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

Unified Diff: chrome/browser/ui/views/toolbar/wrench_menu.cc

Issue 1005873012: Makes bookmark menu lazily create menus and removes limits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review feedback 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 side-by-side diff with in-line comments
Download patch
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 fb972ec886e351d66ab51c3460b045c9fdacaa4b..00d9a7abe8cc115eda6fb335dabd5dc134df0b08 100644
--- a/chrome/browser/ui/views/toolbar/wrench_menu.cc
+++ b/chrome/browser/ui/views/toolbar/wrench_menu.cc
@@ -91,8 +91,7 @@ const int kZoomLabelHorizontalPadding = 2;
// Returns true if |command_id| identifies a bookmark menu item.
bool IsBookmarkCommand(int command_id) {
- return command_id >= WrenchMenuModel::kMinBookmarkCommandId &&
- command_id <= WrenchMenuModel::kMaxBookmarkCommandId;
+ return command_id >= IDC_FIRST_BOOKMARK_MENU;
}
// Returns true if |command_id| identifies a recent tabs menu item.
@@ -817,13 +816,6 @@ void WrenchMenu::Init(ui::MenuModel* model) {
// so we get the taller menu style.
PopulateMenu(root_, model);
-#if !defined(NDEBUG)
- // Verify that the reserved command ID's for bookmarks menu are not used.
- for (int i = WrenchMenuModel::kMinBookmarkCommandId;
- i <= WrenchMenuModel::kMaxBookmarkCommandId; ++i)
- DCHECK(command_id_to_entry_.find(i) == command_id_to_entry_.end());
-#endif // !defined(NDEBUG)
-
int32 types = views::MenuRunner::HAS_MNEMONICS;
if (for_drop()) {
// We add NESTED_DRAG since currently the only operation to open the wrench
@@ -1055,6 +1047,8 @@ bool WrenchMenu::GetAccelerator(int command_id,
void WrenchMenu::WillShowMenu(MenuItemView* menu) {
if (menu == bookmark_menu_)
CreateBookmarkMenu();
+ else if (bookmark_menu_delegate_)
+ bookmark_menu_delegate_->WillShowMenu(menu);
}
void WrenchMenu::WillHideMenu(MenuItemView* menu) {
@@ -1064,9 +1058,9 @@ void WrenchMenu::WillHideMenu(MenuItemView* menu) {
if (menu->HasSubmenu() &&
((feedback_menu_item_ && feedback_menu_item_->IsSelected()) ||
(screenshot_menu_item_ && screenshot_menu_item_->IsSelected()))) {
- // It's okay to just turn off the animation and no to take care the
- // animation back because the menu widget will be recreated next time
- // it's opened. See ToolbarView::RunMenu() and Init() of this class.
+ // It's okay to just turn off the animation and not turn it back on because
+ // the menu widget will be recreated next time it's opened. See
+ // ToolbarView::RunMenu() and Init() of this class.
menu->GetSubmenu()->GetWidget()->
SetVisibilityChangedAnimationsEnabled(false);
}
@@ -1197,6 +1191,7 @@ MenuItemView* WrenchMenu::AddMenuItem(MenuItemView* parent,
DCHECK(command_id > -1 ||
(command_id == -1 &&
model->GetTypeAt(model_index) == MenuModel::TYPE_SEPARATOR));
+ DCHECK_LT(command_id, IDC_FIRST_BOOKMARK_MENU);
if (command_id > -1) { // Don't add separators to |command_id_to_entry_|.
// All command ID's should be unique except for IDC_SHOW_HISTORY which is
@@ -1249,11 +1244,7 @@ void WrenchMenu::CreateBookmarkMenu() {
views::Widget* parent = views::Widget::GetWidgetForNativeWindow(
browser_->window()->GetNativeWindow());
bookmark_menu_delegate_.reset(
- new BookmarkMenuDelegate(browser_,
- browser_,
- parent,
- WrenchMenuModel::kMinBookmarkCommandId,
- WrenchMenuModel::kMaxBookmarkCommandId));
+ new BookmarkMenuDelegate(browser_, browser_, parent));
bookmark_menu_delegate_->Init(this,
bookmark_menu_,
model->bookmark_bar_node(),
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_menu_delegate_unittest.cc ('k') | ui/views/controls/menu/menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698