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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_context_menu.cc

Issue 2790773002: Cleanup MenuRunner API (Closed)
Patch Set: Rebase Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bookmarks/bookmark_context_menu.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 browser, 47 browser,
48 profile, 48 profile,
49 page_navigator, 49 page_navigator,
50 parent, 50 parent,
51 selection)), 51 selection)),
52 parent_widget_(parent_widget), 52 parent_widget_(parent_widget),
53 menu_(new views::MenuItemView(this)), 53 menu_(new views::MenuItemView(this)),
54 menu_runner_(new views::MenuRunner(menu_, 54 menu_runner_(new views::MenuRunner(menu_,
55 views::MenuRunner::HAS_MNEMONICS | 55 views::MenuRunner::HAS_MNEMONICS |
56 views::MenuRunner::IS_NESTED | 56 views::MenuRunner::IS_NESTED |
57 views::MenuRunner::CONTEXT_MENU | 57 views::MenuRunner::CONTEXT_MENU)),
58 views::MenuRunner::ASYNC)),
59 observer_(NULL), 58 observer_(NULL),
60 close_on_remove_(close_on_remove) { 59 close_on_remove_(close_on_remove) {
61 ui::SimpleMenuModel* menu_model = controller_->menu_model(); 60 ui::SimpleMenuModel* menu_model = controller_->menu_model();
62 for (int i = 0; i < menu_model->GetItemCount(); ++i) { 61 for (int i = 0; i < menu_model->GetItemCount(); ++i) {
63 views::MenuModelAdapter::AppendMenuItemFromModel( 62 views::MenuModelAdapter::AppendMenuItemFromModel(
64 menu_model, i, menu_, menu_model->GetCommandIdAt(i)); 63 menu_model, i, menu_, menu_model->GetCommandIdAt(i));
65 } 64 }
66 } 65 }
67 66
68 BookmarkContextMenu::~BookmarkContextMenu() { 67 BookmarkContextMenu::~BookmarkContextMenu() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 102 }
104 103
105 bool BookmarkContextMenu::IsCommandVisible(int command_id) const { 104 bool BookmarkContextMenu::IsCommandVisible(int command_id) const {
106 return controller_->IsCommandIdVisible(command_id); 105 return controller_->IsCommandIdVisible(command_id);
107 } 106 }
108 107
109 bool BookmarkContextMenu::ShouldCloseAllMenusOnExecute(int id) { 108 bool BookmarkContextMenu::ShouldCloseAllMenusOnExecute(int id) {
110 return (id != IDC_BOOKMARK_BAR_REMOVE) || close_on_remove_; 109 return (id != IDC_BOOKMARK_BAR_REMOVE) || close_on_remove_;
111 } 110 }
112 111
113 void BookmarkContextMenu::OnMenuClosed(views::MenuItemView* menu, 112 void BookmarkContextMenu::OnMenuClosed(views::MenuItemView* menu) {
114 views::MenuRunner::RunResult result) {
115 if (observer_) 113 if (observer_)
116 observer_->OnContextMenuClosed(); 114 observer_->OnContextMenuClosed();
117 } 115 }
118 116
119 //////////////////////////////////////////////////////////////////////////////// 117 ////////////////////////////////////////////////////////////////////////////////
120 // BookmarkContextMenuControllerDelegate 118 // BookmarkContextMenuControllerDelegate
121 // implementation: 119 // implementation:
122 120
123 void BookmarkContextMenu::CloseMenu() { 121 void BookmarkContextMenu::CloseMenu() {
124 menu_->Cancel(); 122 menu_->Cancel();
125 } 123 }
126 124
127 void BookmarkContextMenu::WillExecuteCommand( 125 void BookmarkContextMenu::WillExecuteCommand(
128 int command_id, 126 int command_id,
129 const std::vector<const BookmarkNode*>& bookmarks) { 127 const std::vector<const BookmarkNode*>& bookmarks) {
130 if (observer_ && IsRemoveBookmarksCommand(command_id)) 128 if (observer_ && IsRemoveBookmarksCommand(command_id))
131 observer_->WillRemoveBookmarks(bookmarks); 129 observer_->WillRemoveBookmarks(bookmarks);
132 } 130 }
133 131
134 void BookmarkContextMenu::DidExecuteCommand(int command_id) { 132 void BookmarkContextMenu::DidExecuteCommand(int command_id) {
135 if (observer_ && IsRemoveBookmarksCommand(command_id)) 133 if (observer_ && IsRemoveBookmarksCommand(command_id))
136 observer_->DidRemoveBookmarks(); 134 observer_->DidRemoveBookmarks();
137 } 135 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_context_menu.h ('k') | chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698