context_menu_params.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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 <vector>
9
10#include "base/basictypes.h"
11#include "base/string16.h"
12#include "googleurl/src/gurl.h"
13#include "content/common/content_export.h"
14#include "content/public/common/page_state.h"
15#include "content/public/common/ssl_status.h"
16#include "third_party/WebKit/Source/Platform/chromium/public/WebReferrerPolicy.h"
17#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
18#include "webkit/glue/webmenuitem.h"
19
20#if defined(OS_ANDROID)
21#include "ui/gfx/point.h"
22#endif
23
24namespace content {
25
26struct CONTENT_EXPORT CustomContextMenuContext {
27  static const int32 kCurrentRenderWidget;
28
29  CustomContextMenuContext();
30
31  bool is_pepper_menu;
32  int request_id;
33  // The routing ID of the render widget on which the context menu is shown.
34  // It could also be |kCurrentRenderWidget|, which means the render widget that
35  // the corresponding ViewHostMsg_ContextMenu is sent to.
36  int32 render_widget_id;
37};
38
39// FIXME(beng): This would be more useful in the future and more efficient
40//              if the parameters here weren't so literally mapped to what
41//              they contain for the ContextMenu task. It might be better
42//              to make the string fields more generic so that this object
43//              could be used for more contextual actions.
44struct CONTENT_EXPORT ContextMenuParams {
45  ContextMenuParams();
46  ~ContextMenuParams();
47
48  // This is the type of Context Node that the context menu was invoked on.
49  WebKit::WebContextMenuData::MediaType media_type;
50
51  // These values represent the coordinates of the mouse when the context menu
52  // was invoked.  Coords are relative to the associated RenderView's origin.
53  int x;
54  int y;
55
56  // This is the URL of the link that encloses the node the context menu was
57  // invoked on.
58  GURL link_url;
59
60  // The text associated with the link. May be an empty string if the contents
61  // of the link are an image.
62  // Will be empty if link_url is empty.
63  string16 link_text;
64
65  // The link URL to be used ONLY for "copy link address". We don't validate
66  // this field in the frontend process.
67  GURL unfiltered_link_url;
68
69  // This is the source URL for the element that the context menu was
70  // invoked on.  Example of elements with source URLs are img, audio, and
71  // video.
72  GURL src_url;
73
74  // This is true if the context menu was invoked on a blocked image.
75  bool is_image_blocked;
76
77  // This is the URL of the top level page that the context menu was invoked
78  // on.
79  GURL page_url;
80
81  // This is the absolute keyword search URL including the %s search tag when
82  // the "Add as search engine..." option is clicked (left empty if not used).
83  GURL keyword_url;
84
85  // This is the URL of the subframe that the context menu was invoked on.
86  GURL frame_url;
87
88  // This is the ID of the subframe that the context menu was invoked on.
89  int64 frame_id;
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  string16 selection_text;
100
101  // The misspelled word under the cursor, if any. Used to generate the
102  // |dictionary_suggestions| list.
103  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<string16> dictionary_suggestions;
114
115  // If editable, flag for whether node is speech-input enabled.
116  bool speech_input_enabled;
117
118  // If editable, flag for whether spell check is enabled or not.
119  bool spellcheck_enabled;
120
121  // Whether context is editable.
122  bool is_editable;
123
124#if defined(OS_MACOSX)
125  // Writing direction menu items.
126  // Currently only used on OS X.
127  int writing_direction_default;
128  int writing_direction_left_to_right;
129  int writing_direction_right_to_left;
130#endif  // OS_MACOSX
131
132  // These flags indicate to the browser whether the renderer believes it is
133  // able to perform the corresponding action.
134  int edit_flags;
135
136  // The security info for the resource we are showing the menu on.
137  SSLStatus security_info;
138
139  // The character encoding of the frame on which the menu is invoked.
140  std::string frame_charset;
141
142  // The referrer policy of the frame on which the menu is invoked.
143  WebKit::WebReferrerPolicy referrer_policy;
144
145  CustomContextMenuContext custom_context;
146  std::vector<WebMenuItem> custom_items;
147
148#if defined(OS_ANDROID)
149  // Points representing the coordinates in the document space of the start and
150  // end of the selection, if there is one.
151  gfx::Point selection_start;
152  gfx::Point selection_end;
153#endif
154
155};
156
157}  // namespace content
158
159#endif  // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_
160