Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / public / common / context_menu_params.h
blob15b0598102027bc7bd506ea43194d47f1bfc5e51
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 <map>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/strings/string16.h"
14 #include "content/common/content_export.h"
15 #include "content/public/common/menu_item.h"
16 #include "content/public/common/page_state.h"
17 #include "content/public/common/ssl_status.h"
18 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
19 #include "third_party/WebKit/public/web/WebContextMenuData.h"
20 #include "ui/base/ui_base_types.h"
21 #include "url/gurl.h"
23 #if defined(OS_ANDROID)
24 #include "ui/gfx/geometry/point.h"
25 #endif
27 namespace content {
29 struct CONTENT_EXPORT CustomContextMenuContext {
30 static const int32 kCurrentRenderWidget;
32 CustomContextMenuContext();
34 bool is_pepper_menu;
35 int request_id;
36 // The routing ID of the render widget on which the context menu is shown.
37 // It could also be |kCurrentRenderWidget|, which means the render widget that
38 // the corresponding ViewHostMsg_ContextMenu is sent to.
39 int32 render_widget_id;
41 // If the context menu was created for a link, and we navigated to that url,
42 // this will contain the url that was navigated. This field may not be set
43 // if, for example, we are transitioning to an incognito window, since we
44 // want to sever any connection to the old renderer.
45 GURL link_followed;
48 // FIXME(beng): This would be more useful in the future and more efficient
49 // if the parameters here weren't so literally mapped to what
50 // they contain for the ContextMenu task. It might be better
51 // to make the string fields more generic so that this object
52 // could be used for more contextual actions.
53 struct CONTENT_EXPORT ContextMenuParams {
54 ContextMenuParams();
55 ~ContextMenuParams();
57 // This is the type of Context Node that the context menu was invoked on.
58 blink::WebContextMenuData::MediaType media_type;
60 // These values represent the coordinates of the mouse when the context menu
61 // was invoked. Coords are relative to the associated RenderView's origin.
62 int x;
63 int y;
65 // This is the URL of the link that encloses the node the context menu was
66 // invoked on.
67 GURL link_url;
69 // The text associated with the link. May be an empty string if the contents
70 // of the link are an image.
71 // Will be empty if link_url is empty.
72 base::string16 link_text;
74 // The link URL to be used ONLY for "copy link address". We don't validate
75 // this field in the frontend process.
76 GURL unfiltered_link_url;
78 // This is the source URL for the element that the context menu was
79 // invoked on. Example of elements with source URLs are img, audio, and
80 // video.
81 GURL src_url;
83 // This is true if the context menu was invoked on an image which has
84 // non-empty contents.
85 bool has_image_contents;
87 // This is the URL of the top level page that the context menu was invoked
88 // on.
89 GURL page_url;
91 // This is the absolute keyword search URL including the %s search tag when
92 // the "Add as search engine..." option is clicked (left empty if not used).
93 GURL keyword_url;
95 // This is the URL of the subframe that the context menu was invoked on.
96 GURL frame_url;
98 // This is the page state of the frame on which the context menu was invoked.
99 PageState frame_page_state;
101 // These are the parameters for the media element that the context menu
102 // was invoked on.
103 int media_flags;
105 // This is the text of the selection that the context menu was invoked on.
106 base::string16 selection_text;
108 // This is the title or alt (if title not available) text of the selection
109 // that the context menu was invoked on.
110 base::string16 title_text;
112 // This is the suggested filename to be used when saving file through "Save
113 // Link As" option of context menu.
114 base::string16 suggested_filename;
116 // The misspelled word under the cursor, if any. Used to generate the
117 // |dictionary_suggestions| list.
118 base::string16 misspelled_word;
120 // The identifier of the misspelling under the cursor, if any.
121 uint32 misspelling_hash;
123 // Suggested replacements for a misspelled word under the cursor.
124 // This vector gets populated in the render process host
125 // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
126 // and populating dictionary_suggestions if the type is EDITABLE
127 // and the misspelled_word is not empty.
128 std::vector<base::string16> dictionary_suggestions;
130 // If editable, flag for whether spell check is enabled or not.
131 bool spellcheck_enabled;
133 // Whether context is editable.
134 bool is_editable;
136 // Writing direction menu items.
137 int writing_direction_default;
138 int writing_direction_left_to_right;
139 int writing_direction_right_to_left;
141 // These flags indicate to the browser whether the renderer believes it is
142 // able to perform the corresponding action.
143 int edit_flags;
145 // The security info for the resource we are showing the menu on.
146 SSLStatus security_info;
148 // The character encoding of the frame on which the menu is invoked.
149 std::string frame_charset;
151 // The referrer policy of the frame on which the menu is invoked.
152 blink::WebReferrerPolicy referrer_policy;
154 CustomContextMenuContext custom_context;
155 std::vector<MenuItem> custom_items;
157 ui::MenuSourceType source_type;
159 // Extra properties for the context menu.
160 std::map<std::string, std::string> properties;
162 #if defined(OS_ANDROID)
163 // Points representing the coordinates in the document space of the start and
164 // end of the selection, if there is one.
165 gfx::Point selection_start;
166 gfx::Point selection_end;
167 #endif
169 // If this node is an input field, the type of that field.
170 blink::WebContextMenuData::InputFieldType input_field_type;
173 } // namespace content
175 #endif // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_