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_
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"
22 #if defined(OS_ANDROID)
23 #include "ui/gfx/point.h"
28 struct CONTENT_EXPORT CustomContextMenuContext {
29 static const int32 kCurrentRenderWidget;
31 CustomContextMenuContext();
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;
41 // FIXME(beng): This would be more useful in the future and more efficient
42 // if the parameters here weren't so literally mapped to what
43 // they contain for the ContextMenu task. It might be better
44 // to make the string fields more generic so that this object
45 // could be used for more contextual actions.
46 struct CONTENT_EXPORT ContextMenuParams {
50 // This is the type of Context Node that the context menu was invoked on.
51 blink::WebContextMenuData::MediaType media_type;
53 // These values represent the coordinates of the mouse when the context menu
54 // was invoked. Coords are relative to the associated RenderView's origin.
58 // This is the URL of the link that encloses the node the context menu was
62 // The text associated with the link. May be an empty string if the contents
63 // of the link are an image.
64 // Will be empty if link_url is empty.
65 base::string16 link_text;
67 // The link URL to be used ONLY for "copy link address". We don't validate
68 // this field in the frontend process.
69 GURL unfiltered_link_url;
71 // This is the source URL for the element that the context menu was
72 // invoked on. Example of elements with source URLs are img, audio, and
76 // This is true if the context menu was invoked on an image which has
77 // non-empty contents.
78 bool has_image_contents;
80 // This is the URL of the top level page that the context menu was invoked
84 // This is the absolute keyword search URL including the %s search tag when
85 // the "Add as search engine..." option is clicked (left empty if not used).
88 // This is the URL of the subframe that the context menu was invoked on.
91 // This is the ID of the subframe that the context menu was invoked on.
94 // This is the page state of the frame on which the context menu was invoked.
95 PageState frame_page_state;
97 // These are the parameters for the media element that the context menu
101 // This is the text of the selection that the context menu was invoked on.
102 base::string16 selection_text;
104 // The misspelled word under the cursor, if any. Used to generate the
105 // |dictionary_suggestions| list.
106 base::string16 misspelled_word;
108 // The identifier of the misspelling under the cursor, if any.
109 uint32 misspelling_hash;
111 // Suggested replacements for a misspelled word under the cursor.
112 // This vector gets populated in the render process host
113 // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
114 // and populating dictionary_suggestions if the type is EDITABLE
115 // and the misspelled_word is not empty.
116 std::vector<base::string16> dictionary_suggestions;
118 // If editable, flag for whether node is speech-input enabled.
119 bool speech_input_enabled;
121 // If editable, flag for whether spell check is enabled or not.
122 bool spellcheck_enabled;
124 // Whether context is editable.
127 // Writing direction menu items.
128 int writing_direction_default;
129 int writing_direction_left_to_right;
130 int writing_direction_right_to_left;
132 // These flags indicate to the browser whether the renderer believes it is
133 // able to perform the corresponding action.
136 // The security info for the resource we are showing the menu on.
137 SSLStatus security_info;
139 // The character encoding of the frame on which the menu is invoked.
140 std::string frame_charset;
142 // The referrer policy of the frame on which the menu is invoked.
143 blink::WebReferrerPolicy referrer_policy;
145 CustomContextMenuContext custom_context;
146 std::vector<MenuItem> custom_items;
148 ui::MenuSourceType source_type;
150 #if defined(OS_ANDROID)
151 // Points representing the coordinates in the document space of the start and
152 // end of the selection, if there is one.
153 gfx::Point selection_start;
154 gfx::Point selection_end;
158 } // namespace content
160 #endif // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_