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;
395f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
405f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // If the context menu was created for a link, and we navigated to that url,
415f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // this will contain the url that was navigated. This field may not be set
425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // if, for example, we are transitioning to an incognito window, since we
435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  // want to sever any connection to the old renderer.
445f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  GURL link_followed;
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// FIXME(beng): This would be more useful in the future and more efficient
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              if the parameters here weren't so literally mapped to what
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              they contain for the ContextMenu task. It might be better
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              to make the string fields more generic so that this object
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//              could be used for more contextual actions.
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct CONTENT_EXPORT ContextMenuParams {
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ContextMenuParams();
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  ~ContextMenuParams();
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the type of Context Node that the context menu was invoked on.
57f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebContextMenuData::MediaType media_type;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These values represent the coordinates of the mouse when the context menu
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was invoked.  Coords are relative to the associated RenderView's origin.
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int x;
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int y;
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the link that encloses the node the context menu was
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked on.
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL link_url;
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The text associated with the link. May be an empty string if the contents
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // of the link are an image.
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Will be empty if link_url is empty.
71a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 link_text;
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The link URL to be used ONLY for "copy link address". We don't validate
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // this field in the frontend process.
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL unfiltered_link_url;
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the source URL for the element that the context menu was
785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // invoked on.  Example of elements with source URLs are img, audio, and
795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // video.
805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL src_url;
815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
82424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // This is true if the context menu was invoked on an image which has
83424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // non-empty contents.
84424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  bool has_image_contents;
855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the top level page that the context menu was invoked
875821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // on.
885821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL page_url;
895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the absolute keyword search URL including the %s search tag when
915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // the "Add as search engine..." option is clicked (left empty if not used).
925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL keyword_url;
935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the URL of the subframe that the context menu was invoked on.
955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  GURL frame_url;
965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // This is the page state of the frame on which the context menu was invoked.
9890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  PageState frame_page_state;
995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These are the parameters for the media element that the context menu
1015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // was invoked on.
1025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int media_flags;
1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This is the text of the selection that the context menu was invoked on.
105a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 selection_text;
1065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
107116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // This is the suggested filename to be used when saving file through "Save
108116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Link As" option of context menu.
109116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  base::string16 suggested_filename;
110116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The misspelled word under the cursor, if any. Used to generate the
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // |dictionary_suggestions| list.
113a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  base::string16 misspelled_word;
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  // The identifier of the misspelling under the cursor, if any.
11690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  uint32 misspelling_hash;
11790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Suggested replacements for a misspelled word under the cursor.
1195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // This vector gets populated in the render process host
1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and populating dictionary_suggestions if the type is EDITABLE
1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // and the misspelled_word is not empty.
123a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  std::vector<base::string16> dictionary_suggestions;
1245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // If editable, flag for whether spell check is enabled or not.
1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool spellcheck_enabled;
1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Whether context is editable.
1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  bool is_editable;
1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Writing direction menu items.
1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int writing_direction_default;
1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int writing_direction_left_to_right;
1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int writing_direction_right_to_left;
1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // These flags indicate to the browser whether the renderer believes it is
1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // able to perform the corresponding action.
1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  int edit_flags;
1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The security info for the resource we are showing the menu on.
1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  SSLStatus security_info;
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The character encoding of the frame on which the menu is invoked.
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  std::string frame_charset;
1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // The referrer policy of the frame on which the menu is invoked.
147f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  blink::WebReferrerPolicy referrer_policy;
1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CustomContextMenuContext custom_context;
1507dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  std::vector<MenuItem> custom_items;
1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
152eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  ui::MenuSourceType source_type;
1537d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)
1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#if defined(OS_ANDROID)
1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Points representing the coordinates in the document space of the start and
1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // end of the selection, if there is one.
1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point selection_start;
1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  gfx::Point selection_end;
1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif
1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
165