context_menu_params.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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)
8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include <string>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
127d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
147dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "content/public/common/menu_item.h"
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/common/page_state.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/ssl_status.h"
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
187dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "third_party/WebKit/public/web/WebContextMenuData.h"
19eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "ui/base/ui_base_types.h"
207dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "url/gurl.h"
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/point.h"
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT CustomContextMenuContext {
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int32 kCurrentRenderWidget;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CustomContextMenuContext();
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_pepper_menu;
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int request_id;
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The routing ID of the render widget on which the context menu is shown.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // It could also be |kCurrentRenderWidget|, which means the render widget that
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the corresponding ViewHostMsg_ContextMenu is sent to.
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int32 render_widget_id;
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// FIXME(beng): This would be more useful in the future and more efficient
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              if the parameters here weren't so literally mapped to what
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              they contain for the ContextMenu task. It might be better
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              to make the string fields more generic so that this object
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              could be used for more contextual actions.
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT ContextMenuParams {
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ContextMenuParams();
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ~ContextMenuParams();
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the type of Context Node that the context menu was invoked on.
51f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebContextMenuData::MediaType media_type;
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These values represent the coordinates of the mouse when the context menu
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was invoked.  Coords are relative to the associated RenderView's origin.
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int x;
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int y;
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the link that encloses the node the context menu was
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked on.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL link_url;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The text associated with the link. May be an empty string if the contents
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of the link are an image.
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Will be empty if link_url is empty.
65a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 link_text;
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The link URL to be used ONLY for "copy link address". We don't validate
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this field in the frontend process.
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL unfiltered_link_url;
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the source URL for the element that the context menu was
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked on.  Example of elements with source URLs are img, audio, and
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // video.
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL src_url;
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
76424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // This is true if the context menu was invoked on an image which has
77424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // non-empty contents.
78424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  bool has_image_contents;
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the top level page that the context menu was invoked
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on.
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL page_url;
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the absolute keyword search URL including the %s search tag when
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the "Add as search engine..." option is clicked (left empty if not used).
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL keyword_url;
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the subframe that the context menu was invoked on.
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL frame_url;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the ID of the subframe that the context menu was invoked on.
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int64 frame_id;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // This is the page state of the frame on which the context menu was invoked.
9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  PageState frame_page_state;
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These are the parameters for the media element that the context menu
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was invoked on.
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int media_flags;
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the text of the selection that the context menu was invoked on.
102a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 selection_text;
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The misspelled word under the cursor, if any. Used to generate the
1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dictionary_suggestions| list.
106a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 misspelled_word;
1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // The identifier of the misspelling under the cursor, if any.
10990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  uint32 misspelling_hash;
11090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Suggested replacements for a misspelled word under the cursor.
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This vector gets populated in the render process host
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and populating dictionary_suggestions if the type is EDITABLE
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and the misspelled_word is not empty.
116a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  std::vector<base::string16> dictionary_suggestions;
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If editable, flag for whether node is speech-input enabled.
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool speech_input_enabled;
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If editable, flag for whether spell check is enabled or not.
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool spellcheck_enabled;
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether context is editable.
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_editable;
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Writing direction menu items.
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)
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These flags indicate to the browser whether the renderer believes it is
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // able to perform the corresponding action.
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int edit_flags;
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The security info for the resource we are showing the menu on.
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SSLStatus security_info;
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The character encoding of the frame on which the menu is invoked.
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string frame_charset;
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The referrer policy of the frame on which the menu is invoked.
143f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebReferrerPolicy referrer_policy;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CustomContextMenuContext custom_context;
1467dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  std::vector<MenuItem> custom_items;
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
148eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  ui::MenuSourceType source_type;
1497d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Points representing the coordinates in the document space of the start and
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // end of the selection, if there is one.
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point selection_start;
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point selection_end;
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
161