OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // source code is governed by a BSD-style license that can be found in the |
3 // found in the LICENSE file. | 3 // LICENSE file. |
| 4 // |
| 5 // This file contains ParamTraits templates to support serialization of WebKit |
| 6 // data types over IPC. |
4 | 7 |
5 #ifndef CHROME_COMMON_RENDER_MESSAGES_H_ | 8 #ifndef CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ |
6 #define CHROME_COMMON_RENDER_MESSAGES_H_ | 9 #define CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ |
7 | 10 |
8 #include <string> | |
9 #include <vector> | |
10 #include <map> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/gfx/native_widget_types.h" | |
14 #include "base/ref_counted.h" | |
15 #include "base/shared_memory.h" | |
16 #include "chrome/browser/renderer_host/resource_handler.h" | |
17 #include "chrome/common/filter_policy.h" | |
18 #include "chrome/common/ipc_message_utils.h" | 11 #include "chrome/common/ipc_message_utils.h" |
19 #include "chrome/common/modal_dialog_event.h" | |
20 #include "chrome/common/page_transition_types.h" | |
21 #include "chrome/common/transport_dib.h" | |
22 #include "googleurl/src/gurl.h" | |
23 #include "media/audio/audio_output.h" | |
24 #include "net/base/upload_data.h" | |
25 #include "net/http/http_response_headers.h" | |
26 #include "net/url_request/url_request_status.h" | |
27 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebCache.h" |
28 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" |
29 #include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebFindInPageRequest.h" |
30 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
31 #include "webkit/glue/autofill_form.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" |
32 #include "webkit/glue/context_menu.h" | |
33 #include "webkit/glue/feed.h" | |
34 #include "webkit/glue/form_data.h" | |
35 #include "webkit/glue/password_form.h" | |
36 #include "webkit/glue/password_form_dom_manager.h" | |
37 #include "webkit/glue/resource_loader_bridge.h" | |
38 #include "webkit/glue/screen_info.h" | |
39 #include "webkit/glue/webaccessibility.h" | |
40 #include "webkit/glue/webdropdata.h" | |
41 #include "webkit/glue/webplugin.h" | |
42 #include "webkit/glue/webpreferences.h" | |
43 #include "webkit/glue/webview_delegate.h" | |
44 | |
45 #if defined(OS_POSIX) | |
46 #include "skia/include/SkBitmap.h" | |
47 #endif | |
48 | |
49 struct ViewHostMsg_UpdateFeedList_Params { | |
50 // The page_id for this navigation, or -1 if it is a new navigation. Back, | |
51 // Forward, and Reload navigations should have a valid page_id. If the load | |
52 // succeeds, then this page_id will be reflected in the resulting | |
53 // ViewHostMsg_FrameNavigate message. | |
54 int32 page_id; | |
55 | |
56 // The list of available feeds. | |
57 scoped_refptr<FeedList> feedlist; | |
58 }; | |
59 | |
60 // Parameters structure for ViewMsg_Navigate, which has too many data | |
61 // parameters to be reasonably put in a predefined IPC message. | |
62 struct ViewMsg_Navigate_Params { | |
63 // The page_id for this navigation, or -1 if it is a new navigation. Back, | |
64 // Forward, and Reload navigations should have a valid page_id. If the load | |
65 // succeeds, then this page_id will be reflected in the resultant | |
66 // ViewHostMsg_FrameNavigate message. | |
67 int32 page_id; | |
68 | |
69 // The URL to load. | |
70 GURL url; | |
71 | |
72 // The URL to send in the "Referer" header field. Can be empty if there is | |
73 // no referrer. | |
74 GURL referrer; | |
75 | |
76 // The type of transition. | |
77 PageTransition::Type transition; | |
78 | |
79 // Opaque history state (received by ViewHostMsg_UpdateState). | |
80 std::string state; | |
81 | |
82 // Specifies if the URL should be loaded using 'reload' semantics (i.e., | |
83 // bypassing any locally cached content). | |
84 bool reload; | |
85 }; | |
86 | |
87 // Parameters structure for ViewHostMsg_FrameNavigate, which has too many data | |
88 // parameters to be reasonably put in a predefined IPC message. | |
89 struct ViewHostMsg_FrameNavigate_Params { | |
90 // Page ID of this navigation. The renderer creates a new unique page ID | |
91 // anytime a new session history entry is created. This means you'll get new | |
92 // page IDs for user actions, and the old page IDs will be reloaded when | |
93 // iframes are loaded automatically. | |
94 int32 page_id; | |
95 | |
96 // URL of the page being loaded. | |
97 GURL url; | |
98 | |
99 // URL of the referrer of this load. WebKit generates this based on the | |
100 // source of the event that caused the load. | |
101 GURL referrer; | |
102 | |
103 // The type of transition. | |
104 PageTransition::Type transition; | |
105 | |
106 // Lists the redirects that occurred on the way to the current page. This | |
107 // vector has the same format as reported by the WebDataSource in the glue, | |
108 // with the current page being the last one in the list (so even when | |
109 // there's no redirect, there will be one entry in the list. | |
110 std::vector<GURL> redirects; | |
111 | |
112 // Set to false if we want to update the session history but not update | |
113 // the browser history. E.g., on unreachable urls. | |
114 bool should_update_history; | |
115 | |
116 // See SearchableFormData for a description of these. | |
117 GURL searchable_form_url; | |
118 std::wstring searchable_form_element_name; | |
119 std::string searchable_form_encoding; | |
120 | |
121 // See password_form.h. | |
122 PasswordForm password_form; | |
123 | |
124 // Information regarding the security of the connection (empty if the | |
125 // connection was not secure). | |
126 std::string security_info; | |
127 | |
128 // The gesture that initiated this navigation. | |
129 NavigationGesture gesture; | |
130 | |
131 // Contents MIME type of main frame. | |
132 std::string contents_mime_type; | |
133 | |
134 // True if this was a post request. | |
135 bool is_post; | |
136 | |
137 // Whether the content of the frame was replaced with some alternate content | |
138 // (this can happen if the resource was insecure). | |
139 bool is_content_filtered; | |
140 | |
141 // The status code of the HTTP request. | |
142 int http_status_code; | |
143 }; | |
144 | |
145 // Values that may be OR'd together to form the 'flags' parameter of a | |
146 // ViewHostMsg_PaintRect message. | |
147 struct ViewHostMsg_PaintRect_Flags { | |
148 enum { | |
149 IS_RESIZE_ACK = 1 << 0, | |
150 IS_RESTORE_ACK = 1 << 1, | |
151 IS_REPAINT_ACK = 1 << 2, | |
152 }; | |
153 static bool is_resize_ack(int flags) { | |
154 return (flags & IS_RESIZE_ACK) != 0; | |
155 } | |
156 static bool is_restore_ack(int flags) { | |
157 return (flags & IS_RESTORE_ACK) != 0; | |
158 } | |
159 | |
160 static bool is_repaint_ack(int flags) { | |
161 return (flags & IS_REPAINT_ACK) != 0; | |
162 } | |
163 }; | |
164 | |
165 struct ViewHostMsg_PaintRect_Params { | |
166 // The bitmap to be painted into the rect given by bitmap_rect. | |
167 TransportDIB::Id bitmap; | |
168 | |
169 // The position and size of the bitmap. | |
170 gfx::Rect bitmap_rect; | |
171 | |
172 // The size of the RenderView when this message was generated. This is | |
173 // included so the host knows how large the view is from the perspective of | |
174 // the renderer process. This is necessary in case a resize operation is in | |
175 // progress. | |
176 gfx::Size view_size; | |
177 | |
178 // New window locations for plugin child windows. | |
179 std::vector<WebPluginGeometry> plugin_window_moves; | |
180 | |
181 // The following describes the various bits that may be set in flags: | |
182 // | |
183 // ViewHostMsg_PaintRect_Flags::IS_RESIZE_ACK | |
184 // Indicates that this is a response to a ViewMsg_Resize message. | |
185 // | |
186 // ViewHostMsg_PaintRect_Flags::IS_RESTORE_ACK | |
187 // Indicates that this is a response to a ViewMsg_WasRestored message. | |
188 // | |
189 // If flags is zero, then this message corresponds to an unsoliticed paint | |
190 // request by the render view. Both of the above bits may be set in flags, | |
191 // which would indicate that this paint message is an ACK for multiple | |
192 // request messages. | |
193 int flags; | |
194 }; | |
195 | |
196 // Parameters structure for ViewHostMsg_ScrollRect, which has too many data | |
197 // parameters to be reasonably put in a predefined IPC message. | |
198 struct ViewHostMsg_ScrollRect_Params { | |
199 // The bitmap to be painted into the rect exposed by scrolling. | |
200 TransportDIB::Id bitmap; | |
201 | |
202 // The position and size of the bitmap. | |
203 gfx::Rect bitmap_rect; | |
204 | |
205 // The scroll offset. Only one of these can be non-zero. | |
206 int dx; | |
207 int dy; | |
208 | |
209 // The rectangular region to scroll. | |
210 gfx::Rect clip_rect; | |
211 | |
212 // The size of the RenderView when this message was generated. | |
213 gfx::Size view_size; | |
214 | |
215 // New window locations for plugin child windows. | |
216 std::vector<WebPluginGeometry> plugin_window_moves; | |
217 }; | |
218 | |
219 // Parameters structure for ViewMsg_UploadFile. | |
220 struct ViewMsg_UploadFile_Params { | |
221 // See WebContents::StartFileUpload for a description of these fields. | |
222 std::wstring file_path; | |
223 std::wstring form; | |
224 std::wstring file; | |
225 std::wstring submit; | |
226 std::wstring other_values; | |
227 }; | |
228 | |
229 // Parameters for a resource request. | |
230 struct ViewHostMsg_Resource_Request { | |
231 // The request method: GET, POST, etc. | |
232 std::string method; | |
233 | |
234 // The requested URL. | |
235 GURL url; | |
236 | |
237 // The URL of the document in the top-level window, which may be checked by | |
238 // the third-party cookie blocking policy. Leaving it empty may lead to | |
239 // undesired cookie blocking. Third-party cookie blocking can be bypassed by | |
240 // setting policy_url = url, but this should ideally only be done if there | |
241 // really is no way to determine the correct value. | |
242 GURL policy_url; | |
243 | |
244 // The referrer to use (may be empty). | |
245 GURL referrer; | |
246 | |
247 // The origin of the frame that is associated with this request. This is used | |
248 // to update our mixed content state. | |
249 std::string frame_origin; | |
250 | |
251 // The origin of the main frame (top-level frame) that is associated with this | |
252 // request. This is used to update our mixed content state. | |
253 std::string main_frame_origin; | |
254 | |
255 // Additional HTTP request headers. | |
256 std::string headers; | |
257 | |
258 // The default MIME type to use if the response lacks a Content-Type header. | |
259 // Use the empty string here if you don't want special MIME type handling. | |
260 std::string default_mime_type; | |
261 | |
262 // URLRequest load flags (0 by default). | |
263 int load_flags; | |
264 | |
265 // Process ID of process that originated this request. | |
266 int origin_pid; | |
267 | |
268 // What this resource load is for (main frame, sub-frame, sub-resource, | |
269 // object). | |
270 ResourceType::Type resource_type; | |
271 | |
272 // Used by plugin->browser requests to get the correct URLRequestContext. | |
273 uint32 request_context; | |
274 | |
275 // Optional upload data (may be null). | |
276 scoped_refptr<net::UploadData> upload_data; | |
277 }; | |
278 | |
279 // Parameters for a render request. | |
280 struct ViewMsg_Print_Params { | |
281 // In pixels according to dpi_x and dpi_y. | |
282 gfx::Size printable_size; | |
283 | |
284 // Specifies dots per inch. | |
285 double dpi; | |
286 | |
287 // Minimum shrink factor. See PrintSettings::min_shrink for more information. | |
288 double min_shrink; | |
289 | |
290 // Maximum shrink factor. See PrintSettings::max_shrink for more information. | |
291 double max_shrink; | |
292 | |
293 // Desired apparent dpi on paper. | |
294 int desired_dpi; | |
295 | |
296 // Cookie for the document to ensure correctness. | |
297 int document_cookie; | |
298 | |
299 // Warning: do not compare document_cookie. | |
300 bool Equals(const ViewMsg_Print_Params& rhs) const { | |
301 return printable_size == rhs.printable_size && | |
302 dpi == rhs.dpi && | |
303 min_shrink == rhs.min_shrink && | |
304 max_shrink == rhs.max_shrink && | |
305 desired_dpi == rhs.desired_dpi; | |
306 } | |
307 }; | |
308 | |
309 struct ViewMsg_PrintPage_Params { | |
310 // Parameters to render the page as a printed page. It must always be the same | |
311 // value for all the document. | |
312 ViewMsg_Print_Params params; | |
313 | |
314 // The page number is the indicator of the square that should be rendered | |
315 // according to the layout specified in ViewMsg_Print_Params. | |
316 int page_number; | |
317 }; | |
318 | |
319 struct ViewMsg_PrintPages_Params { | |
320 // Parameters to render the page as a printed page. It must always be the same | |
321 // value for all the document. | |
322 ViewMsg_Print_Params params; | |
323 | |
324 // If empty, this means a request to render all the printed pages. | |
325 std::vector<int> pages; | |
326 }; | |
327 | |
328 // Parameters to describe a rendered page. | |
329 struct ViewHostMsg_DidPrintPage_Params { | |
330 // A shared memory handle to the EMF data. This data can be quite large so a | |
331 // memory map needs to be used. | |
332 base::SharedMemoryHandle emf_data_handle; | |
333 | |
334 // Size of the EMF data. | |
335 unsigned data_size; | |
336 | |
337 // Cookie for the document to ensure correctness. | |
338 int document_cookie; | |
339 | |
340 // Page number. | |
341 int page_number; | |
342 | |
343 // Shrink factor used to render this page. | |
344 double actual_shrink; | |
345 }; | |
346 | |
347 // The first parameter for the ViewHostMsg_ImeUpdateStatus message. | |
348 enum ViewHostMsg_ImeControl { | |
349 IME_DISABLE = 0, | |
350 IME_MOVE_WINDOWS, | |
351 IME_COMPLETE_COMPOSITION, | |
352 }; | |
353 | |
354 // Parameters for creating an audio output stream. | |
355 struct ViewHostMsg_Audio_CreateStream { | |
356 // Format request for the stream. | |
357 AudioManager::Format format; | |
358 | |
359 // Number of channels. | |
360 int channels; | |
361 | |
362 // Sampling rate (frequency) of the output stream. | |
363 int sample_rate; | |
364 | |
365 // Number of bits per sample; | |
366 int bits_per_sample; | |
367 | |
368 // Number of bytes per packet. | |
369 size_t packet_size; | |
370 }; | |
371 | 17 |
372 namespace IPC { | 18 namespace IPC { |
373 | 19 |
374 template <> | 20 template <> |
| 21 struct ParamTraits<WebKit::WebRect> { |
| 22 typedef WebKit::WebRect param_type; |
| 23 static void Write(Message* m, const param_type& p) { |
| 24 WriteParam(m, p.x); |
| 25 WriteParam(m, p.y); |
| 26 WriteParam(m, p.width); |
| 27 WriteParam(m, p.height); |
| 28 } |
| 29 static bool Read(const Message* m, void** iter, param_type* p) { |
| 30 return |
| 31 ReadParam(m, iter, &p->x) && |
| 32 ReadParam(m, iter, &p->y) && |
| 33 ReadParam(m, iter, &p->width) && |
| 34 ReadParam(m, iter, &p->height); |
| 35 } |
| 36 static void Log(const param_type& p, std::wstring* l) { |
| 37 l->append(L"("); |
| 38 LogParam(p.x, l); |
| 39 l->append(L", "); |
| 40 LogParam(p.y, l); |
| 41 l->append(L", "); |
| 42 LogParam(p.width, l); |
| 43 l->append(L", "); |
| 44 LogParam(p.height, l); |
| 45 l->append(L")"); |
| 46 } |
| 47 }; |
| 48 |
| 49 template <> |
| 50 struct ParamTraits<WebKit::WebScreenInfo> { |
| 51 typedef WebKit::WebScreenInfo param_type; |
| 52 static void Write(Message* m, const param_type& p) { |
| 53 WriteParam(m, p.depth); |
| 54 WriteParam(m, p.depthPerComponent); |
| 55 WriteParam(m, p.isMonochrome); |
| 56 WriteParam(m, p.rect); |
| 57 WriteParam(m, p.availableRect); |
| 58 } |
| 59 static bool Read(const Message* m, void** iter, param_type* p) { |
| 60 return |
| 61 ReadParam(m, iter, &p->depth) && |
| 62 ReadParam(m, iter, &p->depthPerComponent) && |
| 63 ReadParam(m, iter, &p->isMonochrome) && |
| 64 ReadParam(m, iter, &p->rect) && |
| 65 ReadParam(m, iter, &p->availableRect); |
| 66 } |
| 67 static void Log(const param_type& p, std::wstring* l) { |
| 68 l->append(L"("); |
| 69 LogParam(p.depth, l); |
| 70 l->append(L", "); |
| 71 LogParam(p.depthPerComponent, l); |
| 72 l->append(L", "); |
| 73 LogParam(p.isMonochrome, l); |
| 74 l->append(L", "); |
| 75 LogParam(p.rect, l); |
| 76 l->append(L", "); |
| 77 LogParam(p.availableRect, l); |
| 78 l->append(L")"); |
| 79 } |
| 80 }; |
| 81 |
| 82 template <> |
375 struct ParamTraits<WebKit::WebString> { | 83 struct ParamTraits<WebKit::WebString> { |
376 typedef WebKit::WebString param_type; | 84 typedef WebKit::WebString param_type; |
377 static void Write(Message* m, const param_type& p) { | 85 static void Write(Message* m, const param_type& p) { |
378 m->WriteData(reinterpret_cast<const char*>(p.data()), | 86 m->WriteData(reinterpret_cast<const char*>(p.data()), |
379 static_cast<int>(p.length() * sizeof(WebKit::WebUChar))); | 87 static_cast<int>(p.length() * sizeof(WebKit::WebUChar))); |
380 } | 88 } |
381 static bool Read(const Message* m, void** iter, param_type* p) { | 89 static bool Read(const Message* m, void** iter, param_type* p) { |
382 const char* data; | 90 const char* data; |
383 int data_len; | 91 int data_len; |
384 if (!m->ReadData(iter, &data, &data_len)) | 92 if (!m->ReadData(iter, &data, &data_len)) |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 static void Log(const param_type& p, std::wstring* l) { | 133 static void Log(const param_type& p, std::wstring* l) { |
426 l->append(L"("); | 134 l->append(L"("); |
427 LogParam(p.level, l); | 135 LogParam(p.level, l); |
428 l->append(L", "); | 136 l->append(L", "); |
429 LogParam(p.text, l); | 137 LogParam(p.text, l); |
430 l->append(L")"); | 138 l->append(L")"); |
431 } | 139 } |
432 }; | 140 }; |
433 | 141 |
434 template <> | 142 template <> |
435 struct ParamTraits<ResourceType::Type> { | 143 struct ParamTraits<WebKit::WebFindInPageRequest> { |
436 typedef ResourceType::Type param_type; | 144 typedef WebKit::WebFindInPageRequest param_type; |
437 static void Write(Message* m, const param_type& p) { | 145 static void Write(Message* m, const param_type& p) { |
438 m->WriteInt(p); | 146 WriteParam(m, p.identifier); |
| 147 WriteParam(m, p.text); |
| 148 WriteParam(m, p.forward); |
| 149 WriteParam(m, p.matchCase); |
| 150 WriteParam(m, p.findNext); |
439 } | 151 } |
440 static bool Read(const Message* m, void** iter, param_type* p) { | 152 static bool Read(const Message* m, void** iter, param_type* p) { |
441 int type; | 153 return |
442 if (!m->ReadInt(iter, &type) || !ResourceType::ValidType(type)) | 154 ReadParam(m, iter, &p->identifier) && |
443 return false; | 155 ReadParam(m, iter, &p->text) && |
444 *p = ResourceType::FromInt(type); | 156 ReadParam(m, iter, &p->forward) && |
445 return true; | 157 ReadParam(m, iter, &p->matchCase) && |
| 158 ReadParam(m, iter, &p->findNext); |
446 } | 159 } |
447 static void Log(const param_type& p, std::wstring* l) { | 160 static void Log(const param_type& p, std::wstring* l) { |
448 std::wstring type; | 161 l->append(L"<FindInPageRequest>"); |
449 switch (p) { | |
450 case ResourceType::MAIN_FRAME: | |
451 type = L"MAIN_FRAME"; | |
452 break; | |
453 case ResourceType::SUB_FRAME: | |
454 type = L"SUB_FRAME"; | |
455 break; | |
456 case ResourceType::SUB_RESOURCE: | |
457 type = L"SUB_RESOURCE"; | |
458 break; | |
459 case ResourceType::OBJECT: | |
460 type = L"OBJECT"; | |
461 break; | |
462 case ResourceType::MEDIA: | |
463 type = L"MEDIA"; | |
464 break; | |
465 default: | |
466 type = L"UNKNOWN"; | |
467 break; | |
468 } | |
469 | |
470 LogParam(type, l); | |
471 } | |
472 }; | |
473 | |
474 template <> | |
475 struct ParamTraits<FilterPolicy::Type> { | |
476 typedef FilterPolicy::Type param_type; | |
477 static void Write(Message* m, const param_type& p) { | |
478 m->WriteInt(p); | |
479 } | |
480 static bool Read(const Message* m, void** iter, param_type* p) { | |
481 int type; | |
482 if (!m->ReadInt(iter, &type) || !FilterPolicy::ValidType(type)) | |
483 return false; | |
484 *p = FilterPolicy::FromInt(type); | |
485 return true; | |
486 } | |
487 static void Log(const param_type& p, std::wstring* l) { | |
488 std::wstring type; | |
489 switch (p) { | |
490 case FilterPolicy::DONT_FILTER: | |
491 type = L"DONT_FILTER"; | |
492 break; | |
493 case FilterPolicy::FILTER_ALL: | |
494 type = L"FILTER_ALL"; | |
495 break; | |
496 case FilterPolicy::FILTER_ALL_EXCEPT_IMAGES: | |
497 type = L"FILTER_ALL_EXCEPT_IMAGES"; | |
498 break; | |
499 default: | |
500 type = L"UNKNOWN"; | |
501 break; | |
502 } | |
503 | |
504 LogParam(type, l); | |
505 } | |
506 }; | |
507 | |
508 template <> | |
509 struct ParamTraits<ContextNode> { | |
510 typedef ContextNode param_type; | |
511 static void Write(Message* m, const param_type& p) { | |
512 m->WriteInt(p.type); | |
513 } | |
514 static bool Read(const Message* m, void** iter, param_type* p) { | |
515 int type; | |
516 if (!m->ReadInt(iter, &type)) | |
517 return false; | |
518 *p = ContextNode(type); | |
519 return true; | |
520 } | |
521 static void Log(const param_type& p, std::wstring* l) { | |
522 std::wstring event = L""; | |
523 | |
524 if (!p.type) { | |
525 event.append(L"NONE"); | |
526 } else { | |
527 event.append(L"("); | |
528 if (p.type & ContextNode::PAGE) | |
529 event.append(L"PAGE|"); | |
530 if (p.type & ContextNode::FRAME) | |
531 event.append(L"FRAME|"); | |
532 if (p.type & ContextNode::LINK) | |
533 event.append(L"LINK|"); | |
534 if (p.type & ContextNode::IMAGE) | |
535 event.append(L"IMAGE|"); | |
536 if (p.type & ContextNode::SELECTION) | |
537 event.append(L"SELECTION|"); | |
538 if (p.type & ContextNode::EDITABLE) | |
539 event.append(L"EDITABLE|"); | |
540 if (p.type & ContextNode::MISSPELLED_WORD) | |
541 event.append(L"MISSPELLED_WORD|"); | |
542 event.append(L")"); | |
543 } | |
544 | |
545 LogParam(event, l); | |
546 } | 162 } |
547 }; | 163 }; |
548 | 164 |
549 template <> | 165 template <> |
550 struct ParamTraits<WebKit::WebInputEvent::Type> { | 166 struct ParamTraits<WebKit::WebInputEvent::Type> { |
551 typedef WebKit::WebInputEvent::Type param_type; | 167 typedef WebKit::WebInputEvent::Type param_type; |
552 static void Write(Message* m, const param_type& p) { | 168 static void Write(Message* m, const param_type& p) { |
553 m->WriteInt(p); | 169 m->WriteInt(p); |
554 } | 170 } |
555 static bool Read(const Message* m, void** iter, param_type* p) { | 171 static bool Read(const Message* m, void** iter, param_type* p) { |
(...skipping 30 matching lines...) Expand all Loading... |
586 case WebKit::WebInputEvent::KeyDown: | 202 case WebKit::WebInputEvent::KeyDown: |
587 type = L"KeyDown"; | 203 type = L"KeyDown"; |
588 break; | 204 break; |
589 case WebKit::WebInputEvent::KeyUp: | 205 case WebKit::WebInputEvent::KeyUp: |
590 type = L"KeyUp"; | 206 type = L"KeyUp"; |
591 break; | 207 break; |
592 default: | 208 default: |
593 type = L"None"; | 209 type = L"None"; |
594 break; | 210 break; |
595 } | 211 } |
596 | |
597 LogParam(type, l); | 212 LogParam(type, l); |
598 } | 213 } |
599 }; | 214 }; |
600 | 215 |
601 // Traits for ViewHostMsg_UpdateFeedList_Params structure to pack/unpack. | |
602 template <> | |
603 struct ParamTraits<ViewHostMsg_UpdateFeedList_Params> { | |
604 typedef ViewHostMsg_UpdateFeedList_Params param_type; | |
605 static void Write(Message* msg, const param_type& param) { | |
606 WriteParam(msg, param.page_id); | |
607 WriteParam(msg, param.feedlist->list().size()); | |
608 for (std::vector<FeedItem>::const_iterator iter = | |
609 param.feedlist->list().begin(); | |
610 iter != param.feedlist->list().end(); iter++) { | |
611 WriteParam(msg, iter->title); | |
612 WriteParam(msg, iter->type); | |
613 WriteParam(msg, iter->url); | |
614 } | |
615 } | |
616 static bool Read(const Message* msg, void** iter, param_type* param) { | |
617 param->feedlist = new FeedList(); | |
618 if (!ReadParam(msg, iter, ¶m->page_id)) | |
619 return false; | |
620 | |
621 size_t arraysize = 0; | |
622 if (!ReadParam(msg, iter, &arraysize)) | |
623 return false; | |
624 | |
625 if (arraysize > FeedList::kMaxFeeds) { | |
626 NOTREACHED() << L"Too many feeds sent by the renderer"; | |
627 return false; | |
628 } | |
629 | |
630 bool ret = true; | |
631 for (size_t i = 0; i < arraysize; i++) { | |
632 FeedItem feeditem; | |
633 ret = ReadParam(msg, iter, &feeditem.title) && | |
634 ReadParam(msg, iter, &feeditem.type) && | |
635 ReadParam(msg, iter, &feeditem.url); | |
636 if (!ret) | |
637 return ret; | |
638 param->feedlist->Add(feeditem); | |
639 } | |
640 | |
641 return ret; | |
642 } | |
643 static void Log(const param_type& param, std::wstring* log) { | |
644 log->append(L"("); | |
645 LogParam(param.page_id, log); | |
646 log->append(L", {"); | |
647 for (std::vector<FeedItem>::const_iterator iter = | |
648 param.feedlist->list().begin(); | |
649 iter != param.feedlist->list().end(); iter++) { | |
650 log->append(L"["); | |
651 LogParam(iter->title, log); | |
652 log->append(L", "); | |
653 LogParam(iter->type, log); | |
654 log->append(L", "); | |
655 LogParam(iter->url, log); | |
656 log->append(L"]"); | |
657 } | |
658 log->append(L"})"); | |
659 } | |
660 }; | |
661 | |
662 template <> | |
663 struct ParamTraits<webkit_glue::WebAccessibility::InParams> { | |
664 typedef webkit_glue::WebAccessibility::InParams param_type; | |
665 static void Write(Message* m, const param_type& p) { | |
666 WriteParam(m, p.object_id); | |
667 WriteParam(m, p.function_id); | |
668 WriteParam(m, p.child_id); | |
669 WriteParam(m, p.input_long1); | |
670 WriteParam(m, p.input_long2); | |
671 } | |
672 static bool Read(const Message* m, void** iter, param_type* p) { | |
673 return | |
674 ReadParam(m, iter, &p->object_id) && | |
675 ReadParam(m, iter, &p->function_id) && | |
676 ReadParam(m, iter, &p->child_id) && | |
677 ReadParam(m, iter, &p->input_long1) && | |
678 ReadParam(m, iter, &p->input_long2); | |
679 } | |
680 static void Log(const param_type& p, std::wstring* l) { | |
681 l->append(L"("); | |
682 LogParam(p.object_id, l); | |
683 l->append(L", "); | |
684 LogParam(p.function_id, l); | |
685 l->append(L", "); | |
686 LogParam(p.child_id, l); | |
687 l->append(L", "); | |
688 LogParam(p.input_long1, l); | |
689 l->append(L", "); | |
690 LogParam(p.input_long2, l); | |
691 l->append(L")"); | |
692 } | |
693 }; | |
694 | |
695 template <> | |
696 struct ParamTraits<webkit_glue::WebAccessibility::OutParams> { | |
697 typedef webkit_glue::WebAccessibility::OutParams param_type; | |
698 static void Write(Message* m, const param_type& p) { | |
699 WriteParam(m, p.object_id); | |
700 WriteParam(m, p.output_long1); | |
701 WriteParam(m, p.output_long2); | |
702 WriteParam(m, p.output_long3); | |
703 WriteParam(m, p.output_long4); | |
704 WriteParam(m, p.output_string); | |
705 WriteParam(m, p.return_code); | |
706 } | |
707 static bool Read(const Message* m, void** iter, param_type* p) { | |
708 return | |
709 ReadParam(m, iter, &p->object_id) && | |
710 ReadParam(m, iter, &p->output_long1) && | |
711 ReadParam(m, iter, &p->output_long2) && | |
712 ReadParam(m, iter, &p->output_long3) && | |
713 ReadParam(m, iter, &p->output_long4) && | |
714 ReadParam(m, iter, &p->output_string) && | |
715 ReadParam(m, iter, &p->return_code); | |
716 } | |
717 static void Log(const param_type& p, std::wstring* l) { | |
718 l->append(L"("); | |
719 LogParam(p.object_id, l); | |
720 l->append(L", "); | |
721 LogParam(p.output_long1, l); | |
722 l->append(L", "); | |
723 LogParam(p.output_long2, l); | |
724 l->append(L", "); | |
725 LogParam(p.output_long3, l); | |
726 l->append(L", "); | |
727 LogParam(p.output_long4, l); | |
728 l->append(L", "); | |
729 LogParam(p.output_string, l); | |
730 l->append(L", "); | |
731 LogParam(p.return_code, l); | |
732 l->append(L")"); | |
733 } | |
734 }; | |
735 | |
736 template <> | |
737 struct ParamTraits<ViewHostMsg_ImeControl> { | |
738 typedef ViewHostMsg_ImeControl param_type; | |
739 static void Write(Message* m, const param_type& p) { | |
740 m->WriteInt(p); | |
741 } | |
742 static bool Read(const Message* m, void** iter, param_type* p) { | |
743 int type; | |
744 if (!m->ReadInt(iter, &type)) | |
745 return false; | |
746 *p = static_cast<ViewHostMsg_ImeControl>(type); | |
747 return true; | |
748 } | |
749 static void Log(const param_type& p, std::wstring* l) { | |
750 std::wstring control; | |
751 switch (p) { | |
752 case IME_DISABLE: | |
753 control = L"IME_DISABLE"; | |
754 break; | |
755 case IME_MOVE_WINDOWS: | |
756 control = L"IME_MOVE_WINDOWS"; | |
757 break; | |
758 case IME_COMPLETE_COMPOSITION: | |
759 control = L"IME_COMPLETE_COMPOSITION"; | |
760 break; | |
761 default: | |
762 control = L"UNKNOWN"; | |
763 break; | |
764 } | |
765 | |
766 LogParam(control, l); | |
767 } | |
768 }; | |
769 | |
770 // Traits for ViewMsg_Navigate_Params structure to pack/unpack. | |
771 template <> | |
772 struct ParamTraits<ViewMsg_Navigate_Params> { | |
773 typedef ViewMsg_Navigate_Params param_type; | |
774 static void Write(Message* m, const param_type& p) { | |
775 WriteParam(m, p.page_id); | |
776 WriteParam(m, p.url); | |
777 WriteParam(m, p.referrer); | |
778 WriteParam(m, p.transition); | |
779 WriteParam(m, p.state); | |
780 WriteParam(m, p.reload); | |
781 } | |
782 static bool Read(const Message* m, void** iter, param_type* p) { | |
783 return | |
784 ReadParam(m, iter, &p->page_id) && | |
785 ReadParam(m, iter, &p->url) && | |
786 ReadParam(m, iter, &p->referrer) && | |
787 ReadParam(m, iter, &p->transition) && | |
788 ReadParam(m, iter, &p->state) && | |
789 ReadParam(m, iter, &p->reload); | |
790 } | |
791 static void Log(const param_type& p, std::wstring* l) { | |
792 l->append(L"("); | |
793 LogParam(p.page_id, l); | |
794 l->append(L", "); | |
795 LogParam(p.url, l); | |
796 l->append(L", "); | |
797 LogParam(p.transition, l); | |
798 l->append(L", "); | |
799 LogParam(p.state, l); | |
800 l->append(L", "); | |
801 LogParam(p.reload, l); | |
802 l->append(L")"); | |
803 } | |
804 }; | |
805 | |
806 // Traits for PasswordForm_Params structure to pack/unpack. | |
807 template <> | |
808 struct ParamTraits<PasswordForm> { | |
809 typedef PasswordForm param_type; | |
810 static void Write(Message* m, const param_type& p) { | |
811 WriteParam(m, p.signon_realm); | |
812 WriteParam(m, p.origin); | |
813 WriteParam(m, p.action); | |
814 WriteParam(m, p.submit_element); | |
815 WriteParam(m, p.username_element); | |
816 WriteParam(m, p.username_value); | |
817 WriteParam(m, p.password_element); | |
818 WriteParam(m, p.password_value); | |
819 WriteParam(m, p.old_password_element); | |
820 WriteParam(m, p.old_password_value); | |
821 WriteParam(m, p.ssl_valid); | |
822 WriteParam(m, p.preferred); | |
823 WriteParam(m, p.blacklisted_by_user); | |
824 } | |
825 static bool Read(const Message* m, void** iter, param_type* p) { | |
826 return | |
827 ReadParam(m, iter, &p->signon_realm) && | |
828 ReadParam(m, iter, &p->origin) && | |
829 ReadParam(m, iter, &p->action) && | |
830 ReadParam(m, iter, &p->submit_element) && | |
831 ReadParam(m, iter, &p->username_element) && | |
832 ReadParam(m, iter, &p->username_value) && | |
833 ReadParam(m, iter, &p->password_element) && | |
834 ReadParam(m, iter, &p->password_value) && | |
835 ReadParam(m, iter, &p->old_password_element) && | |
836 ReadParam(m, iter, &p->old_password_value) && | |
837 ReadParam(m, iter, &p->ssl_valid) && | |
838 ReadParam(m, iter, &p->preferred) && | |
839 ReadParam(m, iter, &p->blacklisted_by_user); | |
840 } | |
841 static void Log(const param_type& p, std::wstring* l) { | |
842 l->append(L"<PasswordForm>"); | |
843 } | |
844 }; | |
845 | |
846 // Traits for AutofillForm_Params structure to pack/unpack. | |
847 template <> | |
848 struct ParamTraits<AutofillForm> { | |
849 typedef AutofillForm param_type; | |
850 static void Write(Message* m, const param_type& p) { | |
851 WriteParam(m, p.elements.size()); | |
852 for (std::vector<AutofillForm::Element>::const_iterator itr = | |
853 p.elements.begin(); | |
854 itr != p.elements.end(); | |
855 itr++) { | |
856 WriteParam(m, itr->name); | |
857 WriteParam(m, itr->value); | |
858 } | |
859 } | |
860 static bool Read(const Message* m, void** iter, param_type* p) { | |
861 bool result = true; | |
862 size_t elements_size = 0; | |
863 result = result && ReadParam(m, iter, &elements_size); | |
864 p->elements.resize(elements_size); | |
865 for (size_t i = 0; i < elements_size; i++) { | |
866 result = result && ReadParam(m, iter, &(p->elements[i].name)); | |
867 result = result && ReadParam(m, iter, &(p->elements[i].value)); | |
868 } | |
869 return result; | |
870 } | |
871 static void Log(const param_type& p, std::wstring* l) { | |
872 l->append(L"<AutofillForm>"); | |
873 } | |
874 }; | |
875 | |
876 // Traits for ViewHostMsg_FrameNavigate_Params structure to pack/unpack. | |
877 template <> | |
878 struct ParamTraits<ViewHostMsg_FrameNavigate_Params> { | |
879 typedef ViewHostMsg_FrameNavigate_Params param_type; | |
880 static void Write(Message* m, const param_type& p) { | |
881 WriteParam(m, p.page_id); | |
882 WriteParam(m, p.url); | |
883 WriteParam(m, p.referrer); | |
884 WriteParam(m, p.transition); | |
885 WriteParam(m, p.redirects); | |
886 WriteParam(m, p.should_update_history); | |
887 WriteParam(m, p.searchable_form_url); | |
888 WriteParam(m, p.searchable_form_element_name); | |
889 WriteParam(m, p.searchable_form_encoding); | |
890 WriteParam(m, p.password_form); | |
891 WriteParam(m, p.security_info); | |
892 WriteParam(m, p.gesture); | |
893 WriteParam(m, p.contents_mime_type); | |
894 WriteParam(m, p.is_post); | |
895 WriteParam(m, p.is_content_filtered); | |
896 WriteParam(m, p.http_status_code); | |
897 } | |
898 static bool Read(const Message* m, void** iter, param_type* p) { | |
899 return | |
900 ReadParam(m, iter, &p->page_id) && | |
901 ReadParam(m, iter, &p->url) && | |
902 ReadParam(m, iter, &p->referrer) && | |
903 ReadParam(m, iter, &p->transition) && | |
904 ReadParam(m, iter, &p->redirects) && | |
905 ReadParam(m, iter, &p->should_update_history) && | |
906 ReadParam(m, iter, &p->searchable_form_url) && | |
907 ReadParam(m, iter, &p->searchable_form_element_name) && | |
908 ReadParam(m, iter, &p->searchable_form_encoding) && | |
909 ReadParam(m, iter, &p->password_form) && | |
910 ReadParam(m, iter, &p->security_info) && | |
911 ReadParam(m, iter, &p->gesture) && | |
912 ReadParam(m, iter, &p->contents_mime_type) && | |
913 ReadParam(m, iter, &p->is_post) && | |
914 ReadParam(m, iter, &p->is_content_filtered) && | |
915 ReadParam(m, iter, &p->http_status_code); | |
916 } | |
917 static void Log(const param_type& p, std::wstring* l) { | |
918 l->append(L"("); | |
919 LogParam(p.page_id, l); | |
920 l->append(L", "); | |
921 LogParam(p.url, l); | |
922 l->append(L", "); | |
923 LogParam(p.referrer, l); | |
924 l->append(L", "); | |
925 LogParam(p.transition, l); | |
926 l->append(L", "); | |
927 LogParam(p.redirects, l); | |
928 l->append(L", "); | |
929 LogParam(p.should_update_history, l); | |
930 l->append(L", "); | |
931 LogParam(p.searchable_form_url, l); | |
932 l->append(L", "); | |
933 LogParam(p.searchable_form_element_name, l); | |
934 l->append(L", "); | |
935 LogParam(p.searchable_form_encoding, l); | |
936 l->append(L", "); | |
937 LogParam(p.password_form, l); | |
938 l->append(L", "); | |
939 LogParam(p.security_info, l); | |
940 l->append(L", "); | |
941 LogParam(p.gesture, l); | |
942 l->append(L", "); | |
943 LogParam(p.contents_mime_type, l); | |
944 l->append(L", "); | |
945 LogParam(p.is_post, l); | |
946 l->append(L", "); | |
947 LogParam(p.is_content_filtered, l); | |
948 l->append(L", "); | |
949 LogParam(p.http_status_code, l); | |
950 l->append(L")"); | |
951 } | |
952 }; | |
953 | |
954 template <> | |
955 struct ParamTraits<ContextMenuParams> { | |
956 typedef ContextMenuParams param_type; | |
957 static void Write(Message* m, const param_type& p) { | |
958 WriteParam(m, p.node); | |
959 WriteParam(m, p.x); | |
960 WriteParam(m, p.y); | |
961 WriteParam(m, p.link_url); | |
962 WriteParam(m, p.image_url); | |
963 WriteParam(m, p.page_url); | |
964 WriteParam(m, p.frame_url); | |
965 WriteParam(m, p.selection_text); | |
966 WriteParam(m, p.misspelled_word); | |
967 WriteParam(m, p.dictionary_suggestions); | |
968 WriteParam(m, p.spellcheck_enabled); | |
969 WriteParam(m, p.edit_flags); | |
970 WriteParam(m, p.security_info); | |
971 } | |
972 static bool Read(const Message* m, void** iter, param_type* p) { | |
973 return | |
974 ReadParam(m, iter, &p->node) && | |
975 ReadParam(m, iter, &p->x) && | |
976 ReadParam(m, iter, &p->y) && | |
977 ReadParam(m, iter, &p->link_url) && | |
978 ReadParam(m, iter, &p->image_url) && | |
979 ReadParam(m, iter, &p->page_url) && | |
980 ReadParam(m, iter, &p->frame_url) && | |
981 ReadParam(m, iter, &p->selection_text) && | |
982 ReadParam(m, iter, &p->misspelled_word) && | |
983 ReadParam(m, iter, &p->dictionary_suggestions) && | |
984 ReadParam(m, iter, &p->spellcheck_enabled) && | |
985 ReadParam(m, iter, &p->edit_flags) && | |
986 ReadParam(m, iter, &p->security_info); | |
987 } | |
988 static void Log(const param_type& p, std::wstring* l) { | |
989 l->append(L"<ContextMenuParams>"); | |
990 } | |
991 }; | |
992 | |
993 // Traits for ViewHostMsg_PaintRect_Params structure to pack/unpack. | |
994 template <> | |
995 struct ParamTraits<ViewHostMsg_PaintRect_Params> { | |
996 typedef ViewHostMsg_PaintRect_Params param_type; | |
997 static void Write(Message* m, const param_type& p) { | |
998 WriteParam(m, p.bitmap); | |
999 WriteParam(m, p.bitmap_rect); | |
1000 WriteParam(m, p.view_size); | |
1001 WriteParam(m, p.plugin_window_moves); | |
1002 WriteParam(m, p.flags); | |
1003 } | |
1004 static bool Read(const Message* m, void** iter, param_type* p) { | |
1005 return | |
1006 ReadParam(m, iter, &p->bitmap) && | |
1007 ReadParam(m, iter, &p->bitmap_rect) && | |
1008 ReadParam(m, iter, &p->view_size) && | |
1009 ReadParam(m, iter, &p->plugin_window_moves) && | |
1010 ReadParam(m, iter, &p->flags); | |
1011 } | |
1012 static void Log(const param_type& p, std::wstring* l) { | |
1013 l->append(L"("); | |
1014 LogParam(p.bitmap, l); | |
1015 l->append(L", "); | |
1016 LogParam(p.bitmap_rect, l); | |
1017 l->append(L", "); | |
1018 LogParam(p.view_size, l); | |
1019 l->append(L", "); | |
1020 LogParam(p.plugin_window_moves, l); | |
1021 l->append(L", "); | |
1022 LogParam(p.flags, l); | |
1023 l->append(L")"); | |
1024 } | |
1025 }; | |
1026 | |
1027 // Traits for ViewHostMsg_ScrollRect_Params structure to pack/unpack. | |
1028 template <> | |
1029 struct ParamTraits<ViewHostMsg_ScrollRect_Params> { | |
1030 typedef ViewHostMsg_ScrollRect_Params param_type; | |
1031 static void Write(Message* m, const param_type& p) { | |
1032 WriteParam(m, p.bitmap); | |
1033 WriteParam(m, p.bitmap_rect); | |
1034 WriteParam(m, p.dx); | |
1035 WriteParam(m, p.dy); | |
1036 WriteParam(m, p.clip_rect); | |
1037 WriteParam(m, p.view_size); | |
1038 WriteParam(m, p.plugin_window_moves); | |
1039 } | |
1040 static bool Read(const Message* m, void** iter, param_type* p) { | |
1041 return | |
1042 ReadParam(m, iter, &p->bitmap) && | |
1043 ReadParam(m, iter, &p->bitmap_rect) && | |
1044 ReadParam(m, iter, &p->dx) && | |
1045 ReadParam(m, iter, &p->dy) && | |
1046 ReadParam(m, iter, &p->clip_rect) && | |
1047 ReadParam(m, iter, &p->view_size) && | |
1048 ReadParam(m, iter, &p->plugin_window_moves); | |
1049 } | |
1050 static void Log(const param_type& p, std::wstring* l) { | |
1051 l->append(L"("); | |
1052 LogParam(p.bitmap, l); | |
1053 l->append(L", "); | |
1054 LogParam(p.bitmap_rect, l); | |
1055 l->append(L", "); | |
1056 LogParam(p.dx, l); | |
1057 l->append(L", "); | |
1058 LogParam(p.dy, l); | |
1059 l->append(L", "); | |
1060 LogParam(p.clip_rect, l); | |
1061 l->append(L", "); | |
1062 LogParam(p.view_size, l); | |
1063 l->append(L", "); | |
1064 LogParam(p.plugin_window_moves, l); | |
1065 l->append(L")"); | |
1066 } | |
1067 }; | |
1068 | |
1069 template <> | |
1070 struct ParamTraits<WebPluginGeometry> { | |
1071 typedef WebPluginGeometry param_type; | |
1072 static void Write(Message* m, const param_type& p) { | |
1073 WriteParam(m, p.window); | |
1074 WriteParam(m, p.window_rect); | |
1075 WriteParam(m, p.clip_rect); | |
1076 WriteParam(m, p.cutout_rects); | |
1077 WriteParam(m, p.visible); | |
1078 } | |
1079 static bool Read(const Message* m, void** iter, param_type* p) { | |
1080 return | |
1081 ReadParam(m, iter, &p->window) && | |
1082 ReadParam(m, iter, &p->window_rect) && | |
1083 ReadParam(m, iter, &p->clip_rect) && | |
1084 ReadParam(m, iter, &p->cutout_rects) && | |
1085 ReadParam(m, iter, &p->visible); | |
1086 } | |
1087 static void Log(const param_type& p, std::wstring* l) { | |
1088 l->append(L"("); | |
1089 LogParam(p.window, l); | |
1090 l->append(L", "); | |
1091 LogParam(p.window_rect, l); | |
1092 l->append(L", "); | |
1093 LogParam(p.clip_rect, l); | |
1094 l->append(L", "); | |
1095 LogParam(p.cutout_rects, l); | |
1096 l->append(L", "); | |
1097 LogParam(p.visible, l); | |
1098 l->append(L")"); | |
1099 } | |
1100 }; | |
1101 | |
1102 // Traits for ViewMsg_GetPlugins_Reply structure to pack/unpack. | |
1103 template <> | |
1104 struct ParamTraits<WebPluginMimeType> { | |
1105 typedef WebPluginMimeType param_type; | |
1106 static void Write(Message* m, const param_type& p) { | |
1107 WriteParam(m, p.mime_type); | |
1108 WriteParam(m, p.file_extensions); | |
1109 WriteParam(m, p.description); | |
1110 } | |
1111 static bool Read(const Message* m, void** iter, param_type* r) { | |
1112 return | |
1113 ReadParam(m, iter, &r->mime_type) && | |
1114 ReadParam(m, iter, &r->file_extensions) && | |
1115 ReadParam(m, iter, &r->description); | |
1116 } | |
1117 static void Log(const param_type& p, std::wstring* l) { | |
1118 l->append(L"("); | |
1119 LogParam(p.mime_type, l); | |
1120 l->append(L", "); | |
1121 LogParam(p.file_extensions, l); | |
1122 l->append(L", "); | |
1123 LogParam(p.description, l); | |
1124 l->append(L")"); | |
1125 } | |
1126 }; | |
1127 | |
1128 | |
1129 template <> | |
1130 struct ParamTraits<WebPluginInfo> { | |
1131 typedef WebPluginInfo param_type; | |
1132 static void Write(Message* m, const param_type& p) { | |
1133 WriteParam(m, p.name); | |
1134 WriteParam(m, p.path); | |
1135 WriteParam(m, p.version); | |
1136 WriteParam(m, p.desc); | |
1137 WriteParam(m, p.mime_types); | |
1138 } | |
1139 static bool Read(const Message* m, void** iter, param_type* r) { | |
1140 return | |
1141 ReadParam(m, iter, &r->name) && | |
1142 ReadParam(m, iter, &r->path) && | |
1143 ReadParam(m, iter, &r->version) && | |
1144 ReadParam(m, iter, &r->desc) && | |
1145 ReadParam(m, iter, &r->mime_types); | |
1146 } | |
1147 static void Log(const param_type& p, std::wstring* l) { | |
1148 l->append(L"("); | |
1149 LogParam(p.name, l); | |
1150 l->append(L", "); | |
1151 l->append(L", "); | |
1152 LogParam(p.path, l); | |
1153 l->append(L", "); | |
1154 LogParam(p.version, l); | |
1155 l->append(L", "); | |
1156 LogParam(p.desc, l); | |
1157 l->append(L", "); | |
1158 LogParam(p.mime_types, l); | |
1159 l->append(L")"); | |
1160 } | |
1161 }; | |
1162 | |
1163 // Traits for ViewMsg_UploadFile_Params structure to pack/unpack. | |
1164 template <> | |
1165 struct ParamTraits<ViewMsg_UploadFile_Params> { | |
1166 typedef ViewMsg_UploadFile_Params param_type; | |
1167 static void Write(Message* m, const param_type& p) { | |
1168 WriteParam(m, p.file_path); | |
1169 WriteParam(m, p.form); | |
1170 WriteParam(m, p.file); | |
1171 WriteParam(m, p.submit); | |
1172 WriteParam(m, p.other_values); | |
1173 } | |
1174 static bool Read(const Message* m, void** iter, param_type* p) { | |
1175 return | |
1176 ReadParam(m, iter, &p->file_path) && | |
1177 ReadParam(m, iter, &p->form) && | |
1178 ReadParam(m, iter, &p->file) && | |
1179 ReadParam(m, iter, &p->submit) && | |
1180 ReadParam(m, iter, &p->other_values); | |
1181 } | |
1182 static void Log(const param_type& p, std::wstring* l) { | |
1183 l->append(L"<ViewMsg_UploadFile_Params>"); | |
1184 } | |
1185 }; | |
1186 | |
1187 // Traits for net::UploadData::Element. | |
1188 template <> | |
1189 struct ParamTraits<net::UploadData::Element> { | |
1190 typedef net::UploadData::Element param_type; | |
1191 static void Write(Message* m, const param_type& p) { | |
1192 WriteParam(m, static_cast<int>(p.type())); | |
1193 if (p.type() == net::UploadData::TYPE_BYTES) { | |
1194 m->WriteData(&p.bytes()[0], static_cast<int>(p.bytes().size())); | |
1195 } else { | |
1196 WriteParam(m, p.file_path()); | |
1197 WriteParam(m, p.file_range_offset()); | |
1198 WriteParam(m, p.file_range_length()); | |
1199 } | |
1200 } | |
1201 static bool Read(const Message* m, void** iter, param_type* r) { | |
1202 int type; | |
1203 if (!ReadParam(m, iter, &type)) | |
1204 return false; | |
1205 if (type == net::UploadData::TYPE_BYTES) { | |
1206 const char* data; | |
1207 int len; | |
1208 if (!m->ReadData(iter, &data, &len)) | |
1209 return false; | |
1210 r->SetToBytes(data, len); | |
1211 } else { | |
1212 DCHECK(type == net::UploadData::TYPE_FILE); | |
1213 std::wstring file_path; | |
1214 uint64 offset, length; | |
1215 if (!ReadParam(m, iter, &file_path)) | |
1216 return false; | |
1217 if (!ReadParam(m, iter, &offset)) | |
1218 return false; | |
1219 if (!ReadParam(m, iter, &length)) | |
1220 return false; | |
1221 r->SetToFilePathRange(file_path, offset, length); | |
1222 } | |
1223 return true; | |
1224 } | |
1225 static void Log(const param_type& p, std::wstring* l) { | |
1226 l->append(L"<net::UploadData::Element>"); | |
1227 } | |
1228 }; | |
1229 | |
1230 // Traits for net::UploadData. | |
1231 template <> | |
1232 struct ParamTraits<scoped_refptr<net::UploadData> > { | |
1233 typedef scoped_refptr<net::UploadData> param_type; | |
1234 static void Write(Message* m, const param_type& p) { | |
1235 WriteParam(m, p.get() != NULL); | |
1236 if (p) { | |
1237 WriteParam(m, p->elements()); | |
1238 WriteParam(m, p->identifier()); | |
1239 } | |
1240 } | |
1241 static bool Read(const Message* m, void** iter, param_type* r) { | |
1242 bool has_object; | |
1243 if (!ReadParam(m, iter, &has_object)) | |
1244 return false; | |
1245 if (!has_object) | |
1246 return true; | |
1247 std::vector<net::UploadData::Element> elements; | |
1248 if (!ReadParam(m, iter, &elements)) | |
1249 return false; | |
1250 int identifier; | |
1251 if (!ReadParam(m, iter, &identifier)) | |
1252 return false; | |
1253 *r = new net::UploadData; | |
1254 (*r)->swap_elements(&elements); | |
1255 (*r)->set_identifier(identifier); | |
1256 return true; | |
1257 } | |
1258 static void Log(const param_type& p, std::wstring* l) { | |
1259 l->append(L"<net::UploadData>"); | |
1260 } | |
1261 }; | |
1262 | |
1263 // Traits for WebKit::WebCache::UsageStats | 216 // Traits for WebKit::WebCache::UsageStats |
1264 template <> | 217 template <> |
1265 struct ParamTraits<WebKit::WebCache::UsageStats> { | 218 struct ParamTraits<WebKit::WebCache::UsageStats> { |
1266 typedef WebKit::WebCache::UsageStats param_type; | 219 typedef WebKit::WebCache::UsageStats param_type; |
1267 static void Write(Message* m, const param_type& p) { | 220 static void Write(Message* m, const param_type& p) { |
1268 WriteParam(m, p.minDeadCapacity); | 221 WriteParam(m, p.minDeadCapacity); |
1269 WriteParam(m, p.maxDeadCapacity); | 222 WriteParam(m, p.maxDeadCapacity); |
1270 WriteParam(m, p.capacity); | 223 WriteParam(m, p.capacity); |
1271 WriteParam(m, p.liveSize); | 224 WriteParam(m, p.liveSize); |
1272 WriteParam(m, p.deadSize); | 225 WriteParam(m, p.deadSize); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 l->append(L"<WebCoreStats>"); | 283 l->append(L"<WebCoreStats>"); |
1331 LogParam(p.images, l); | 284 LogParam(p.images, l); |
1332 LogParam(p.cssStyleSheets, l); | 285 LogParam(p.cssStyleSheets, l); |
1333 LogParam(p.scripts, l); | 286 LogParam(p.scripts, l); |
1334 LogParam(p.xslStyleSheets, l); | 287 LogParam(p.xslStyleSheets, l); |
1335 LogParam(p.fonts, l); | 288 LogParam(p.fonts, l); |
1336 l->append(L"</WebCoreStats>"); | 289 l->append(L"</WebCoreStats>"); |
1337 } | 290 } |
1338 }; | 291 }; |
1339 | 292 |
1340 // Traits for PasswordFormDomManager::FillData. | |
1341 template <> | |
1342 struct ParamTraits<PasswordFormDomManager::FillData> { | |
1343 typedef PasswordFormDomManager::FillData param_type; | |
1344 static void Write(Message* m, const param_type& p) { | |
1345 WriteParam(m, p.basic_data); | |
1346 WriteParam(m, p.additional_logins); | |
1347 WriteParam(m, p.wait_for_username); | |
1348 } | |
1349 static bool Read(const Message* m, void** iter, param_type* r) { | |
1350 return | |
1351 ReadParam(m, iter, &r->basic_data) && | |
1352 ReadParam(m, iter, &r->additional_logins) && | |
1353 ReadParam(m, iter, &r->wait_for_username); | |
1354 } | |
1355 static void Log(const param_type& p, std::wstring* l) { | |
1356 l->append(L"<PasswordFormDomManager::FillData>"); | |
1357 } | |
1358 }; | |
1359 | |
1360 template<> | |
1361 struct ParamTraits<NavigationGesture> { | |
1362 typedef NavigationGesture param_type; | |
1363 static void Write(Message* m, const param_type& p) { | |
1364 m->WriteInt(p); | |
1365 } | |
1366 static bool Read(const Message* m, void** iter, param_type* p) { | |
1367 int type; | |
1368 if (!m->ReadInt(iter, &type)) | |
1369 return false; | |
1370 *p = static_cast<NavigationGesture>(type); | |
1371 return true; | |
1372 } | |
1373 static void Log(const param_type& p, std::wstring* l) { | |
1374 std::wstring event; | |
1375 switch (p) { | |
1376 case NavigationGestureUser: | |
1377 event = L"GESTURE_USER"; | |
1378 break; | |
1379 case NavigationGestureAuto: | |
1380 event = L"GESTURE_AUTO"; | |
1381 break; | |
1382 default: | |
1383 event = L"GESTURE_UNKNOWN"; | |
1384 break; | |
1385 } | |
1386 LogParam(event, l); | |
1387 } | |
1388 }; | |
1389 | |
1390 // Traits for ViewHostMsg_Resource_Request | |
1391 template <> | |
1392 struct ParamTraits<ViewHostMsg_Resource_Request> { | |
1393 typedef ViewHostMsg_Resource_Request param_type; | |
1394 static void Write(Message* m, const param_type& p) { | |
1395 WriteParam(m, p.method); | |
1396 WriteParam(m, p.url); | |
1397 WriteParam(m, p.policy_url); | |
1398 WriteParam(m, p.referrer); | |
1399 WriteParam(m, p.frame_origin); | |
1400 WriteParam(m, p.main_frame_origin); | |
1401 WriteParam(m, p.headers); | |
1402 WriteParam(m, p.default_mime_type); | |
1403 WriteParam(m, p.load_flags); | |
1404 WriteParam(m, p.origin_pid); | |
1405 WriteParam(m, p.resource_type); | |
1406 WriteParam(m, p.request_context); | |
1407 WriteParam(m, p.upload_data); | |
1408 } | |
1409 static bool Read(const Message* m, void** iter, param_type* r) { | |
1410 return | |
1411 ReadParam(m, iter, &r->method) && | |
1412 ReadParam(m, iter, &r->url) && | |
1413 ReadParam(m, iter, &r->policy_url) && | |
1414 ReadParam(m, iter, &r->referrer) && | |
1415 ReadParam(m, iter, &r->frame_origin) && | |
1416 ReadParam(m, iter, &r->main_frame_origin) && | |
1417 ReadParam(m, iter, &r->headers) && | |
1418 ReadParam(m, iter, &r->default_mime_type) && | |
1419 ReadParam(m, iter, &r->load_flags) && | |
1420 ReadParam(m, iter, &r->origin_pid) && | |
1421 ReadParam(m, iter, &r->resource_type) && | |
1422 ReadParam(m, iter, &r->request_context) && | |
1423 ReadParam(m, iter, &r->upload_data); | |
1424 } | |
1425 static void Log(const param_type& p, std::wstring* l) { | |
1426 l->append(L"("); | |
1427 LogParam(p.method, l); | |
1428 l->append(L", "); | |
1429 LogParam(p.url, l); | |
1430 l->append(L", "); | |
1431 LogParam(p.referrer, l); | |
1432 l->append(L", "); | |
1433 LogParam(p.frame_origin, l); | |
1434 l->append(L", "); | |
1435 LogParam(p.main_frame_origin, l); | |
1436 l->append(L", "); | |
1437 LogParam(p.default_mime_type, l); | |
1438 l->append(L", "); | |
1439 LogParam(p.load_flags, l); | |
1440 l->append(L", "); | |
1441 LogParam(p.origin_pid, l); | |
1442 l->append(L", "); | |
1443 LogParam(p.resource_type, l); | |
1444 l->append(L", "); | |
1445 LogParam(p.request_context, l); | |
1446 l->append(L")"); | |
1447 } | |
1448 }; | |
1449 | |
1450 // Traits for URLRequestStatus | |
1451 template <> | |
1452 struct ParamTraits<URLRequestStatus> { | |
1453 typedef URLRequestStatus param_type; | |
1454 static void Write(Message* m, const param_type& p) { | |
1455 WriteParam(m, static_cast<int>(p.status())); | |
1456 WriteParam(m, p.os_error()); | |
1457 } | |
1458 static bool Read(const Message* m, void** iter, param_type* r) { | |
1459 int status, os_error; | |
1460 if (!ReadParam(m, iter, &status) || | |
1461 !ReadParam(m, iter, &os_error)) | |
1462 return false; | |
1463 r->set_status(static_cast<URLRequestStatus::Status>(status)); | |
1464 r->set_os_error(os_error); | |
1465 return true; | |
1466 } | |
1467 static void Log(const param_type& p, std::wstring* l) { | |
1468 std::wstring status; | |
1469 switch (p.status()) { | |
1470 case URLRequestStatus::SUCCESS: | |
1471 status = L"SUCCESS"; | |
1472 break; | |
1473 case URLRequestStatus::IO_PENDING: | |
1474 status = L"IO_PENDING "; | |
1475 break; | |
1476 case URLRequestStatus::HANDLED_EXTERNALLY: | |
1477 status = L"HANDLED_EXTERNALLY"; | |
1478 break; | |
1479 case URLRequestStatus::CANCELED: | |
1480 status = L"CANCELED"; | |
1481 break; | |
1482 case URLRequestStatus::FAILED: | |
1483 status = L"FAILED"; | |
1484 break; | |
1485 default: | |
1486 status = L"UNKNOWN"; | |
1487 break; | |
1488 } | |
1489 if (p.status() == URLRequestStatus::FAILED) | |
1490 l->append(L"("); | |
1491 | |
1492 LogParam(status, l); | |
1493 | |
1494 if (p.status() == URLRequestStatus::FAILED) { | |
1495 l->append(L", "); | |
1496 LogParam(p.os_error(), l); | |
1497 l->append(L")"); | |
1498 } | |
1499 } | |
1500 }; | |
1501 | |
1502 template <> | |
1503 struct ParamTraits<scoped_refptr<net::HttpResponseHeaders> > { | |
1504 typedef scoped_refptr<net::HttpResponseHeaders> param_type; | |
1505 static void Write(Message* m, const param_type& p) { | |
1506 WriteParam(m, p.get() != NULL); | |
1507 if (p) { | |
1508 // Do not disclose Set-Cookie headers over IPC. | |
1509 p->Persist(m, net::HttpResponseHeaders::PERSIST_SANS_COOKIES); | |
1510 } | |
1511 } | |
1512 static bool Read(const Message* m, void** iter, param_type* r) { | |
1513 bool has_object; | |
1514 if (!ReadParam(m, iter, &has_object)) | |
1515 return false; | |
1516 if (has_object) | |
1517 *r = new net::HttpResponseHeaders(*m, iter); | |
1518 return true; | |
1519 } | |
1520 static void Log(const param_type& p, std::wstring* l) { | |
1521 l->append(L"<HttpResponseHeaders>"); | |
1522 } | |
1523 }; | |
1524 | |
1525 // Traits for webkit_glue::ResourceLoaderBridge::ResponseInfo | |
1526 template <> | |
1527 struct ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo> { | |
1528 typedef webkit_glue::ResourceLoaderBridge::ResponseInfo param_type; | |
1529 static void Write(Message* m, const param_type& p) { | |
1530 WriteParam(m, p.request_time); | |
1531 WriteParam(m, p.response_time); | |
1532 WriteParam(m, p.headers); | |
1533 WriteParam(m, p.mime_type); | |
1534 WriteParam(m, p.charset); | |
1535 WriteParam(m, p.security_info); | |
1536 WriteParam(m, p.content_length); | |
1537 WriteParam(m, p.response_data_file); | |
1538 } | |
1539 static bool Read(const Message* m, void** iter, param_type* r) { | |
1540 return | |
1541 ReadParam(m, iter, &r->request_time) && | |
1542 ReadParam(m, iter, &r->response_time) && | |
1543 ReadParam(m, iter, &r->headers) && | |
1544 ReadParam(m, iter, &r->mime_type) && | |
1545 ReadParam(m, iter, &r->charset) && | |
1546 ReadParam(m, iter, &r->security_info) && | |
1547 ReadParam(m, iter, &r->content_length) && | |
1548 ReadParam(m, iter, &r->response_data_file); | |
1549 } | |
1550 static void Log(const param_type& p, std::wstring* l) { | |
1551 l->append(L"("); | |
1552 LogParam(p.request_time, l); | |
1553 l->append(L", "); | |
1554 LogParam(p.response_time, l); | |
1555 l->append(L", "); | |
1556 LogParam(p.headers, l); | |
1557 l->append(L", "); | |
1558 LogParam(p.mime_type, l); | |
1559 l->append(L", "); | |
1560 LogParam(p.charset, l); | |
1561 l->append(L", "); | |
1562 LogParam(p.security_info, l); | |
1563 l->append(L")"); | |
1564 } | |
1565 }; | |
1566 | |
1567 template <> | |
1568 struct ParamTraits<ResourceResponseHead> { | |
1569 typedef ResourceResponseHead param_type; | |
1570 static void Write(Message* m, const param_type& p) { | |
1571 ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Write(m, p); | |
1572 WriteParam(m, p.status); | |
1573 WriteParam(m, p.filter_policy); | |
1574 } | |
1575 static bool Read(const Message* m, void** iter, param_type* r) { | |
1576 return | |
1577 ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Read(m, | |
1578 iter, | |
1579 r) && | |
1580 ReadParam(m, iter, &r->status) && | |
1581 ReadParam(m, iter, &r->filter_policy); | |
1582 } | |
1583 static void Log(const param_type& p, std::wstring* l) { | |
1584 // log more? | |
1585 ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Log(p, l); | |
1586 } | |
1587 }; | |
1588 | |
1589 template <> | |
1590 struct ParamTraits<SyncLoadResult> { | |
1591 typedef SyncLoadResult param_type; | |
1592 static void Write(Message* m, const param_type& p) { | |
1593 ParamTraits<ResourceResponseHead>::Write(m, p); | |
1594 WriteParam(m, p.final_url); | |
1595 WriteParam(m, p.data); | |
1596 } | |
1597 static bool Read(const Message* m, void** iter, param_type* r) { | |
1598 return | |
1599 ParamTraits<ResourceResponseHead>::Read(m, iter, r) && | |
1600 ReadParam(m, iter, &r->final_url) && | |
1601 ReadParam(m, iter, &r->data); | |
1602 } | |
1603 static void Log(const param_type& p, std::wstring* l) { | |
1604 // log more? | |
1605 ParamTraits<webkit_glue::ResourceLoaderBridge::ResponseInfo>::Log(p, l); | |
1606 } | |
1607 }; | |
1608 | |
1609 // Traits for FormData structure to pack/unpack. | |
1610 template <> | |
1611 struct ParamTraits<FormData> { | |
1612 typedef FormData param_type; | |
1613 static void Write(Message* m, const param_type& p) { | |
1614 WriteParam(m, p.origin); | |
1615 WriteParam(m, p.action); | |
1616 WriteParam(m, p.elements); | |
1617 WriteParam(m, p.values); | |
1618 WriteParam(m, p.submit); | |
1619 } | |
1620 static bool Read(const Message* m, void** iter, param_type* p) { | |
1621 return | |
1622 ReadParam(m, iter, &p->origin) && | |
1623 ReadParam(m, iter, &p->action) && | |
1624 ReadParam(m, iter, &p->elements) && | |
1625 ReadParam(m, iter, &p->values) && | |
1626 ReadParam(m, iter, &p->submit); | |
1627 } | |
1628 static void Log(const param_type& p, std::wstring* l) { | |
1629 l->append(L"<FormData>"); | |
1630 } | |
1631 }; | |
1632 | |
1633 // Traits for ViewMsg_Print_Params | |
1634 template <> | |
1635 struct ParamTraits<ViewMsg_Print_Params> { | |
1636 typedef ViewMsg_Print_Params param_type; | |
1637 static void Write(Message* m, const param_type& p) { | |
1638 WriteParam(m, p.printable_size); | |
1639 WriteParam(m, p.dpi); | |
1640 WriteParam(m, p.min_shrink); | |
1641 WriteParam(m, p.max_shrink); | |
1642 WriteParam(m, p.desired_dpi); | |
1643 WriteParam(m, p.document_cookie); | |
1644 } | |
1645 static bool Read(const Message* m, void** iter, param_type* p) { | |
1646 return ReadParam(m, iter, &p->printable_size) && | |
1647 ReadParam(m, iter, &p->dpi) && | |
1648 ReadParam(m, iter, &p->min_shrink) && | |
1649 ReadParam(m, iter, &p->max_shrink) && | |
1650 ReadParam(m, iter, &p->desired_dpi) && | |
1651 ReadParam(m, iter, &p->document_cookie); | |
1652 } | |
1653 static void Log(const param_type& p, std::wstring* l) { | |
1654 l->append(L"<ViewMsg_Print_Params>"); | |
1655 } | |
1656 }; | |
1657 | |
1658 // Traits for ViewMsg_PrintPage_Params | |
1659 template <> | |
1660 struct ParamTraits<ViewMsg_PrintPage_Params> { | |
1661 typedef ViewMsg_PrintPage_Params param_type; | |
1662 static void Write(Message* m, const param_type& p) { | |
1663 WriteParam(m, p.params); | |
1664 WriteParam(m, p.page_number); | |
1665 } | |
1666 static bool Read(const Message* m, void** iter, param_type* p) { | |
1667 return ReadParam(m, iter, &p->params) && | |
1668 ReadParam(m, iter, &p->page_number); | |
1669 } | |
1670 static void Log(const param_type& p, std::wstring* l) { | |
1671 l->append(L"<ViewMsg_PrintPage_Params>"); | |
1672 } | |
1673 }; | |
1674 | |
1675 // Traits for ViewMsg_PrintPages_Params | |
1676 template <> | |
1677 struct ParamTraits<ViewMsg_PrintPages_Params> { | |
1678 typedef ViewMsg_PrintPages_Params param_type; | |
1679 static void Write(Message* m, const param_type& p) { | |
1680 WriteParam(m, p.params); | |
1681 WriteParam(m, p.pages); | |
1682 } | |
1683 static bool Read(const Message* m, void** iter, param_type* p) { | |
1684 return ReadParam(m, iter, &p->params) && | |
1685 ReadParam(m, iter, &p->pages); | |
1686 } | |
1687 static void Log(const param_type& p, std::wstring* l) { | |
1688 l->append(L"<ViewMsg_PrintPages_Params>"); | |
1689 } | |
1690 }; | |
1691 | |
1692 // Traits for ViewHostMsg_DidPrintPage_Params | |
1693 template <> | |
1694 struct ParamTraits<ViewHostMsg_DidPrintPage_Params> { | |
1695 typedef ViewHostMsg_DidPrintPage_Params param_type; | |
1696 static void Write(Message* m, const param_type& p) { | |
1697 WriteParam(m, p.emf_data_handle); | |
1698 WriteParam(m, p.data_size); | |
1699 WriteParam(m, p.document_cookie); | |
1700 WriteParam(m, p.page_number); | |
1701 WriteParam(m, p.actual_shrink); | |
1702 } | |
1703 static bool Read(const Message* m, void** iter, param_type* p) { | |
1704 return ReadParam(m, iter, &p->emf_data_handle) && | |
1705 ReadParam(m, iter, &p->data_size) && | |
1706 ReadParam(m, iter, &p->document_cookie) && | |
1707 ReadParam(m, iter, &p->page_number) && | |
1708 ReadParam(m, iter, &p->actual_shrink); | |
1709 } | |
1710 static void Log(const param_type& p, std::wstring* l) { | |
1711 l->append(L"<ViewHostMsg_DidPrintPage_Params>"); | |
1712 } | |
1713 }; | |
1714 | |
1715 // Traits for WebPreferences structure to pack/unpack. | |
1716 template <> | |
1717 struct ParamTraits<WebPreferences> { | |
1718 typedef WebPreferences param_type; | |
1719 static void Write(Message* m, const param_type& p) { | |
1720 WriteParam(m, p.standard_font_family); | |
1721 WriteParam(m, p.fixed_font_family); | |
1722 WriteParam(m, p.serif_font_family); | |
1723 WriteParam(m, p.sans_serif_font_family); | |
1724 WriteParam(m, p.cursive_font_family); | |
1725 WriteParam(m, p.fantasy_font_family); | |
1726 WriteParam(m, p.default_font_size); | |
1727 WriteParam(m, p.default_fixed_font_size); | |
1728 WriteParam(m, p.minimum_font_size); | |
1729 WriteParam(m, p.minimum_logical_font_size); | |
1730 WriteParam(m, p.default_encoding); | |
1731 WriteParam(m, p.javascript_enabled); | |
1732 WriteParam(m, p.web_security_enabled); | |
1733 WriteParam(m, p.javascript_can_open_windows_automatically); | |
1734 WriteParam(m, p.loads_images_automatically); | |
1735 WriteParam(m, p.plugins_enabled); | |
1736 WriteParam(m, p.dom_paste_enabled); | |
1737 WriteParam(m, p.developer_extras_enabled); | |
1738 WriteParam(m, p.shrinks_standalone_images_to_fit); | |
1739 WriteParam(m, p.uses_universal_detector); | |
1740 WriteParam(m, p.text_areas_are_resizable); | |
1741 WriteParam(m, p.java_enabled); | |
1742 WriteParam(m, p.user_style_sheet_enabled); | |
1743 WriteParam(m, p.user_style_sheet_location); | |
1744 WriteParam(m, p.uses_page_cache); | |
1745 } | |
1746 static bool Read(const Message* m, void** iter, param_type* p) { | |
1747 return | |
1748 ReadParam(m, iter, &p->standard_font_family) && | |
1749 ReadParam(m, iter, &p->fixed_font_family) && | |
1750 ReadParam(m, iter, &p->serif_font_family) && | |
1751 ReadParam(m, iter, &p->sans_serif_font_family) && | |
1752 ReadParam(m, iter, &p->cursive_font_family) && | |
1753 ReadParam(m, iter, &p->fantasy_font_family) && | |
1754 ReadParam(m, iter, &p->default_font_size) && | |
1755 ReadParam(m, iter, &p->default_fixed_font_size) && | |
1756 ReadParam(m, iter, &p->minimum_font_size) && | |
1757 ReadParam(m, iter, &p->minimum_logical_font_size) && | |
1758 ReadParam(m, iter, &p->default_encoding) && | |
1759 ReadParam(m, iter, &p->javascript_enabled) && | |
1760 ReadParam(m, iter, &p->web_security_enabled) && | |
1761 ReadParam(m, iter, &p->javascript_can_open_windows_automatically) && | |
1762 ReadParam(m, iter, &p->loads_images_automatically) && | |
1763 ReadParam(m, iter, &p->plugins_enabled) && | |
1764 ReadParam(m, iter, &p->dom_paste_enabled) && | |
1765 ReadParam(m, iter, &p->developer_extras_enabled) && | |
1766 ReadParam(m, iter, &p->shrinks_standalone_images_to_fit) && | |
1767 ReadParam(m, iter, &p->uses_universal_detector) && | |
1768 ReadParam(m, iter, &p->text_areas_are_resizable) && | |
1769 ReadParam(m, iter, &p->java_enabled) && | |
1770 ReadParam(m, iter, &p->user_style_sheet_enabled) && | |
1771 ReadParam(m, iter, &p->user_style_sheet_location) && | |
1772 ReadParam(m, iter, &p->uses_page_cache); | |
1773 } | |
1774 static void Log(const param_type& p, std::wstring* l) { | |
1775 l->append(L"<WebPreferences>"); | |
1776 } | |
1777 }; | |
1778 | |
1779 // Traits for WebDropData | |
1780 template <> | |
1781 struct ParamTraits<WebDropData> { | |
1782 typedef WebDropData param_type; | |
1783 static void Write(Message* m, const param_type& p) { | |
1784 WriteParam(m, p.identity); | |
1785 WriteParam(m, p.url); | |
1786 WriteParam(m, p.url_title); | |
1787 WriteParam(m, p.file_extension); | |
1788 WriteParam(m, p.filenames); | |
1789 WriteParam(m, p.plain_text); | |
1790 WriteParam(m, p.text_html); | |
1791 WriteParam(m, p.html_base_url); | |
1792 WriteParam(m, p.file_description_filename); | |
1793 WriteParam(m, p.file_contents); | |
1794 } | |
1795 static bool Read(const Message* m, void** iter, param_type* p) { | |
1796 return | |
1797 ReadParam(m, iter, &p->identity) && | |
1798 ReadParam(m, iter, &p->url) && | |
1799 ReadParam(m, iter, &p->url_title) && | |
1800 ReadParam(m, iter, &p->file_extension) && | |
1801 ReadParam(m, iter, &p->filenames) && | |
1802 ReadParam(m, iter, &p->plain_text) && | |
1803 ReadParam(m, iter, &p->text_html) && | |
1804 ReadParam(m, iter, &p->html_base_url) && | |
1805 ReadParam(m, iter, &p->file_description_filename) && | |
1806 ReadParam(m, iter, &p->file_contents); | |
1807 } | |
1808 static void Log(const param_type& p, std::wstring* l) { | |
1809 l->append(L"<WebDropData>"); | |
1810 } | |
1811 }; | |
1812 | |
1813 // Traits for ScreenInfo | |
1814 template <> | |
1815 struct ParamTraits<webkit_glue::ScreenInfo> { | |
1816 typedef webkit_glue::ScreenInfo param_type; | |
1817 static void Write(Message* m, const param_type& p) { | |
1818 WriteParam(m, p.depth); | |
1819 WriteParam(m, p.depth_per_component); | |
1820 WriteParam(m, p.is_monochrome); | |
1821 WriteParam(m, p.rect); | |
1822 WriteParam(m, p.available_rect); | |
1823 } | |
1824 static bool Read(const Message* m, void** iter, param_type* p) { | |
1825 return | |
1826 ReadParam(m, iter, &p->depth) && | |
1827 ReadParam(m, iter, &p->depth_per_component) && | |
1828 ReadParam(m, iter, &p->is_monochrome) && | |
1829 ReadParam(m, iter, &p->rect) && | |
1830 ReadParam(m, iter, &p->available_rect); | |
1831 } | |
1832 static void Log(const param_type& p, std::wstring* l) { | |
1833 l->append(L"<webkit_glue::ScreenInfo>"); | |
1834 } | |
1835 }; | |
1836 | |
1837 template<> | |
1838 struct ParamTraits<ModalDialogEvent> { | |
1839 typedef ModalDialogEvent param_type; | |
1840 #if defined(OS_WIN) | |
1841 static void Write(Message* m, const param_type& p) { | |
1842 WriteParam(m, p.event); | |
1843 } | |
1844 static bool Read(const Message* m, void** iter, param_type* p) { | |
1845 return ReadParam(m, iter, &p->event); | |
1846 } | |
1847 #else | |
1848 static void Write(Message* m, const param_type& p) { | |
1849 } | |
1850 static bool Read(const Message* m, void** iter, param_type* p) { | |
1851 return true; | |
1852 } | |
1853 #endif | |
1854 | |
1855 static void Log(const param_type& p, std::wstring* l) { | |
1856 l->append(L"<ModalDialogEvent>"); | |
1857 } | |
1858 }; | |
1859 | |
1860 // Traits for AudioManager::Format. | |
1861 template <> | |
1862 struct ParamTraits<AudioManager::Format> { | |
1863 typedef AudioManager::Format param_type; | |
1864 static void Write(Message* m, const param_type& p) { | |
1865 m->WriteInt(p); | |
1866 } | |
1867 static bool Read(const Message* m, void** iter, param_type* p) { | |
1868 int type; | |
1869 if (!m->ReadInt(iter, &type)) | |
1870 return false; | |
1871 *p = static_cast<AudioManager::Format>(type); | |
1872 return true; | |
1873 } | |
1874 static void Log(const param_type& p, std::wstring* l) { | |
1875 std::wstring format; | |
1876 switch (p) { | |
1877 case AudioManager::AUDIO_PCM_LINEAR: | |
1878 format = L"AUDIO_PCM_LINEAR"; | |
1879 break; | |
1880 case AudioManager::AUDIO_PCM_DELTA: | |
1881 format = L"AUDIO_PCM_DELTA"; | |
1882 break; | |
1883 case AudioManager::AUDIO_MOCK: | |
1884 format = L"AUDIO_MOCK"; | |
1885 break; | |
1886 default: | |
1887 format = L"AUDIO_LAST_FORMAT"; | |
1888 break; | |
1889 } | |
1890 LogParam(format, l); | |
1891 } | |
1892 }; | |
1893 | |
1894 // Traits for ViewHostMsg_Audio_CreateStream. | |
1895 template <> | |
1896 struct ParamTraits<ViewHostMsg_Audio_CreateStream> { | |
1897 typedef ViewHostMsg_Audio_CreateStream param_type; | |
1898 static void Write(Message* m, const param_type& p) { | |
1899 WriteParam(m, p.format); | |
1900 WriteParam(m, p.channels); | |
1901 WriteParam(m, p.sample_rate); | |
1902 WriteParam(m, p.bits_per_sample); | |
1903 WriteParam(m, p.packet_size); | |
1904 } | |
1905 static bool Read(const Message* m, void** iter, param_type* p) { | |
1906 return | |
1907 ReadParam(m, iter, &p->format) && | |
1908 ReadParam(m, iter, &p->channels) && | |
1909 ReadParam(m, iter, &p->sample_rate) && | |
1910 ReadParam(m, iter, &p->bits_per_sample) && | |
1911 ReadParam(m, iter, &p->packet_size); | |
1912 } | |
1913 static void Log(const param_type& p, std::wstring* l) { | |
1914 l->append(L"<ViewHostMsg_Audio_CreateStream>("); | |
1915 LogParam(p.format, l); | |
1916 l->append(L", "); | |
1917 LogParam(p.channels, l); | |
1918 l->append(L", "); | |
1919 LogParam(p.sample_rate, l); | |
1920 l->append(L", "); | |
1921 LogParam(p.bits_per_sample, l); | |
1922 l->append(L", "); | |
1923 LogParam(p.packet_size, l); | |
1924 l->append(L")"); | |
1925 } | |
1926 }; | |
1927 | |
1928 | |
1929 #if defined(OS_POSIX) | |
1930 | |
1931 // TODO(port): this shouldn't exist. However, the plugin stuff is really using | |
1932 // HWNDS (NativeView), and making Windows calls based on them. I've not figured | |
1933 // out the deal with plugins yet. | |
1934 template <> | |
1935 struct ParamTraits<gfx::NativeView> { | |
1936 typedef gfx::NativeView param_type; | |
1937 static void Write(Message* m, const param_type& p) { | |
1938 NOTIMPLEMENTED(); | |
1939 } | |
1940 | |
1941 static bool Read(const Message* m, void** iter, param_type* p) { | |
1942 NOTIMPLEMENTED(); | |
1943 *p = NULL; | |
1944 return true; | |
1945 } | |
1946 | |
1947 static void Log(const param_type& p, std::wstring* l) { | |
1948 l->append(StringPrintf(L"<gfx::NativeView>")); | |
1949 } | |
1950 }; | |
1951 | |
1952 #endif // defined(OS_POSIX) | |
1953 | |
1954 template <> | |
1955 struct ParamTraits<AudioOutputStream::State> { | |
1956 typedef AudioOutputStream::State param_type; | |
1957 static void Write(Message* m, const param_type& p) { | |
1958 m->WriteInt(p); | |
1959 } | |
1960 static bool Read(const Message* m, void** iter, param_type* p) { | |
1961 int type; | |
1962 if (!m->ReadInt(iter, &type)) | |
1963 return false; | |
1964 *p = static_cast<AudioOutputStream::State>(type); | |
1965 return true; | |
1966 } | |
1967 static void Log(const param_type& p, std::wstring* l) { | |
1968 std::wstring state; | |
1969 switch (p) { | |
1970 case AudioOutputStream::STATE_PAUSED: | |
1971 state = L"AudioOutputStream::STATE_PAUSED"; | |
1972 break; | |
1973 case AudioOutputStream::STATE_STARTED: | |
1974 state = L"AudioOutputStream::STATE_STARTED"; | |
1975 break; | |
1976 case AudioOutputStream::STATE_ERROR: | |
1977 state = L"AudioOutputStream::STATE_ERROR"; | |
1978 break; | |
1979 default: | |
1980 state = L"UNKNOWN"; | |
1981 break; | |
1982 } | |
1983 | |
1984 LogParam(state, l); | |
1985 } | |
1986 }; | |
1987 | |
1988 template <> | |
1989 struct ParamTraits<WebKit::WebFindInPageRequest> { | |
1990 typedef WebKit::WebFindInPageRequest param_type; | |
1991 static void Write(Message* m, const param_type& p) { | |
1992 WriteParam(m, p.identifier); | |
1993 WriteParam(m, p.text); | |
1994 WriteParam(m, p.forward); | |
1995 WriteParam(m, p.matchCase); | |
1996 WriteParam(m, p.findNext); | |
1997 } | |
1998 static bool Read(const Message* m, void** iter, param_type* p) { | |
1999 return | |
2000 ReadParam(m, iter, &p->identifier) && | |
2001 ReadParam(m, iter, &p->text) && | |
2002 ReadParam(m, iter, &p->forward) && | |
2003 ReadParam(m, iter, &p->matchCase) && | |
2004 ReadParam(m, iter, &p->findNext); | |
2005 } | |
2006 static void Log(const param_type& p, std::wstring* l) { | |
2007 l->append(L"<FindInPageRequest>"); | |
2008 } | |
2009 }; | |
2010 | |
2011 } // namespace IPC | 293 } // namespace IPC |
2012 | 294 |
2013 | 295 #endif // CHROME_COMMON_WEBKIT_PARAM_TRAITS_H_ |
2014 #define MESSAGES_INTERNAL_FILE "chrome/common/render_messages_internal.h" | |
2015 #include "chrome/common/ipc_message_macros.h" | |
2016 | |
2017 #endif // CHROME_COMMON_RENDER_MESSAGES_H_ | |
OLD | NEW |