context_menu_params.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector> 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h" 117d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h" 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h" 1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/common/page_state.h" 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/ssl_status.h" 157d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "googleurl/src/gurl.h" 167d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "third_party/WebKit/public/web/WebContextMenuData.h" 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebReferrerPolicy.h" 18eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ui/base/ui_base_types.h" 197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "webkit/common/webmenuitem.h" 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID) 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/point.h" 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content { 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT CustomContextMenuContext { 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static const int32 kCurrentRenderWidget; 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CustomContextMenuContext(); 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_pepper_menu; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int request_id; 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The routing ID of the render widget on which the context menu is shown. 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // It could also be |kCurrentRenderWidget|, which means the render widget that 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the corresponding ViewHostMsg_ContextMenu is sent to. 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int32 render_widget_id; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// FIXME(beng): This would be more useful in the future and more efficient 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// if the parameters here weren't so literally mapped to what 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// they contain for the ContextMenu task. It might be better 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// to make the string fields more generic so that this object 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// could be used for more contextual actions. 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT ContextMenuParams { 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ContextMenuParams(); 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) ~ContextMenuParams(); 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the type of Context Node that the context menu was invoked on. 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebContextMenuData::MediaType media_type; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These values represent the coordinates of the mouse when the context menu 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // was invoked. Coords are relative to the associated RenderView's origin. 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int x; 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int y; 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the URL of the link that encloses the node the context menu was 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // invoked on. 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL link_url; 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The text associated with the link. May be an empty string if the contents 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // of the link are an image. 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Will be empty if link_url is empty. 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) string16 link_text; 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The link URL to be used ONLY for "copy link address". We don't validate 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // this field in the frontend process. 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL unfiltered_link_url; 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the source URL for the element that the context menu was 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // invoked on. Example of elements with source URLs are img, audio, and 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // video. 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL src_url; 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is true if the context menu was invoked on a blocked image. 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_image_blocked; 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the URL of the top level page that the context menu was invoked 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // on. 805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL page_url; 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the absolute keyword search URL including the %s search tag when 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // the "Add as search engine..." option is clicked (left empty if not used). 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL keyword_url; 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the URL of the subframe that the context menu was invoked on. 875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GURL frame_url; 885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the ID of the subframe that the context menu was invoked on. 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int64 frame_id; 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // This is the page state of the frame on which the context menu was invoked. 9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) PageState frame_page_state; 945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These are the parameters for the media element that the context menu 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // was invoked on. 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int media_flags; 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This is the text of the selection that the context menu was invoked on. 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) string16 selection_text; 1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The misspelled word under the cursor, if any. Used to generate the 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // |dictionary_suggestions| list. 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) string16 misspelled_word; 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // The identifier of the misspelling under the cursor, if any. 10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) uint32 misspelling_hash; 10890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Suggested replacements for a misspelled word under the cursor. 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // This vector gets populated in the render process host 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and populating dictionary_suggestions if the type is EDITABLE 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // and the misspelled_word is not empty. 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<string16> dictionary_suggestions; 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If editable, flag for whether node is speech-input enabled. 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool speech_input_enabled; 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // If editable, flag for whether spell check is enabled or not. 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool spellcheck_enabled; 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Whether context is editable. 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool is_editable; 1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Writing direction menu items. 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Currently only used on OS X. 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int writing_direction_default; 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int writing_direction_left_to_right; 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int writing_direction_right_to_left; 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // OS_MACOSX 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // These flags indicate to the browser whether the renderer believes it is 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // able to perform the corresponding action. 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int edit_flags; 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The security info for the resource we are showing the menu on. 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) SSLStatus security_info; 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The character encoding of the frame on which the menu is invoked. 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::string frame_charset; 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // The referrer policy of the frame on which the menu is invoked. 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) WebKit::WebReferrerPolicy referrer_policy; 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CustomContextMenuContext custom_context; 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) std::vector<WebMenuItem> custom_items; 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 149eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch ui::MenuSourceType source_type; 1507d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID) 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Points representing the coordinates in the document space of the start and 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // end of the selection, if there is one. 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point selection_start; 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) gfx::Point selection_end; 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace content 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_ 163