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

Side by Side Diff: chrome/browser/ui/views/toolbar/wrench_menu.cc

Issue 1003853004: MacViews: Gets wrench menu working (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@grd
Patch Set: Created 5 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
« no previous file with comments | « chrome/browser/ui/views/toolbar/wrench_menu.h ('k') | ui/base/models/button_menu_item_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/ui/views/toolbar/wrench_menu.h" 5 #include "chrome/browser/ui/views/toolbar/wrench_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <set> 9 #include <set>
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #include "ui/views/controls/menu/menu_item_view.h" 57 #include "ui/views/controls/menu/menu_item_view.h"
58 #include "ui/views/controls/menu/menu_model_adapter.h" 58 #include "ui/views/controls/menu/menu_model_adapter.h"
59 #include "ui/views/controls/menu/menu_runner.h" 59 #include "ui/views/controls/menu/menu_runner.h"
60 #include "ui/views/controls/menu/menu_scroll_view_container.h" 60 #include "ui/views/controls/menu/menu_scroll_view_container.h"
61 #include "ui/views/controls/menu/submenu_view.h" 61 #include "ui/views/controls/menu/submenu_view.h"
62 #include "ui/views/widget/widget.h" 62 #include "ui/views/widget/widget.h"
63 63
64 using base::UserMetricsAction; 64 using base::UserMetricsAction;
65 using bookmarks::BookmarkModel; 65 using bookmarks::BookmarkModel;
66 using content::WebContents; 66 using content::WebContents;
67 using ui::ButtonMenuItemModel;
67 using ui::MenuModel; 68 using ui::MenuModel;
68 using views::CustomButton; 69 using views::CustomButton;
69 using views::ImageButton; 70 using views::ImageButton;
70 using views::Label; 71 using views::Label;
71 using views::LabelButton; 72 using views::LabelButton;
72 using views::MenuConfig; 73 using views::MenuConfig;
73 using views::MenuItemView; 74 using views::MenuItemView;
74 using views::View; 75 using views::View;
75 76
76 namespace { 77 namespace {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 const ButtonType type_; 232 const ButtonType type_;
232 233
233 // See description above setter for details. 234 // See description above setter for details.
234 const CustomButton* left_button_; 235 const CustomButton* left_button_;
235 const CustomButton* right_button_; 236 const CustomButton* right_button_;
236 237
237 DISALLOW_COPY_AND_ASSIGN(InMenuButtonBackground); 238 DISALLOW_COPY_AND_ASSIGN(InMenuButtonBackground);
238 }; 239 };
239 240
240 base::string16 GetAccessibleNameForWrenchMenuItem( 241 base::string16 GetAccessibleNameForWrenchMenuItem(
241 MenuModel* model, int item_index, int accessible_string_id) { 242 ButtonMenuItemModel* model, int item_index, int accessible_string_id) {
242 base::string16 accessible_name = 243 base::string16 accessible_name =
243 l10n_util::GetStringUTF16(accessible_string_id); 244 l10n_util::GetStringUTF16(accessible_string_id);
244 base::string16 accelerator_text; 245 base::string16 accelerator_text;
245 246
246 ui::Accelerator menu_accelerator; 247 ui::Accelerator menu_accelerator;
247 if (model->GetAcceleratorAt(item_index, &menu_accelerator)) { 248 if (model->GetAcceleratorAt(item_index, &menu_accelerator)) {
248 accelerator_text = 249 accelerator_text =
249 ui::Accelerator(menu_accelerator.key_code(), 250 ui::Accelerator(menu_accelerator.key_code(),
250 menu_accelerator.modifiers()).GetShortcutText(); 251 menu_accelerator.modifiers()).GetShortcutText();
251 } 252 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 InMenuButtonBackground* in_menu_background_; 308 InMenuButtonBackground* in_menu_background_;
308 309
309 DISALLOW_COPY_AND_ASSIGN(InMenuButton); 310 DISALLOW_COPY_AND_ASSIGN(InMenuButton);
310 }; 311 };
311 312
312 // WrenchMenuView is a view that can contain label buttons. 313 // WrenchMenuView is a view that can contain label buttons.
313 class WrenchMenuView : public views::View, 314 class WrenchMenuView : public views::View,
314 public views::ButtonListener, 315 public views::ButtonListener,
315 public WrenchMenuObserver { 316 public WrenchMenuObserver {
316 public: 317 public:
317 WrenchMenuView(WrenchMenu* menu, MenuModel* menu_model) 318 WrenchMenuView(WrenchMenu* menu, ButtonMenuItemModel* menu_model)
318 : menu_(menu), 319 : menu_(menu),
319 menu_model_(menu_model) { 320 menu_model_(menu_model) {
320 menu_->AddObserver(this); 321 menu_->AddObserver(this);
321 } 322 }
322 323
323 ~WrenchMenuView() override { 324 ~WrenchMenuView() override {
324 if (menu_) 325 if (menu_)
325 menu_->RemoveObserver(this); 326 menu_->RemoveObserver(this);
326 } 327 }
327 328
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 367
367 // Overridden from WrenchMenuObserver: 368 // Overridden from WrenchMenuObserver:
368 void WrenchMenuDestroyed() override { 369 void WrenchMenuDestroyed() override {
369 menu_->RemoveObserver(this); 370 menu_->RemoveObserver(this);
370 menu_ = NULL; 371 menu_ = NULL;
371 menu_model_ = NULL; 372 menu_model_ = NULL;
372 } 373 }
373 374
374 protected: 375 protected:
375 WrenchMenu* menu() { return menu_; } 376 WrenchMenu* menu() { return menu_; }
376 MenuModel* menu_model() { return menu_model_; } 377 ButtonMenuItemModel* menu_model() { return menu_model_; }
377 378
378 private: 379 private:
379 // Hosting WrenchMenu. 380 // Hosting WrenchMenu.
380 // WARNING: this may be NULL during shutdown. 381 // WARNING: this may be NULL during shutdown.
381 WrenchMenu* menu_; 382 WrenchMenu* menu_;
382 383
383 // The menu model containing the increment/decrement/reset items. 384 // The menu model containing the increment/decrement/reset items.
384 // WARNING: this may be NULL during shutdown. 385 // WARNING: this may be NULL during shutdown.
385 MenuModel* menu_model_; 386 ButtonMenuItemModel* menu_model_;
386 387
387 DISALLOW_COPY_AND_ASSIGN(WrenchMenuView); 388 DISALLOW_COPY_AND_ASSIGN(WrenchMenuView);
388 }; 389 };
389 390
390 // Generate the button image for hover state. 391 // Generate the button image for hover state.
391 class HoveredImageSource : public gfx::ImageSkiaSource { 392 class HoveredImageSource : public gfx::ImageSkiaSource {
392 public: 393 public:
393 HoveredImageSource(const gfx::ImageSkia& image, SkColor color) 394 HoveredImageSource(const gfx::ImageSkia& image, SkColor color)
394 : image_(image), 395 : image_(image),
395 color_(color) { 396 color_(color) {
(...skipping 27 matching lines...) Expand all
423 }; 424 };
424 425
425 } // namespace 426 } // namespace
426 427
427 // CutCopyPasteView ------------------------------------------------------------ 428 // CutCopyPasteView ------------------------------------------------------------
428 429
429 // CutCopyPasteView is the view containing the cut/copy/paste buttons. 430 // CutCopyPasteView is the view containing the cut/copy/paste buttons.
430 class WrenchMenu::CutCopyPasteView : public WrenchMenuView { 431 class WrenchMenu::CutCopyPasteView : public WrenchMenuView {
431 public: 432 public:
432 CutCopyPasteView(WrenchMenu* menu, 433 CutCopyPasteView(WrenchMenu* menu,
433 MenuModel* menu_model, 434 ButtonMenuItemModel* menu_model,
434 int cut_index, 435 int cut_index,
435 int copy_index, 436 int copy_index,
436 int paste_index) 437 int paste_index)
437 : WrenchMenuView(menu, menu_model) { 438 : WrenchMenuView(menu, menu_model) {
438 InMenuButton* cut = CreateAndConfigureButton( 439 InMenuButton* cut = CreateAndConfigureButton(
439 IDS_CUT, InMenuButtonBackground::LEFT_BUTTON, cut_index); 440 IDS_CUT, InMenuButtonBackground::LEFT_BUTTON, cut_index);
440 InMenuButton* copy = CreateAndConfigureButton( 441 InMenuButton* copy = CreateAndConfigureButton(
441 IDS_COPY, InMenuButtonBackground::CENTER_BUTTON, copy_index); 442 IDS_COPY, InMenuButtonBackground::CENTER_BUTTON, copy_index);
442 InMenuButton* paste = CreateAndConfigureButton( 443 InMenuButton* paste = CreateAndConfigureButton(
443 IDS_PASTE, InMenuButtonBackground::CENTER_BUTTON, paste_index); 444 IDS_PASTE, InMenuButtonBackground::CENTER_BUTTON, paste_index);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 478
478 // ZoomView -------------------------------------------------------------------- 479 // ZoomView --------------------------------------------------------------------
479 480
480 481
481 // ZoomView contains the various zoom controls: two buttons to increase/decrease 482 // ZoomView contains the various zoom controls: two buttons to increase/decrease
482 // the zoom, a label showing the current zoom percent, and a button to go 483 // the zoom, a label showing the current zoom percent, and a button to go
483 // full-screen. 484 // full-screen.
484 class WrenchMenu::ZoomView : public WrenchMenuView { 485 class WrenchMenu::ZoomView : public WrenchMenuView {
485 public: 486 public:
486 ZoomView(WrenchMenu* menu, 487 ZoomView(WrenchMenu* menu,
487 MenuModel* menu_model, 488 ButtonMenuItemModel* menu_model,
488 int decrement_index, 489 int decrement_index,
489 int increment_index, 490 int increment_index,
490 int fullscreen_index) 491 int fullscreen_index)
491 : WrenchMenuView(menu, menu_model), 492 : WrenchMenuView(menu, menu_model),
492 fullscreen_index_(fullscreen_index), 493 fullscreen_index_(fullscreen_index),
493 increment_button_(NULL), 494 increment_button_(NULL),
494 zoom_label_(NULL), 495 zoom_label_(NULL),
495 decrement_button_(NULL), 496 decrement_button_(NULL),
496 fullscreen_button_(NULL), 497 fullscreen_button_(NULL),
497 zoom_label_width_(0) { 498 zoom_label_width_(0) {
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 views::MENU_ANCHOR_TOPRIGHT, 845 views::MENU_ANCHOR_TOPRIGHT,
845 ui::MENU_SOURCE_NONE) == 846 ui::MENU_SOURCE_NONE) ==
846 views::MenuRunner::MENU_DELETED) 847 views::MenuRunner::MENU_DELETED)
847 return; 848 return;
848 if (bookmark_menu_delegate_.get()) { 849 if (bookmark_menu_delegate_.get()) {
849 BookmarkModel* model = BookmarkModelFactory::GetForProfile( 850 BookmarkModel* model = BookmarkModelFactory::GetForProfile(
850 browser_->profile()); 851 browser_->profile());
851 if (model) 852 if (model)
852 model->RemoveObserver(this); 853 model->RemoveObserver(this);
853 } 854 }
854 if (selected_menu_model_) 855 if (selected_menu_model_) {
855 selected_menu_model_->ActivatedAt(selected_index_); 856 selected_menu_model_->ActivatedAt(selected_index_);
857 }
856 } 858 }
857 859
858 void WrenchMenu::CloseMenu() { 860 void WrenchMenu::CloseMenu() {
859 if (menu_runner_.get()) 861 if (menu_runner_.get())
860 menu_runner_->Cancel(); 862 menu_runner_->Cancel();
861 } 863 }
862 864
863 bool WrenchMenu::IsShowing() { 865 bool WrenchMenu::IsShowing() {
864 return menu_runner_.get() && menu_runner_->IsRunning(); 866 return menu_runner_.get() && menu_runner_->IsRunning();
865 } 867 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 bool WrenchMenu::IsCommandEnabled(int command_id) const { 990 bool WrenchMenu::IsCommandEnabled(int command_id) const {
989 if (IsBookmarkCommand(command_id)) 991 if (IsBookmarkCommand(command_id))
990 return true; 992 return true;
991 993
992 if (command_id == 0) 994 if (command_id == 0)
993 return false; // The root item. 995 return false; // The root item.
994 996
995 // The items representing the cut menu (cut/copy/paste), zoom menu 997 // The items representing the cut menu (cut/copy/paste), zoom menu
996 // (increment/decrement/reset) and extension toolbar view are always enabled. 998 // (increment/decrement/reset) and extension toolbar view are always enabled.
997 // The child views of these items enabled state updates appropriately. 999 // The child views of these items enabled state updates appropriately.
998 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || 1000 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU ||
1001 command_id == IDC_MORE_TOOLS_MENU ||
999 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) 1002 command_id == IDC_EXTENSIONS_OVERFLOW_MENU)
1000 return true; 1003 return true;
1001 1004
1002 const Entry& entry = command_id_to_entry_.find(command_id)->second; 1005 const Entry& entry = command_id_to_entry_.find(command_id)->second;
1003 return entry.first->IsEnabledAt(entry.second); 1006 return entry.first->IsEnabledAt(entry.second);
1004 } 1007 }
1005 1008
1006 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { 1009 void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) {
1007 if (IsBookmarkCommand(command_id)) { 1010 if (IsBookmarkCommand(command_id)) {
1008 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenBookmark", 1011 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenBookmark",
1009 menu_opened_timer_.Elapsed()); 1012 menu_opened_timer_.Elapsed());
1010 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", 1013 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction",
1011 MENU_ACTION_BOOKMARK_OPEN, LIMIT_MENU_ACTION); 1014 MENU_ACTION_BOOKMARK_OPEN, LIMIT_MENU_ACTION);
1012 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags); 1015 bookmark_menu_delegate_->ExecuteCommand(command_id, mouse_event_flags);
1013 return; 1016 return;
1014 } 1017 }
1015 1018
1016 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || 1019 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU ||
1020 command_id == IDC_MORE_TOOLS_MENU ||
1017 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { 1021 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) {
1018 // These items are represented by child views. If ExecuteCommand is invoked 1022 // These items are represented by child views. If ExecuteCommand is invoked
1019 // it means the user clicked on the area around the buttons and we should 1023 // it means the user clicked on the area around the buttons and we should
1020 // not do anyting. 1024 // not do anyting.
1021 return; 1025 return;
1022 } 1026 }
1023 1027
1024 const Entry& entry = command_id_to_entry_.find(command_id)->second; 1028 const Entry& entry = command_id_to_entry_.find(command_id)->second;
1025 return entry.first->ActivatedAt(entry.second, mouse_event_flags); 1029 return entry.first->ActivatedAt(entry.second, mouse_event_flags);
1026 } 1030 }
1027 1031
1028 bool WrenchMenu::GetAccelerator(int command_id, 1032 bool WrenchMenu::GetAccelerator(int command_id,
1029 ui::Accelerator* accelerator) const { 1033 ui::Accelerator* accelerator) const {
1030 if (IsBookmarkCommand(command_id)) 1034 if (IsBookmarkCommand(command_id))
1031 return false; 1035 return false;
1032 1036
1033 if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || 1037 if (command_id == IDC_EDIT_MENU || command_id == IDC_ZOOM_MENU ||
1038 command_id == IDC_MORE_TOOLS_MENU ||
1034 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { 1039 command_id == IDC_EXTENSIONS_OVERFLOW_MENU) {
1035 // These have special child views; don't show the accelerator for them. 1040 // These have special child views; don't show the accelerator for them.
1036 return false; 1041 return false;
1037 } 1042 }
1038 1043
1039 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1044 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1040 const Entry& entry = ix->second; 1045 const Entry& entry = ix->second;
1041 ui::Accelerator menu_accelerator; 1046 ui::Accelerator menu_accelerator;
1042 if (!entry.first->GetAcceleratorAt(entry.second, &menu_accelerator)) 1047 if (!entry.first->GetAcceleratorAt(entry.second, &menu_accelerator))
1043 return false; 1048 return false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 1099
1095 void WrenchMenu::PopulateMenu(MenuItemView* parent, 1100 void WrenchMenu::PopulateMenu(MenuItemView* parent,
1096 MenuModel* model) { 1101 MenuModel* model) {
1097 for (int i = 0, max = model->GetItemCount(); i < max; ++i) { 1102 for (int i = 0, max = model->GetItemCount(); i < max; ++i) {
1098 // Add the menu item at the end. 1103 // Add the menu item at the end.
1099 int menu_index = parent->HasSubmenu() ? 1104 int menu_index = parent->HasSubmenu() ?
1100 parent->GetSubmenu()->child_count() : 0; 1105 parent->GetSubmenu()->child_count() : 0;
1101 MenuItemView* item = 1106 MenuItemView* item =
1102 AddMenuItem(parent, menu_index, model, i, model->GetTypeAt(i)); 1107 AddMenuItem(parent, menu_index, model, i, model->GetTypeAt(i));
1103 1108
1104 if (model->GetCommandIdAt(i) == IDC_CUT || 1109 if (model->GetCommandIdAt(i) == IDC_EDIT_MENU ||
1105 model->GetCommandIdAt(i) == IDC_ZOOM_MINUS) { 1110 model->GetCommandIdAt(i) == IDC_ZOOM_MENU ||
1111 model->GetCommandIdAt(i) == IDC_MORE_TOOLS_MENU) {
1106 const MenuConfig& config = item->GetMenuConfig(); 1112 const MenuConfig& config = item->GetMenuConfig();
1107 int top_margin = config.item_top_margin + config.separator_height / 2; 1113 int top_margin = config.item_top_margin + config.separator_height / 2;
1108 int bottom_margin = 1114 int bottom_margin =
1109 config.item_bottom_margin + config.separator_height / 2; 1115 config.item_bottom_margin + config.separator_height / 2;
1110 1116
1111 // Chromeos adds extra vertical space for the menu buttons. 1117 // Chromeos adds extra vertical space for the menu buttons.
1112 #if defined(OS_CHROMEOS) 1118 #if defined(OS_CHROMEOS)
1113 top_margin += 4; 1119 top_margin += 4;
1114 bottom_margin += 5; 1120 bottom_margin += 5;
1115 #endif 1121 #endif
1116 1122
1117 item->SetMargins(top_margin, bottom_margin); 1123 item->SetMargins(top_margin, bottom_margin);
1118 } 1124 }
1119 1125
1120 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU) 1126 if (model->GetTypeAt(i) == MenuModel::TYPE_SUBMENU)
1121 PopulateMenu(item, model->GetSubmenuModelAt(i)); 1127 PopulateMenu(item, model->GetSubmenuModelAt(i));
1122 1128
1123 switch (model->GetCommandIdAt(i)) { 1129 switch (model->GetCommandIdAt(i)) {
1124 case IDC_EXTENSIONS_OVERFLOW_MENU: { 1130 case IDC_EXTENSIONS_OVERFLOW_MENU: {
1125 scoped_ptr<ExtensionToolbarMenuView> extension_toolbar( 1131 scoped_ptr<ExtensionToolbarMenuView> extension_toolbar(
1126 new ExtensionToolbarMenuView(browser_, this)); 1132 new ExtensionToolbarMenuView(browser_, this));
1127 if (extension_toolbar->ShouldShow()) 1133 if (extension_toolbar->ShouldShow())
1128 item->AddChildView(extension_toolbar.release()); 1134 item->AddChildView(extension_toolbar.release());
1129 else 1135 else
1130 item->SetVisible(false); 1136 item->SetVisible(false);
1131 break; 1137 break;
1132 } 1138 }
1133 1139
1134 case IDC_CUT: 1140 case IDC_EDIT_MENU: {
1135 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); 1141 ui::ButtonMenuItemModel* submodel = model->GetButtonMenuItemAt(i);
1136 DCHECK_LT(i + 2, max); 1142 DCHECK_EQ(IDC_CUT, submodel->GetCommandIdAt(0));
1137 DCHECK_EQ(IDC_COPY, model->GetCommandIdAt(i + 1)); 1143 DCHECK_EQ(IDC_COPY, submodel->GetCommandIdAt(1));
1138 DCHECK_EQ(IDC_PASTE, model->GetCommandIdAt(i + 2)); 1144 DCHECK_EQ(IDC_PASTE, submodel->GetCommandIdAt(2));
1139 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2)); 1145 item->SetTitle(l10n_util::GetStringUTF16(IDS_EDIT2));
1140 item->AddChildView(new CutCopyPasteView(this, model, 1146 item->AddChildView(new CutCopyPasteView(this, submodel, 0, 1, 2));
1141 i, i + 1, i + 2));
1142 i += 2;
1143 break; 1147 break;
1148 }
1144 1149
1145 case IDC_ZOOM_MINUS: 1150 case IDC_ZOOM_MENU: {
1146 DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); 1151 ui::ButtonMenuItemModel* submodel = model->GetButtonMenuItemAt(i);
1147 DCHECK_EQ(IDC_ZOOM_PLUS, model->GetCommandIdAt(i + 1)); 1152 DCHECK_EQ(IDC_ZOOM_MINUS, submodel->GetCommandIdAt(0));
1148 DCHECK_EQ(IDC_FULLSCREEN, model->GetCommandIdAt(i + 2)); 1153 DCHECK_EQ(IDC_ZOOM_PLUS, submodel->GetCommandIdAt(1));
1154 DCHECK_EQ(IDC_FULLSCREEN, submodel->GetCommandIdAt(2));
1149 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2)); 1155 item->SetTitle(l10n_util::GetStringUTF16(IDS_ZOOM_MENU2));
1150 item->AddChildView(new ZoomView(this, model, i, i + 1, i + 2)); 1156 item->AddChildView(new ZoomView(this, submodel, 0, 1, 2));
1151 i += 2;
1152 break; 1157 break;
1158 }
1153 1159
1154 case IDC_BOOKMARKS_MENU: 1160 case IDC_BOOKMARKS_MENU:
1155 DCHECK(!bookmark_menu_); 1161 DCHECK(!bookmark_menu_);
1156 bookmark_menu_ = item; 1162 bookmark_menu_ = item;
1157 break; 1163 break;
1158 1164
1159 #if defined(GOOGLE_CHROME_BUILD) 1165 #if defined(GOOGLE_CHROME_BUILD)
1160 case IDC_FEEDBACK: 1166 case IDC_FEEDBACK:
1161 DCHECK(!feedback_menu_item_); 1167 DCHECK(!feedback_menu_item_);
1162 feedback_menu_item_ = item; 1168 feedback_menu_item_ = item;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) { 1222 if (menu_type == MenuModel::TYPE_COMMAND && model->HasIcons()) {
1217 gfx::Image icon; 1223 gfx::Image icon;
1218 if (model->GetIconAt(model_index, &icon)) 1224 if (model->GetIconAt(model_index, &icon))
1219 menu_item->SetIcon(*icon.ToImageSkia()); 1225 menu_item->SetIcon(*icon.ToImageSkia());
1220 } 1226 }
1221 } 1227 }
1222 1228
1223 return menu_item; 1229 return menu_item;
1224 } 1230 }
1225 1231
1226 void WrenchMenu::CancelAndEvaluate(MenuModel* model, int index) { 1232 void WrenchMenu::CancelAndEvaluate(ButtonMenuItemModel* model, int index) {
1227 selected_menu_model_ = model; 1233 selected_menu_model_ = model;
1228 selected_index_ = index; 1234 selected_index_ = index;
1229 root_->Cancel(); 1235 root_->Cancel();
1230 } 1236 }
1231 1237
1232 void WrenchMenu::CreateBookmarkMenu() { 1238 void WrenchMenu::CreateBookmarkMenu() {
1233 if (bookmark_menu_delegate_.get()) 1239 if (bookmark_menu_delegate_.get())
1234 return; // Already created the menu. 1240 return; // Already created the menu.
1235 1241
1236 BookmarkModel* model = 1242 BookmarkModel* model =
(...skipping 18 matching lines...) Expand all
1255 0, 1261 0,
1256 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1262 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1257 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU); 1263 BOOKMARK_LAUNCH_LOCATION_WRENCH_MENU);
1258 } 1264 }
1259 1265
1260 int WrenchMenu::ModelIndexFromCommandId(int command_id) const { 1266 int WrenchMenu::ModelIndexFromCommandId(int command_id) const {
1261 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1267 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1262 DCHECK(ix != command_id_to_entry_.end()); 1268 DCHECK(ix != command_id_to_entry_.end());
1263 return ix->second.second; 1269 return ix->second.second;
1264 } 1270 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar/wrench_menu.h ('k') | ui/base/models/button_menu_item_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698