Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: chrome/common/render_messages_params.cc

Issue 6721021: Move a bunch of renderer->browser messages to content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/render_messages_params.h" 5 #include "chrome/common/render_messages_params.h"
6 6
7 #include "chrome/common/common_param_traits.h" 7 #include "chrome/common/common_param_traits.h"
8 #include "chrome/common/extensions/extension_constants.h" 8 #include "chrome/common/extensions/extension_constants.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "net/base/upload_data.h" 10 #include "net/base/upload_data.h"
11 11
12 ViewHostMsg_FrameNavigate_Params::ViewHostMsg_FrameNavigate_Params()
13 : page_id(0),
14 frame_id(0),
15 transition(PageTransition::TYPED),
16 should_update_history(false),
17 gesture(NavigationGestureUser),
18 is_post(false),
19 was_within_same_page(false),
20 http_status_code(0),
21 was_fetched_via_proxy(false) {
22 }
23
24 ViewHostMsg_FrameNavigate_Params::~ViewHostMsg_FrameNavigate_Params() {
25 }
26
27 ViewHostMsg_UpdateRect_Params::ViewHostMsg_UpdateRect_Params()
28 : dx(0),
29 dy(0),
30 flags(0) {
31 // On windows, bitmap is of type "struct HandleAndSequenceNum"
32 memset(&bitmap, 0, sizeof(bitmap));
33 }
34
35 ViewHostMsg_UpdateRect_Params::~ViewHostMsg_UpdateRect_Params() {
36 }
37
38 ViewMsg_Print_Params::ViewMsg_Print_Params() 12 ViewMsg_Print_Params::ViewMsg_Print_Params()
39 : margin_top(0), 13 : margin_top(0),
40 margin_left(0), 14 margin_left(0),
41 dpi(0), 15 dpi(0),
42 min_shrink(0), 16 min_shrink(0),
43 max_shrink(0), 17 max_shrink(0),
44 desired_dpi(0), 18 desired_dpi(0),
45 document_cookie(0), 19 document_cookie(0),
46 selection_only(false), 20 selection_only(false),
47 supports_alpha_blend(true) { 21 supports_alpha_blend(true) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 const std::string& code, 114 const std::string& code,
141 bool all_frames) 115 bool all_frames)
142 : request_id(request_id), extension_id(extension_id), 116 : request_id(request_id), extension_id(extension_id),
143 is_javascript(is_javascript), 117 is_javascript(is_javascript),
144 code(code), all_frames(all_frames) { 118 code(code), all_frames(all_frames) {
145 } 119 }
146 120
147 ViewMsg_ExecuteCode_Params::~ViewMsg_ExecuteCode_Params() { 121 ViewMsg_ExecuteCode_Params::~ViewMsg_ExecuteCode_Params() {
148 } 122 }
149 123
150 ViewHostMsg_CreateWindow_Params::ViewHostMsg_CreateWindow_Params()
151 : opener_id(0),
152 user_gesture(false),
153 window_container_type(WINDOW_CONTAINER_TYPE_NORMAL),
154 session_storage_namespace_id(0),
155 opener_frame_id(0) {
156 }
157
158 ViewHostMsg_CreateWindow_Params::~ViewHostMsg_CreateWindow_Params() {
159 }
160
161 ViewHostMsg_RunFileChooser_Params::ViewHostMsg_RunFileChooser_Params()
162 : mode(Open) {
163 }
164
165 ViewHostMsg_RunFileChooser_Params::~ViewHostMsg_RunFileChooser_Params() {
166 }
167
168 ViewHostMsg_DomMessage_Params::ViewHostMsg_DomMessage_Params() 124 ViewHostMsg_DomMessage_Params::ViewHostMsg_DomMessage_Params()
169 : request_id(0), 125 : request_id(0),
170 has_callback(false), 126 has_callback(false),
171 user_gesture(false) { 127 user_gesture(false) {
172 } 128 }
173 129
174 ViewHostMsg_DomMessage_Params::~ViewHostMsg_DomMessage_Params() { 130 ViewHostMsg_DomMessage_Params::~ViewHostMsg_DomMessage_Params() {
175 } 131 }
176 132
177 ViewHostMsg_MalwareDOMDetails_Node::ViewHostMsg_MalwareDOMDetails_Node() { 133 ViewHostMsg_MalwareDOMDetails_Node::ViewHostMsg_MalwareDOMDetails_Node() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 Extension::Create(path, location, *manifest, kRequireKey, 196 Extension::Create(path, location, *manifest, kRequireKey,
241 kStrictErrorChecks, &error)); 197 kStrictErrorChecks, &error));
242 if (!extension.get()) 198 if (!extension.get())
243 LOG(ERROR) << "Error deserializing extension: " << error; 199 LOG(ERROR) << "Error deserializing extension: " << error;
244 200
245 return extension; 201 return extension;
246 } 202 }
247 203
248 namespace IPC { 204 namespace IPC {
249 205
250 template<>
251 struct ParamTraits<NavigationGesture> {
252 typedef NavigationGesture param_type;
253 static void Write(Message* m, const param_type& p) {
254 m->WriteInt(p);
255 }
256 static bool Read(const Message* m, void** iter, param_type* p) {
257 int type;
258 if (!m->ReadInt(iter, &type))
259 return false;
260 *p = static_cast<NavigationGesture>(type);
261 return true;
262 }
263 static void Log(const param_type& p, std::string* l) {
264 std::string event;
265 switch (p) {
266 case NavigationGestureUser:
267 event = "GESTURE_USER";
268 break;
269 case NavigationGestureAuto:
270 event = "GESTURE_AUTO";
271 break;
272 default:
273 event = "GESTURE_UNKNOWN";
274 break;
275 }
276 LogParam(event, l);
277 }
278 };
279
280 template <>
281 struct ParamTraits<WindowContainerType> {
282 typedef WindowContainerType param_type;
283 static void Write(Message* m, const param_type& p) {
284 int val = static_cast<int>(p);
285 WriteParam(m, val);
286 }
287 static bool Read(const Message* m, void** iter, param_type* p) {
288 int val = 0;
289 if (!ReadParam(m, iter, &val) ||
290 val < WINDOW_CONTAINER_TYPE_NORMAL ||
291 val >= WINDOW_CONTAINER_TYPE_MAX_VALUE)
292 return false;
293 *p = static_cast<param_type>(val);
294 return true;
295 }
296 static void Log(const param_type& p, std::string* l) {
297 ParamTraits<int>::Log(static_cast<int>(p), l);
298 }
299 };
300
301 template <> 206 template <>
302 struct ParamTraits<Extension::Location> { 207 struct ParamTraits<Extension::Location> {
303 typedef Extension::Location param_type; 208 typedef Extension::Location param_type;
304 static void Write(Message* m, const param_type& p) { 209 static void Write(Message* m, const param_type& p) {
305 int val = static_cast<int>(p); 210 int val = static_cast<int>(p);
306 WriteParam(m, val); 211 WriteParam(m, val);
307 } 212 }
308 static bool Read(const Message* m, void** iter, param_type* p) { 213 static bool Read(const Message* m, void** iter, param_type* p) {
309 int val = 0; 214 int val = 0;
310 if (!ReadParam(m, iter, &val) || 215 if (!ReadParam(m, iter, &val) ||
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 state = "ViewHostMsg_GetSearchProviderInstallState_Params::" 318 state = "ViewHostMsg_GetSearchProviderInstallState_Params::"
414 "INSTALLED_AS_DEFAULT"; 319 "INSTALLED_AS_DEFAULT";
415 break; 320 break;
416 default: 321 default:
417 state = "UNKNOWN"; 322 state = "UNKNOWN";
418 break; 323 break;
419 } 324 }
420 LogParam(state, l); 325 LogParam(state, l);
421 } 326 }
422 327
423 void ParamTraits<ViewHostMsg_FrameNavigate_Params>::Write(Message* m,
424 const param_type& p) {
425 WriteParam(m, p.page_id);
426 WriteParam(m, p.frame_id);
427 WriteParam(m, p.url);
428 WriteParam(m, p.referrer);
429 WriteParam(m, p.transition);
430 WriteParam(m, p.redirects);
431 WriteParam(m, p.should_update_history);
432 WriteParam(m, p.searchable_form_url);
433 WriteParam(m, p.searchable_form_encoding);
434 WriteParam(m, p.password_form);
435 WriteParam(m, p.security_info);
436 WriteParam(m, p.gesture);
437 WriteParam(m, p.contents_mime_type);
438 WriteParam(m, p.is_post);
439 WriteParam(m, p.was_within_same_page);
440 WriteParam(m, p.http_status_code);
441 WriteParam(m, p.socket_address);
442 WriteParam(m, p.was_fetched_via_proxy);
443 WriteParam(m, p.content_state);
444 }
445
446 bool ParamTraits<ViewHostMsg_FrameNavigate_Params>::Read(const Message* m,
447 void** iter,
448 param_type* p) {
449 return
450 ReadParam(m, iter, &p->page_id) &&
451 ReadParam(m, iter, &p->frame_id) &&
452 ReadParam(m, iter, &p->url) &&
453 ReadParam(m, iter, &p->referrer) &&
454 ReadParam(m, iter, &p->transition) &&
455 ReadParam(m, iter, &p->redirects) &&
456 ReadParam(m, iter, &p->should_update_history) &&
457 ReadParam(m, iter, &p->searchable_form_url) &&
458 ReadParam(m, iter, &p->searchable_form_encoding) &&
459 ReadParam(m, iter, &p->password_form) &&
460 ReadParam(m, iter, &p->security_info) &&
461 ReadParam(m, iter, &p->gesture) &&
462 ReadParam(m, iter, &p->contents_mime_type) &&
463 ReadParam(m, iter, &p->is_post) &&
464 ReadParam(m, iter, &p->was_within_same_page) &&
465 ReadParam(m, iter, &p->http_status_code) &&
466 ReadParam(m, iter, &p->socket_address) &&
467 ReadParam(m, iter, &p->was_fetched_via_proxy) &&
468 ReadParam(m, iter, &p->content_state);
469 }
470
471 void ParamTraits<ViewHostMsg_FrameNavigate_Params>::Log(const param_type& p,
472 std::string* l) {
473 l->append("(");
474 LogParam(p.page_id, l);
475 l->append(", ");
476 LogParam(p.frame_id, l);
477 l->append(", ");
478 LogParam(p.url, l);
479 l->append(", ");
480 LogParam(p.referrer, l);
481 l->append(", ");
482 LogParam(p.transition, l);
483 l->append(", ");
484 LogParam(p.redirects, l);
485 l->append(", ");
486 LogParam(p.should_update_history, l);
487 l->append(", ");
488 LogParam(p.searchable_form_url, l);
489 l->append(", ");
490 LogParam(p.searchable_form_encoding, l);
491 l->append(", ");
492 LogParam(p.password_form, l);
493 l->append(", ");
494 LogParam(p.security_info, l);
495 l->append(", ");
496 LogParam(p.gesture, l);
497 l->append(", ");
498 LogParam(p.contents_mime_type, l);
499 l->append(", ");
500 LogParam(p.is_post, l);
501 l->append(", ");
502 LogParam(p.was_within_same_page, l);
503 l->append(", ");
504 LogParam(p.http_status_code, l);
505 l->append(", ");
506 LogParam(p.socket_address, l);
507 l->append(", ");
508 LogParam(p.was_fetched_via_proxy, l);
509 l->append(")");
510 }
511
512 void ParamTraits<ViewHostMsg_UpdateRect_Params>::Write(
513 Message* m, const param_type& p) {
514 WriteParam(m, p.bitmap);
515 WriteParam(m, p.bitmap_rect);
516 WriteParam(m, p.dx);
517 WriteParam(m, p.dy);
518 WriteParam(m, p.scroll_rect);
519 WriteParam(m, p.scroll_offset);
520 WriteParam(m, p.copy_rects);
521 WriteParam(m, p.view_size);
522 WriteParam(m, p.resizer_rect);
523 WriteParam(m, p.plugin_window_moves);
524 WriteParam(m, p.flags);
525 }
526
527 bool ParamTraits<ViewHostMsg_UpdateRect_Params>::Read(
528 const Message* m, void** iter, param_type* p) {
529 return
530 ReadParam(m, iter, &p->bitmap) &&
531 ReadParam(m, iter, &p->bitmap_rect) &&
532 ReadParam(m, iter, &p->dx) &&
533 ReadParam(m, iter, &p->dy) &&
534 ReadParam(m, iter, &p->scroll_rect) &&
535 ReadParam(m, iter, &p->scroll_offset) &&
536 ReadParam(m, iter, &p->copy_rects) &&
537 ReadParam(m, iter, &p->view_size) &&
538 ReadParam(m, iter, &p->resizer_rect) &&
539 ReadParam(m, iter, &p->plugin_window_moves) &&
540 ReadParam(m, iter, &p->flags);
541 }
542
543 void ParamTraits<ViewHostMsg_UpdateRect_Params>::Log(const param_type& p,
544 std::string* l) {
545 l->append("(");
546 LogParam(p.bitmap, l);
547 l->append(", ");
548 LogParam(p.bitmap_rect, l);
549 l->append(", ");
550 LogParam(p.dx, l);
551 l->append(", ");
552 LogParam(p.dy, l);
553 l->append(", ");
554 LogParam(p.scroll_rect, l);
555 l->append(", ");
556 LogParam(p.copy_rects, l);
557 l->append(", ");
558 LogParam(p.view_size, l);
559 l->append(", ");
560 LogParam(p.resizer_rect, l);
561 l->append(", ");
562 LogParam(p.plugin_window_moves, l);
563 l->append(", ");
564 LogParam(p.flags, l);
565 l->append(")");
566 }
567
568 void ParamTraits<ViewMsg_Print_Params>::Write(Message* m, const param_type& p) { 328 void ParamTraits<ViewMsg_Print_Params>::Write(Message* m, const param_type& p) {
569 WriteParam(m, p.page_size); 329 WriteParam(m, p.page_size);
Tom Sepez 2011/03/23 17:32:53 Can these be macro-ized?
570 WriteParam(m, p.printable_size); 330 WriteParam(m, p.printable_size);
571 WriteParam(m, p.margin_top); 331 WriteParam(m, p.margin_top);
572 WriteParam(m, p.margin_left); 332 WriteParam(m, p.margin_left);
573 WriteParam(m, p.dpi); 333 WriteParam(m, p.dpi);
574 WriteParam(m, p.min_shrink); 334 WriteParam(m, p.min_shrink);
575 WriteParam(m, p.max_shrink); 335 WriteParam(m, p.max_shrink);
576 WriteParam(m, p.desired_dpi); 336 WriteParam(m, p.desired_dpi);
577 WriteParam(m, p.document_cookie); 337 WriteParam(m, p.document_cookie);
578 WriteParam(m, p.selection_only); 338 WriteParam(m, p.selection_only);
579 WriteParam(m, p.supports_alpha_blend); 339 WriteParam(m, p.supports_alpha_blend);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 ReadParam(m, iter, &p->is_javascript) && 505 ReadParam(m, iter, &p->is_javascript) &&
746 ReadParam(m, iter, &p->code) && 506 ReadParam(m, iter, &p->code) &&
747 ReadParam(m, iter, &p->all_frames); 507 ReadParam(m, iter, &p->all_frames);
748 } 508 }
749 509
750 void ParamTraits<ViewMsg_ExecuteCode_Params>::Log(const param_type& p, 510 void ParamTraits<ViewMsg_ExecuteCode_Params>::Log(const param_type& p,
751 std::string* l) { 511 std::string* l) {
752 l->append("<ViewMsg_ExecuteCode_Params>"); 512 l->append("<ViewMsg_ExecuteCode_Params>");
753 } 513 }
754 514
755 void ParamTraits<ViewHostMsg_CreateWindow_Params>::Write(Message* m,
756 const param_type& p) {
757 WriteParam(m, p.opener_id);
758 WriteParam(m, p.user_gesture);
759 WriteParam(m, p.window_container_type);
760 WriteParam(m, p.session_storage_namespace_id);
761 WriteParam(m, p.frame_name);
762 WriteParam(m, p.opener_frame_id);
763 WriteParam(m, p.opener_url);
764 WriteParam(m, p.opener_security_origin);
765 WriteParam(m, p.target_url);
766 }
767
768 bool ParamTraits<ViewHostMsg_CreateWindow_Params>::Read(const Message* m,
769 void** iter,
770 param_type* p) {
771 return
772 ReadParam(m, iter, &p->opener_id) &&
773 ReadParam(m, iter, &p->user_gesture) &&
774 ReadParam(m, iter, &p->window_container_type) &&
775 ReadParam(m, iter, &p->session_storage_namespace_id) &&
776 ReadParam(m, iter, &p->frame_name) &&
777 ReadParam(m, iter, &p->opener_frame_id) &&
778 ReadParam(m, iter, &p->opener_url) &&
779 ReadParam(m, iter, &p->opener_security_origin) &&
780 ReadParam(m, iter, &p->target_url);
781 }
782
783 void ParamTraits<ViewHostMsg_CreateWindow_Params>::Log(const param_type& p,
784 std::string* l) {
785 l->append("(");
786 LogParam(p.opener_id, l);
787 l->append(", ");
788 LogParam(p.user_gesture, l);
789 l->append(", ");
790 LogParam(p.window_container_type, l);
791 l->append(", ");
792 LogParam(p.session_storage_namespace_id, l);
793 l->append(", ");
794 LogParam(p.frame_name, l);
795 l->append(", ");
796 LogParam(p.opener_frame_id, l);
797 l->append(", ");
798 LogParam(p.opener_url, l);
799 l->append(", ");
800 LogParam(p.opener_security_origin, l);
801 l->append(", ");
802 LogParam(p.target_url, l);
803 l->append(")");
804 }
805
806 void ParamTraits<ViewHostMsg_RunFileChooser_Params>::Write(
807 Message* m,
808 const param_type& p) {
809 WriteParam(m, static_cast<int>(p.mode));
810 WriteParam(m, p.title);
811 WriteParam(m, p.default_file_name);
812 WriteParam(m, p.accept_types);
813 }
814
815 bool ParamTraits<ViewHostMsg_RunFileChooser_Params>::Read(
816 const Message* m,
817 void** iter,
818 param_type* p) {
819 int mode;
820 if (!ReadParam(m, iter, &mode))
821 return false;
822 if (mode != param_type::Open &&
823 mode != param_type::OpenMultiple &&
824 mode != param_type::OpenFolder &&
825 mode != param_type::Save)
826 return false;
827 p->mode = static_cast<param_type::Mode>(mode);
828 return
829 ReadParam(m, iter, &p->title) &&
830 ReadParam(m, iter, &p->default_file_name) &&
831 ReadParam(m, iter, &p->accept_types);
832 };
833
834 void ParamTraits<ViewHostMsg_RunFileChooser_Params>::Log(
835 const param_type& p,
836 std::string* l) {
837 switch (p.mode) {
838 case param_type::Open:
839 l->append("(Open, ");
840 break;
841 case param_type::OpenMultiple:
842 l->append("(OpenMultiple, ");
843 break;
844 case param_type::OpenFolder:
845 l->append("(OpenFolder, ");
846 break;
847 case param_type::Save:
848 l->append("(Save, ");
849 break;
850 default:
851 l->append("(UNKNOWN, ");
852 }
853 LogParam(p.title, l);
854 l->append(", ");
855 LogParam(p.default_file_name, l);
856 l->append(", ");
857 LogParam(p.accept_types, l);
858 }
859
860 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Write(Message* m, 515 void ParamTraits<ViewMsg_ExtensionLoaded_Params>::Write(Message* m,
861 const param_type& p) { 516 const param_type& p) {
862 WriteParam(m, p.location); 517 WriteParam(m, p.location);
863 WriteParam(m, p.path); 518 WriteParam(m, p.path);
864 WriteParam(m, *(p.manifest)); 519 WriteParam(m, *(p.manifest));
865 } 520 }
866 521
867 bool ParamTraits<ViewMsg_ExtensionLoaded_Params>::Read(const Message* m, 522 bool ParamTraits<ViewMsg_ExtensionLoaded_Params>::Read(const Message* m,
868 void** iter, 523 void** iter,
869 param_type* p) { 524 param_type* p) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 l->append(", "); 647 l->append(", ");
993 LogParam(p.tag_name, l); 648 LogParam(p.tag_name, l);
994 l->append(", "); 649 l->append(", ");
995 LogParam(p.parent, l); 650 LogParam(p.parent, l);
996 l->append(", "); 651 l->append(", ");
997 LogParam(p.children, l); 652 LogParam(p.children, l);
998 l->append(")"); 653 l->append(")");
999 } 654 }
1000 655
1001 } // namespace IPC 656 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698