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 fb972ec886e351d66ab51c3460b045c9fdacaa4b..340bff640c4d625a45d3ebdfc42c31e727d60b28 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; |
|
Peter Kasting
2015/03/30 21:35:25
You should probably add a comment to where this va
sky
2015/03/31 15:17:39
Done.
|
| } |
| // 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_.get()->WillShowMenu(menu); |
|
Peter Kasting
2015/03/30 21:35:25
Nit: .get() probably unnecessary
sky
2015/03/31 15:17:39
Done.
|
| } |
| 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 |
| @@ -1243,17 +1238,15 @@ void WrenchMenu::CreateBookmarkMenu() { |
| if (!model->loaded()) |
| return; |
| + LOG(WARNING) << model->bookmark_bar_node()->GetTotalNodeCount(); |
|
Peter Kasting
2015/03/30 21:35:25
Don't commit this
sky
2015/03/31 15:17:39
Done.
|
| + |
| model->AddObserver(this); |
| // TODO(oshima): Replace with views only API. |
| 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(), |