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