Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

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

Issue 7167002: Convert RenderViewContextMenu to MenuItemView. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: clang build fix. Created 9 years, 5 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/common_param_traits.h" 5 #include "chrome/common/common_param_traits.h"
6 #include "content/common/common_param_traits.h" 6 #include "content/common/common_param_traits.h"
7 #include "ui/base/models/menu_model.h"
7 8
8 #define IPC_MESSAGE_IMPL 9 #define IPC_MESSAGE_IMPL
9 #include "chrome/common/automation_messages.h" 10 #include "chrome/common/automation_messages.h"
10 11
11 AutomationURLRequest::AutomationURLRequest() 12 AutomationURLRequest::AutomationURLRequest()
12 : resource_type(0), 13 : resource_type(0),
13 load_flags(0) { 14 load_flags(0) {
14 } 15 }
15 16
16 AutomationURLRequest::AutomationURLRequest( 17 AutomationURLRequest::AutomationURLRequest(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 screen_y(in_screen_y), 140 screen_y(in_screen_y),
140 link_url(in_link_url), 141 link_url(in_link_url),
141 unfiltered_link_url(in_unfiltered_link_url), 142 unfiltered_link_url(in_unfiltered_link_url),
142 src_url(in_src_url), 143 src_url(in_src_url),
143 page_url(in_page_url), 144 page_url(in_page_url),
144 frame_url(in_frame_url) { 145 frame_url(in_frame_url) {
145 } 146 }
146 147
147 MiniContextMenuParams::~MiniContextMenuParams() {} 148 MiniContextMenuParams::~MiniContextMenuParams() {}
148 149
150 ContextMenuModel::ContextMenuModel() {
151 }
152
153 ContextMenuModel::~ContextMenuModel() {
154 for (size_t i = 0; i < items.size(); ++i)
155 delete items[i].submenu;
156 }
157
158 ContextMenuModel::Item::Item()
159 : type(static_cast<int>(ui::MenuModel::TYPE_COMMAND)),
160 item_id(0),
161 checked(false),
162 enabled(true),
163 submenu(NULL) {
164 }
165
149 AttachExternalTabParams::AttachExternalTabParams() 166 AttachExternalTabParams::AttachExternalTabParams()
150 : cookie(0), 167 : cookie(0),
151 disposition(0), 168 disposition(0),
152 user_gesture(false) { 169 user_gesture(false) {
153 } 170 }
154 171
155 AttachExternalTabParams::AttachExternalTabParams( 172 AttachExternalTabParams::AttachExternalTabParams(
156 uint64 in_cookie, 173 uint64 in_cookie,
157 const GURL& in_url, 174 const GURL& in_url,
158 const gfx::Rect& in_dimensions, 175 const gfx::Rect& in_dimensions,
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 l->append(", "); 648 l->append(", ");
632 LogParam(p.src_url, l); 649 LogParam(p.src_url, l);
633 l->append(", "); 650 l->append(", ");
634 LogParam(p.page_url, l); 651 LogParam(p.page_url, l);
635 l->append(", "); 652 l->append(", ");
636 LogParam(p.frame_url, l); 653 LogParam(p.frame_url, l);
637 l->append(")"); 654 l->append(")");
638 } 655 }
639 656
640 // static 657 // static
658 void ParamTraits<ContextMenuModel>::Write(Message* m,
659 const param_type& p) {
660 WriteParam(m, p.items.size());
661 for (size_t i = 0; i < p.items.size(); ++i) {
662 WriteParam(m, static_cast<int>(p.items[i].type));
663 WriteParam(m, p.items[i].item_id);
664 WriteParam(m, p.items[i].label);
665 WriteParam(m, p.items[i].checked);
666 WriteParam(m, p.items[i].enabled);
667
668 if (p.items[i].type == static_cast<int>(ui::MenuModel::TYPE_SUBMENU)) {
669 Write(m, *p.items[i].submenu);
670 }
671 }
672 }
673
674 // static
675 bool ParamTraits<ContextMenuModel>::Read(const Message* m,
676 void** iter,
677 param_type* p) {
678 size_t item_count;
iyengar 2011/07/11 22:09:17 initialize to 0?. Easier for debugging.
rhashimoto 2011/07/11 22:38:58 Done.
679 if (!ReadParam(m, iter, &item_count))
680 return false;
681
682 p->items.reserve(item_count);
683 for (size_t i = 0; i < item_count; ++i) {
684 ContextMenuModel::Item item;
685 if (!ReadParam(m, iter, &item.type))
686 return false;
687 if (!ReadParam(m, iter, &item.item_id))
688 return false;
689 if (!ReadParam(m, iter, &item.label))
690 return false;
691 if (!ReadParam(m, iter, &item.checked))
692 return false;
693 if (!ReadParam(m, iter, &item.enabled))
694 return false;
695
696 if (item.type == static_cast<int>(ui::MenuModel::TYPE_SUBMENU)) {
697 item.submenu = new ContextMenuModel;
698 if (!Read(m, iter, item.submenu)) {
699 delete item.submenu;
700 item.submenu = NULL;
701 return false;
702 }
703 }
704
705 p->items.push_back(item);
706 }
707
708 return true;
709 }
710
711 // static
712 void ParamTraits<ContextMenuModel>::Log(const param_type& p,
713 std::string* l) {
714 l->append("(");
715 for (size_t i = 0; i < p.items.size(); ++i) {
716 const ContextMenuModel::Item& item = p.items[i];
717 if (i)
718 l->append(", ");
719 l->append("(");
720 LogParam(item.type, l);
721 l->append(", ");
722 LogParam(item.item_id, l);
723 l->append(", ");
724 LogParam(item.label, l);
725 l->append(", ");
726 LogParam(item.checked, l);
727 l->append(", ");
728 LogParam(item.enabled, l);
729 if (item.type == ui::MenuModel::TYPE_SUBMENU) {
730 l->append(", ");
731 Log(*item.submenu, l);
732 }
733 l->append(")");
734 }
735 l->append(")");
736 }
737
738 // static
641 void ParamTraits<AttachExternalTabParams>::Write(Message* m, 739 void ParamTraits<AttachExternalTabParams>::Write(Message* m,
642 const param_type& p) { 740 const param_type& p) {
643 WriteParam(m, p.cookie); 741 WriteParam(m, p.cookie);
644 WriteParam(m, p.url); 742 WriteParam(m, p.url);
645 WriteParam(m, p.dimensions); 743 WriteParam(m, p.dimensions);
646 WriteParam(m, p.disposition); 744 WriteParam(m, p.disposition);
647 WriteParam(m, p.user_gesture); 745 WriteParam(m, p.user_gesture);
648 WriteParam(m, p.profile_name); 746 WriteParam(m, p.profile_name);
649 } 747 }
650 748
(...skipping 21 matching lines...) Expand all
672 l->append(", "); 770 l->append(", ");
673 LogParam(p.disposition, l); 771 LogParam(p.disposition, l);
674 l->append(", "); 772 l->append(", ");
675 LogParam(p.user_gesture, l); 773 LogParam(p.user_gesture, l);
676 l->append(","); 774 l->append(",");
677 LogParam(p.profile_name, l); 775 LogParam(p.profile_name, l);
678 l->append(")"); 776 l->append(")");
679 } 777 }
680 778
681 } // namespace IPC 779 } // namespace IPC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698