Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / content / public / common / context_menu_params.h
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 <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/strings/string16.h"
13 #include "content/common/content_export.h"
14 #include "content/public/common/menu_item.h"
15 #include "content/public/common/page_state.h"
16 #include "content/public/common/ssl_status.h"
17 #include "third_party/WebKit/public/platform/WebReferrerPolicy.h"
18 #include "third_party/WebKit/public/web/WebContextMenuData.h"
19 #include "ui/base/ui_base_types.h"
20 #include "url/gurl.h"
21
22 #if defined(OS_ANDROID)
23 #include "ui/gfx/point.h"
24 #endif
25
26 namespace content {
27
28 struct CONTENT_EXPORT CustomContextMenuContext {
29   static const int32 kCurrentRenderWidget;
30
31   CustomContextMenuContext();
32
33   bool is_pepper_menu;
34   int request_id;
35   // The routing ID of the render widget on which the context menu is shown.
36   // It could also be |kCurrentRenderWidget|, which means the render widget that
37   // the corresponding ViewHostMsg_ContextMenu is sent to.
38   int32 render_widget_id;
39 };
40
41 // FIXME(beng): This would be more useful in the future and more efficient
42 //              if the parameters here weren't so literally mapped to what
43 //              they contain for the ContextMenu task. It might be better
44 //              to make the string fields more generic so that this object
45 //              could be used for more contextual actions.
46 struct CONTENT_EXPORT ContextMenuParams {
47   ContextMenuParams();
48   ~ContextMenuParams();
49
50   // This is the type of Context Node that the context menu was invoked on.
51   blink::WebContextMenuData::MediaType media_type;
52
53   // These values represent the coordinates of the mouse when the context menu
54   // was invoked.  Coords are relative to the associated RenderView's origin.
55   int x;
56   int y;
57
58   // This is the URL of the link that encloses the node the context menu was
59   // invoked on.
60   GURL link_url;
61
62   // The text associated with the link. May be an empty string if the contents
63   // of the link are an image.
64   // Will be empty if link_url is empty.
65   base::string16 link_text;
66
67   // The link URL to be used ONLY for "copy link address". We don't validate
68   // this field in the frontend process.
69   GURL unfiltered_link_url;
70
71   // This is the source URL for the element that the context menu was
72   // invoked on.  Example of elements with source URLs are img, audio, and
73   // video.
74   GURL src_url;
75
76   // This is true if the context menu was invoked on an image which has
77   // non-empty contents.
78   bool has_image_contents;
79
80   // This is the URL of the top level page that the context menu was invoked
81   // on.
82   GURL page_url;
83
84   // This is the absolute keyword search URL including the %s search tag when
85   // the "Add as search engine..." option is clicked (left empty if not used).
86   GURL keyword_url;
87
88   // This is the URL of the subframe that the context menu was invoked on.
89   GURL frame_url;
90
91   // This is the ID of the subframe that the context menu was invoked on.
92   int64 frame_id;
93
94   // This is the page state of the frame on which the context menu was invoked.
95   PageState frame_page_state;
96
97   // These are the parameters for the media element that the context menu
98   // was invoked on.
99   int media_flags;
100
101   // This is the text of the selection that the context menu was invoked on.
102   base::string16 selection_text;
103
104   // The misspelled word under the cursor, if any. Used to generate the
105   // |dictionary_suggestions| list.
106   base::string16 misspelled_word;
107
108   // The identifier of the misspelling under the cursor, if any.
109   uint32 misspelling_hash;
110
111   // Suggested replacements for a misspelled word under the cursor.
112   // This vector gets populated in the render process host
113   // by intercepting ViewHostMsg_ContextMenu in ResourceMessageFilter
114   // and populating dictionary_suggestions if the type is EDITABLE
115   // and the misspelled_word is not empty.
116   std::vector<base::string16> dictionary_suggestions;
117
118   // If editable, flag for whether node is speech-input enabled.
119   bool speech_input_enabled;
120
121   // If editable, flag for whether spell check is enabled or not.
122   bool spellcheck_enabled;
123
124   // Whether context is editable.
125   bool is_editable;
126
127   // Writing direction menu items.
128   int writing_direction_default;
129   int writing_direction_left_to_right;
130   int writing_direction_right_to_left;
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   blink::WebReferrerPolicy referrer_policy;
144
145   CustomContextMenuContext custom_context;
146   std::vector<MenuItem> custom_items;
147
148   ui::MenuSourceType source_type;
149
150 #if defined(OS_ANDROID)
151   // Points representing the coordinates in the document space of the start and
152   // end of the selection, if there is one.
153   gfx::Point selection_start;
154   gfx::Point selection_end;
155 #endif
156 };
157
158 }  // namespace content
159
160 #endif  // CONTENT_PUBLIC_COMMON_CONTEXT_MENU_PARAMS_H_