• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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 // Multiply-included message file, no traditional include guard.
6 #include <string>
7 
8 #include "base/basictypes.h"
9 #include "chrome/common/automation_constants.h"
10 #include "chrome/common/content_settings.h"
11 #include "chrome/common/security_style.h"
12 #include "content/common/common_param_traits.h"
13 #include "content/common/page_type.h"
14 #include "content/common/webkit_param_traits.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "ipc/ipc_message_utils.h"
17 #include "net/base/host_port_pair.h"
18 #include "net/base/upload_data.h"
19 #include "ui/gfx/rect.h"
20 
21 // Singly-included section, not yet converted.
22 #ifndef CHROME_COMMON_AUTOMATION_MESSAGES_H__
23 #define CHROME_COMMON_AUTOMATION_MESSAGES_H__
24 
25 struct AutomationMsg_Find_Params {
26   // Unused value, which exists only for backwards compat.
27   int unused;
28 
29   // The word(s) to find on the page.
30   string16 search_string;
31 
32   // Whether to search forward or backward within the page.
33   bool forward;
34 
35   // Whether search should be Case sensitive.
36   bool match_case;
37 
38   // Whether this operation is first request (Find) or a follow-up (FindNext).
39   bool find_next;
40 };
41 
42 struct AutomationURLResponse {
43   AutomationURLResponse();
44   AutomationURLResponse(const std::string& mime_type,
45                         const std::string& headers,
46                         int64 content_length,
47                         const base::Time& last_modified,
48                         const std::string& redirect_url,
49                         int redirect_status,
50                         const net::HostPortPair& host_socket_address);
51   ~AutomationURLResponse();
52 
53   std::string mime_type;
54   std::string headers;
55   int64 content_length;
56   base::Time last_modified;
57   std::string redirect_url;
58   int redirect_status;
59   net::HostPortPair socket_address;
60 };
61 
62 struct ExternalTabSettings {
63   ExternalTabSettings();
64   ExternalTabSettings(gfx::NativeWindow parent,
65                       const gfx::Rect& dimensions,
66                       unsigned int style,
67                       bool is_incognito,
68                       bool load_requests_via_automation,
69                       bool handle_top_level_requests,
70                       const GURL& initial_url,
71                       const GURL& referrer,
72                       bool infobars_enabled,
73                       bool route_all_top_level_navigations);
74   ~ExternalTabSettings();
75 
76   gfx::NativeWindow parent;
77   gfx::Rect dimensions;
78   unsigned int style;
79   bool is_incognito;
80   bool load_requests_via_automation;
81   bool handle_top_level_requests;
82   GURL initial_url;
83   GURL referrer;
84   bool infobars_enabled;
85   bool route_all_top_level_navigations;
86 };
87 
88 struct NavigationInfo {
89   NavigationInfo();
90   NavigationInfo(int navigation_type,
91                  int relative_offset,
92                  int navigation_index,
93                  const std::wstring& title,
94                  const GURL& url,
95                  const GURL& referrer,
96                  SecurityStyle security_style,
97                  bool displayed_insecure_content,
98                  bool ran_insecure_content);
99   ~NavigationInfo();
100 
101   int navigation_type;
102   int relative_offset;
103   int navigation_index;
104   std::wstring title;
105   GURL url;
106   GURL referrer;
107   SecurityStyle security_style;
108   bool displayed_insecure_content;
109   bool ran_insecure_content;
110 };
111 
112 // A stripped down version of ContextMenuParams in webkit/glue/context_menu.h.
113 struct MiniContextMenuParams {
114   MiniContextMenuParams();
115   MiniContextMenuParams(int screen_x,
116                         int screen_y,
117                         const GURL& link_url,
118                         const GURL& unfiltered_link_url,
119                         const GURL& src_url,
120                         const GURL& page_url,
121                         const GURL& frame_url);
122   ~MiniContextMenuParams();
123 
124   // The x coordinate for displaying the menu.
125   int screen_x;
126 
127   // The y coordinate for displaying the menu.
128   int screen_y;
129 
130   // This is the URL of the link that encloses the node the context menu was
131   // invoked on.
132   GURL link_url;
133 
134   // The link URL to be used ONLY for "copy link address". We don't validate
135   // this field in the frontend process.
136   GURL unfiltered_link_url;
137 
138   // This is the source URL for the element that the context menu was
139   // invoked on.  Example of elements with source URLs are img, audio, and
140   // video.
141   GURL src_url;
142 
143   // This is the URL of the top level page that the context menu was invoked
144   // on.
145   GURL page_url;
146 
147   // This is the URL of the subframe that the context menu was invoked on.
148   GURL frame_url;
149 };
150 
151 struct AttachExternalTabParams {
152   AttachExternalTabParams();
153   AttachExternalTabParams(uint64 cookie,
154                           const GURL& url,
155                           const gfx::Rect& dimensions,
156                           int disposition,
157                           bool user_gesture,
158                           const std::string& profile_name);
159   ~AttachExternalTabParams();
160 
161   uint64 cookie;
162   GURL url;
163   gfx::Rect dimensions;
164   int disposition;
165   bool user_gesture;
166   std::string profile_name;
167 };
168 
169 #if defined(OS_WIN)
170 
171 struct Reposition_Params {
172   HWND window;
173   HWND window_insert_after;
174   int left;
175   int top;
176   int width;
177   int height;
178   int flags;
179   bool set_parent;
180   HWND parent_window;
181 };
182 
183 #endif  // defined(OS_WIN)
184 
185 struct AutomationURLRequest {
186   AutomationURLRequest();
187   AutomationURLRequest(const std::string& url,
188                        const std::string& method,
189                        const std::string& referrer,
190                        const std::string& extra_request_headers,
191                        scoped_refptr<net::UploadData> upload_data,
192                        int resource_type,
193                        int load_flags);
194   ~AutomationURLRequest();
195 
196   std::string url;
197   std::string method;
198   std::string referrer;
199   std::string extra_request_headers;
200   scoped_refptr<net::UploadData> upload_data;
201   int resource_type;  // see webkit/glue/resource_type.h
202   int load_flags; // see net/base/load_flags.h
203 };
204 
205 namespace IPC {
206 
207 template <>
208 struct ParamTraits<AutomationMsg_Find_Params> {
209   typedef AutomationMsg_Find_Params param_type;
210   static void Write(Message* m, const param_type& p);
211   static bool Read(const Message* m, void** iter, param_type* p);
212   static void Log(const param_type& p, std::string* l);
213 };
214 
215 template <>
216 struct ParamTraits<AutomationMsg_NavigationResponseValues> {
217   typedef AutomationMsg_NavigationResponseValues param_type;
218   static void Write(Message* m, const param_type& p);
219   static bool Read(const Message* m, void** iter, param_type* p);
220   static void Log(const param_type& p, std::string* l);
221 };
222 
223 template <>
224 struct ParamTraits<AutomationMsg_ExtensionResponseValues> {
225   typedef AutomationMsg_ExtensionResponseValues param_type;
226   static void Write(Message* m, const param_type& p);
227   static bool Read(const Message* m, void** iter, param_type* p);
228   static void Log(const param_type& p, std::string* l);
229 };
230 
231 template <>
232 struct ParamTraits<AutomationMsg_ExtensionProperty> {
233   typedef AutomationMsg_ExtensionProperty param_type;
234   static void Write(Message* m, const param_type& p);
235   static bool Read(const Message* m, void** iter, param_type* p);
236   static void Log(const param_type& p, std::string* l);
237 };
238 
239 template <>
240 struct ParamTraits<SecurityStyle> {
241   typedef SecurityStyle param_type;
242   static void Write(Message* m, const param_type& p);
243   static bool Read(const Message* m, void** iter, param_type* p);
244   static void Log(const param_type& p, std::string* l);
245 };
246 
247 template <>
248 struct ParamTraits<PageType> {
249   typedef PageType param_type;
250   static void Write(Message* m, const param_type& p);
251   static bool Read(const Message* m, void** iter, param_type* p);
252   static void Log(const param_type& p, std::string* l);
253 };
254 
255 #if defined(OS_WIN)
256 
257 // Traits for SetWindowPos_Params structure to pack/unpack.
258 template <>
259 struct ParamTraits<Reposition_Params> {
260   typedef Reposition_Params param_type;
261   static void Write(Message* m, const param_type& p) {
262     WriteParam(m, p.window);
263     WriteParam(m, p.window_insert_after);
264     WriteParam(m, p.left);
265     WriteParam(m, p.top);
266     WriteParam(m, p.width);
267     WriteParam(m, p.height);
268     WriteParam(m, p.flags);
269     WriteParam(m, p.set_parent);
270     WriteParam(m, p.parent_window);
271   }
272   static bool Read(const Message* m, void** iter, param_type* p) {
273     return ReadParam(m, iter, &p->window) &&
274            ReadParam(m, iter, &p->window_insert_after) &&
275            ReadParam(m, iter, &p->left) &&
276            ReadParam(m, iter, &p->top) &&
277            ReadParam(m, iter, &p->width) &&
278            ReadParam(m, iter, &p->height) &&
279            ReadParam(m, iter, &p->flags) &&
280            ReadParam(m, iter, &p->set_parent) &&
281            ReadParam(m, iter, &p->parent_window);
282   }
283   static void Log(const param_type& p, std::string* l) {
284     l->append("(");
285     LogParam(p.window, l);
286     l->append(", ");
287     LogParam(p.window_insert_after, l);
288     l->append(", ");
289     LogParam(p.left, l);
290     l->append(", ");
291     LogParam(p.top, l);
292     l->append(", ");
293     LogParam(p.width, l);
294     l->append(", ");
295     LogParam(p.height, l);
296     l->append(", ");
297     LogParam(p.flags, l);
298     l->append(", ");
299     LogParam(p.set_parent, l);
300     l->append(", ");
301     LogParam(p.parent_window, l);
302     l->append(")");
303   }
304 };
305 #endif  // defined(OS_WIN)
306 
307 // Traits for AutomationURLRequest structure to pack/unpack.
308 template <>
309 struct ParamTraits<AutomationURLRequest> {
310   typedef AutomationURLRequest param_type;
311   static void Write(Message* m, const param_type& p);
312   static bool Read(const Message* m, void** iter, param_type* p);
313   static void Log(const param_type& p, std::string* l);
314 };
315 
316 // Traits for AutomationURLResponse structure to pack/unpack.
317 template <>
318 struct ParamTraits<AutomationURLResponse> {
319   typedef AutomationURLResponse param_type;
320   static void Write(Message* m, const param_type& p);
321   static bool Read(const Message* m, void** iter, param_type* p);
322   static void Log(const param_type& p, std::string* l);
323 };
324 
325 // Traits for ExternalTabSettings structure to pack/unpack.
326 template <>
327 struct ParamTraits<ExternalTabSettings> {
328   typedef ExternalTabSettings param_type;
329   static void Write(Message* m, const param_type& p);
330   static bool Read(const Message* m, void** iter, param_type* p);
331   static void Log(const param_type& p, std::string* l);
332 };
333 
334 // Traits for NavigationInfo structure to pack/unpack.
335 template <>
336 struct ParamTraits<NavigationInfo> {
337   typedef NavigationInfo param_type;
338   static void Write(Message* m, const param_type& p);
339   static bool Read(const Message* m, void** iter, param_type* p);
340   static void Log(const param_type& p, std::string* l);
341 };
342 
343 // Traits for MiniContextMenuParams structure to pack/unpack.
344 template <>
345 struct ParamTraits<MiniContextMenuParams> {
346   typedef MiniContextMenuParams param_type;
347   static void Write(Message* m, const param_type& p);
348   static bool Read(const Message* m, void** iter, param_type* p);
349   static void Log(const param_type& p, std::string* l);
350 };
351 
352 template <>
353 struct ParamTraits<AttachExternalTabParams> {
354   typedef AttachExternalTabParams param_type;
355   static void Write(Message* m, const param_type& p);
356   static bool Read(const Message* m, void** iter, param_type* p);
357   static void Log(const param_type& p, std::string* l);
358 };
359 
360 }  // namespace IPC
361 
362 #endif  // CHROME_COMMON_AUTOMATION_MESSAGES_H__
363 
364 // Keep this internal message file unchanged to preserve line numbering
365 // (and hence the dubious __LINE__-based message numberings) across versions.
366 #include "chrome/common/automation_messages_internal.h"
367 
368