context_menu_params.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/string16.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "googleurl/src/gurl.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)#include "content/public/common/page_state.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/public/common/ssl_status.h"
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h"
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "webkit/glue/webmenuitem.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/gfx/point.h"
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT CustomContextMenuContext {
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  static const int32 kCurrentRenderWidget;
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CustomContextMenuContext();
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_pepper_menu;
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int request_id;
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The routing ID of the render widget on which the context menu is shown.
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // It could also be |kCurrentRenderWidget|, which means the render widget that
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the corresponding ViewHostMsg_ContextMenu is sent to.
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int32 render_widget_id;
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// FIXME(beng): This would be more useful in the future and more efficient
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              if the parameters here weren't so literally mapped to what
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              they contain for the ContextMenu task. It might be better
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              to make the string fields more generic so that this object
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              could be used for more contextual actions.
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT ContextMenuParams {
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ContextMenuParams();
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ~ContextMenuParams();
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the type of Context Node that the context menu was invoked on.
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebKit::WebContextMenuData::MediaType media_type;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These values represent the coordinates of the mouse when the context menu
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was invoked.  Coords are relative to the associated RenderView's origin.
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int x;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int y;
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the link that encloses the node the context menu was
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked on.
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL link_url;
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The text associated with the link. May be an empty string if the contents
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of the link are an image.
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Will be empty if link_url is empty.
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  string16 link_text;
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The link URL to be used ONLY for "copy link address". We don't validate
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this field in the frontend process.
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL unfiltered_link_url;
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the source URL for the element that the context menu was
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked on.  Example of elements with source URLs are img, audio, and
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // video.
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL src_url;
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is true if the context menu was invoked on a blocked image.
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_image_blocked;
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the top level page that the context menu was invoked
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on.
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL page_url;
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the absolute keyword search URL including the %s search tag when
825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the "Add as search engine..." option is clicked (left empty if not used).
835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL keyword_url;
845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the subframe that the context menu was invoked on.
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL frame_url;
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the ID of the subframe that the context menu was invoked on.
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int64 frame_id;
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // This is the page state of the frame on which the context menu was invoked.
9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  PageState frame_page_state;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These are the parameters for the media element that the context menu
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was invoked on.
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int media_flags;
975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the text of the selection that the context menu was invoked on.
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  string16 selection_text;
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The misspelled word under the cursor, if any. Used to generate the
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dictionary_suggestions| list.
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  string16 misspelled_word;
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // The identifier of the misspelling under the cursor, if any.
10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  uint32 misspelling_hash;
10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Suggested replacements for a misspelled word under the cursor.
1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This vector gets populated in the render process host
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and populating dictionary_suggestions if the type is EDITABLE
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and the misspelled_word is not empty.
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<string16> dictionary_suggestions;
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If editable, flag for whether node is speech-input enabled.
1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool speech_input_enabled;
1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If editable, flag for whether spell check is enabled or not.
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool spellcheck_enabled;
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether context is editable.
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_editable;
1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_MACOSX)
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Writing direction menu items.
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Currently only used on OS X.
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int writing_direction_default;
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int writing_direction_left_to_right;
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int writing_direction_right_to_left;
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // OS_MACOSX
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.
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebKit::WebReferrerPolicy referrer_policy;
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CustomContextMenuContext custom_context;
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::vector<WebMenuItem> custom_items;
1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Points representing the coordinates in the document space of the start and
1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // end of the selection, if there is one.
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point selection_start;
1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point selection_end;
1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
160