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. 4 5 #ifndef CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_ 6 #define CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_ 7 8 #include <string> 9 #include <vector> 10 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" 21 22 #if defined(OS_ANDROID) 23 #include "ui/gfx/point.h" 24 #endif 25 26 namespace content { 27 28 struct CONTENT_EXPORT CustomContextMenuContext { 29 static const int32 kCurrentRenderWidget; 30 31 CustomContextMenuContext(); 32 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; 39 }; 40 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 { 47 ContextMenuParams(); 48 ~ContextMenuParams(); 49 50 // This is the type of Context Node that the context menu was invoked on. 51 blink::WebContextMenuData::MediaType media_type; 52 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. 55 int x; 56 int y; 57 58 // This is the URL of the link that encloses the node the context menu was 59 // invoked on. 60 GURL link_url; 61 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; 66 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; 70 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 73 // video. 74 GURL src_url; 75 76 // This is true if the context menu was invoked on an image which has 77 // non-empty contents. 78 bool has_image_contents; 79 80 // This is the URL of the top level page that the context menu was invoked 81 // on. 82 GURL page_url; 83 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). 86 GURL keyword_url; 87 88 // This is the URL of the subframe that the context menu was invoked on. 89 GURL frame_url; 90 91 // This is the page state of the frame on which the context menu was invoked. 92 PageState frame_page_state; 93 94 // These are the parameters for the media element that the context menu 95 // was invoked on. 96 int media_flags; 97 98 // This is the text of the selection that the context menu was invoked on. 99 base::string16 selection_text; 100 101 // The misspelled word under the cursor, if any. Used to generate the 102 // |dictionary_suggestions| list. 103 base::string16 misspelled_word; 104 105 // The identifier of the misspelling under the cursor, if any. 106 uint32 misspelling_hash; 107 108 // Suggested replacements for a misspelled word under the cursor. 109 // This vector gets populated in the render process host 110 // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter 111 // and populating dictionary_suggestions if the type is EDITABLE 112 // and the misspelled_word is not empty. 113 std::vector<base::string16> dictionary_suggestions; 114 115 // If editable, flag for whether spell check is enabled or not. 116 bool spellcheck_enabled; 117 118 // Whether context is editable. 119 bool is_editable; 120 121 // Writing direction menu items. 122 int writing_direction_default; 123 int writing_direction_left_to_right; 124 int writing_direction_right_to_left; 125 126 // These flags indicate to the browser whether the renderer believes it is 127 // able to perform the corresponding action. 128 int edit_flags; 129 130 // The security info for the resource we are showing the menu on. 131 SSLStatus security_info; 132 133 // The character encoding of the frame on which the menu is invoked. 134 std::string frame_charset; 135 136 // The referrer policy of the frame on which the menu is invoked. 137 blink::WebReferrerPolicy referrer_policy; 138 139 CustomContextMenuContext custom_context; 140 std::vector<MenuItem> custom_items; 141 142 ui::MenuSourceType source_type; 143 144 #if defined(OS_ANDROID) 145 // Points representing the coordinates in the document space of the start and 146 // end of the selection, if there is one. 147 gfx::Point selection_start; 148 gfx::Point selection_end; 149 #endif 150 }; 151 152 } // namespace content 153 154 #endif // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_ 155