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