Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/wrench_menu.cc |
| diff --git a/chrome/browser/ui/views/toolbar/wrench_menu.cc b/chrome/browser/ui/views/toolbar/wrench_menu.cc |
| index b38dd1012736f58747466f026f1ada45cbdbe62e..ef21ffc7c9ce36991211db9bc053069909fc32e5 100644 |
| --- a/chrome/browser/ui/views/toolbar/wrench_menu.cc |
| +++ b/chrome/browser/ui/views/toolbar/wrench_menu.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| #include "chrome/browser/ui/views/bookmarks/bookmark_menu_delegate.h" |
| +#include "chrome/browser/ui/views/toolbar/extension_toolbar_menu_view.h" |
| #include "chrome/browser/ui/views/toolbar/wrench_menu_observer.h" |
| #include "components/bookmarks/browser/bookmark_model.h" |
| #include "content/public/browser/host_zoom_map.h" |
| @@ -30,6 +31,7 @@ |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "extensions/common/feature_switch.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| #include "grit/theme_resources.h" |
| @@ -680,9 +682,8 @@ class WrenchMenu::ZoomView : public WrenchMenuView { |
| menu->use_new_menu() ? kHorizontalTouchPadding : kHorizontalPadding; |
| fullscreen_button_->SetBorder(views::Border::CreateEmptyBorder( |
| 0, horizontal_padding, 0, horizontal_padding)); |
| - fullscreen_button_->set_background( |
| - new InMenuButtonBackground(InMenuButtonBackground::SINGLE_BUTTON, |
| - menu->use_new_menu())); |
| + fullscreen_button_->set_background(new InMenuButtonBackground( |
| + InMenuButtonBackground::SINGLE_BUTTON, menu->use_new_menu())); |
| fullscreen_button_->SetAccessibleName( |
| GetAccessibleNameForWrenchMenuItem( |
| menu_model, fullscreen_index, IDS_ACCNAME_FULLSCREEN)); |
| @@ -1149,7 +1150,8 @@ bool WrenchMenu::IsCommandEnabled(int command_id) const { |
| // The items representing the cut menu (cut/copy/paste) and zoom menu |
| // (increment/decrement/reset) are always enabled. The child views of these |
| // items enabled state updates appropriately. |
|
Devlin
2014/06/23 17:55:29
does this comment need updating?
|
| - if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) |
| + if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| + command_id == IDC_EXTENSIONS_OVERFLOW_MENU) |
| return true; |
| const Entry& entry = command_id_to_entry_.find(command_id)->second; |
| @@ -1162,7 +1164,8 @@ void WrenchMenu::ExecuteCommand(int command_id, int mouse_event_flags) { |
| return; |
| } |
| - if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) { |
| + if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| + command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { |
| // These items are represented by child views. If ExecuteCommand is invoked |
| // it means the user clicked on the area around the buttons and we should |
| // not do anyting. |
| @@ -1178,7 +1181,8 @@ bool WrenchMenu::GetAccelerator(int command_id, |
| if (IsBookmarkCommand(command_id)) |
| return false; |
| - if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS) { |
| + if (command_id == IDC_CUT || command_id == IDC_ZOOM_MINUS || |
| + command_id == IDC_EXTENSIONS_OVERFLOW_MENU) { |
| // These have special child views; don't show the accelerator for them. |
| return false; |
| } |
| @@ -1245,6 +1249,12 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent, |
| model->GetCommandIdAt(i) == IDC_ZOOM_MINUS)) |
| height = kMenuItemContainingButtonsHeight; |
| + if (model->GetCommandIdAt(i) == IDC_EXTENSIONS_OVERFLOW_MENU) { |
| + extension_toolbar_menu_view_.reset( |
|
Devlin
2014/06/23 17:55:29
If this variable is only ever created and then rel
Finnur
2014/06/25 16:18:11
Nope.
|
| + new ExtensionToolbarMenuView(browser_)); |
| + height = extension_toolbar_menu_view_->GetPreferredSize().height(); |
| + } |
| + |
| // Add the menu item at the end. |
| int menu_index = parent->HasSubmenu() ? |
| parent->GetSubmenu()->child_count() : 0; |
| @@ -1255,6 +1265,12 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent, |
| PopulateMenu(item, model->GetSubmenuModelAt(i)); |
| switch (model->GetCommandIdAt(i)) { |
| + case IDC_EXTENSIONS_OVERFLOW_MENU: |
| + if (height > 0) |
| + item->AddChildView(extension_toolbar_menu_view_.release()); |
| + else |
| + item->SetVisible(false); |
| + break; |
| case IDC_CUT: |
| DCHECK_EQ(MenuModel::TYPE_COMMAND, model->GetTypeAt(i)); |
| DCHECK_LT(i + 2, max); |