Chromecast ATV: distinguish actual shutdown vs. lifecycle from sleep.
[chromium-blink-merge.git] / content / public / common / context_menu_params.h
blobea8d90fead48f96f91c56a9c57787ee6337bba12
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
6 #define CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h"
14 #include "content/public/common/menu_item.h"
15 #include "content/public/common/page_state.h"
16 #include "content/public/common/ssl_status.h"
17 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
18 #include "third_party/WebKit/public/web/WebContextMenuData.h"
19 #include "ui/base/ui_base_types.h"
20 #include "url/gurl.h"
22 #if defined(OS_ANDROID)
23 #include "ui/gfx/geometry/point.h"
24 #endif
26 namespace content {
28 struct CONTENT_EXPORT CustomContextMenuContext {
29 static const int32 kCurrentRenderWidget;
31 CustomContextMenuContext();
33 bool is_pepper_menu;
34 int request_id;
35 // The routing ID of the render widget on which the context menu is shown.
36 // It could also be |kCurrentRenderWidget|, which means the render widget that
37 // the corresponding ViewHostMsg_ContextMenu is sent to.
38 int32 render_widget_id;
40 // If the context menu was created for a link, and we navigated to that url,
41 // this will contain the url that was navigated. This field may not be set
42 // if, for example, we are transitioning to an incognito window, since we
43 // want to sever any connection to the old renderer.
44 GURL link_followed;
47 // FIXME(beng): This would be more useful in the future and more efficient
48 // if the parameters here weren't so literally mapped to what
49 // they contain for the ContextMenu task. It might be better
50 // to make the string fields more generic so that this object
51 // could be used for more contextual actions.
52 struct CONTENT_EXPORT ContextMenuParams {
53 ContextMenuParams();
54 ~ContextMenuParams();
56 // This is the type of Context Node that the context menu was invoked on.
57 blink::WebContextMenuData::MediaType media_type;
59 // These values represent the coordinates of the mouse when the context menu
60 // was invoked. Coords are relative to the associated RenderView's origin.
61 int x;
62 int y;
64 // This is the URL of the link that encloses the node the context menu was
65 // invoked on.
66 GURL link_url;
68 // The text associated with the link. May be an empty string if the contents
69 // of the link are an image.
70 // Will be empty if link_url is empty.
71 base::string16 link_text;
73 // The link URL to be used ONLY for "copy link address". We don't validate
74 // this field in the frontend process.
75 GURL unfiltered_link_url;
77 // This is the source URL for the element that the context menu was
78 // invoked on. Example of elements with source URLs are img, audio, and
79 // video.
80 GURL src_url;
82 // This is true if the context menu was invoked on an image which has
83 // non-empty contents.
84 bool has_image_contents;
86 // This is the URL of the top level page that the context menu was invoked
87 // on.
88 GURL page_url;
90 // This is the absolute keyword search URL including the %s search tag when
91 // the "Add as search engine..." option is clicked (left empty if not used).
92 GURL keyword_url;
94 // This is the URL of the subframe that the context menu was invoked on.
95 GURL frame_url;
97 // This is the page state of the frame on which the context menu was invoked.
98 PageState frame_page_state;
100 // These are the parameters for the media element that the context menu
101 // was invoked on.
102 int media_flags;
104 // This is the text of the selection that the context menu was invoked on.
105 base::string16 selection_text;
107 // This is the suggested filename to be used when saving file through "Save
108 // Link As" option of context menu.
109 base::string16 suggested_filename;
111 // The misspelled word under the cursor, if any. Used to generate the
112 // |dictionary_suggestions| list.
113 base::string16 misspelled_word;
115 // Suggested replacements for a misspelled word under the cursor.
116 // This vector gets populated in the render process host
117 // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
118 // and populating dictionary_suggestions if the type is EDITABLE
119 // and the misspelled_word is not empty.
120 std::vector<base::string16> dictionary_suggestions;
122 // If editable, flag for whether spell check is enabled or not.
123 bool spellcheck_enabled;
125 // Whether context is editable.
126 bool is_editable;
128 // Writing direction menu items.
129 int writing_direction_default;
130 int writing_direction_left_to_right;
131 int writing_direction_right_to_left;
133 // These flags indicate to the browser whether the renderer believes it is
134 // able to perform the corresponding action.
135 int edit_flags;
137 // The security info for the resource we are showing the menu on.
138 SSLStatus security_info;
140 // The character encoding of the frame on which the menu is invoked.
141 std::string frame_charset;
143 // The referrer policy of the frame on which the menu is invoked.
144 blink::WebReferrerPolicy referrer_policy;
146 CustomContextMenuContext custom_context;
147 std::vector<MenuItem> custom_items;
149 ui::MenuSourceType source_type;
151 #if defined(OS_ANDROID)
152 // Points representing the coordinates in the document space of the start and
153 // end of the selection, if there is one.
154 gfx::Point selection_start;
155 gfx::Point selection_end;
156 #endif
159 } // namespace content
161 #endif // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_