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

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

Issue 23530070: backup for dynamic recent tabs submenu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new RecentTabsMenuModelDelegate w/ new intf Created 7 years, 2 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 | Annotate | Revision Log
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/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/bookmarks/bookmark_model.h" 10 #include "chrome/browser/bookmarks/bookmark_model.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/views/controls/menu/menu_item_view.h" 15 #include "ui/views/controls/menu/menu_item_view.h"
16 #include "ui/views/controls/menu/menu_model_adapter.h"
16 #include "ui/views/controls/menu/menu_runner.h" 17 #include "ui/views/controls/menu/menu_runner.h"
17 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
18 19
19 using content::PageNavigator; 20 using content::PageNavigator;
20 21
21 namespace { 22 namespace {
22 23
23 // Returns true if |command_id| corresponds to a command that causes one or more 24 // Returns true if |command_id| corresponds to a command that causes one or more
24 // bookmarks to be removed. 25 // bookmarks to be removed.
25 bool IsRemoveBookmarksCommand(int command_id) { 26 bool IsRemoveBookmarksCommand(int command_id) {
(...skipping 18 matching lines...) Expand all
44 browser, profile, page_navigator, parent, selection)), 45 browser, profile, page_navigator, parent, selection)),
45 parent_widget_(parent_widget), 46 parent_widget_(parent_widget),
46 menu_(new views::MenuItemView(this)), 47 menu_(new views::MenuItemView(this)),
47 menu_runner_(new views::MenuRunner(menu_)), 48 menu_runner_(new views::MenuRunner(menu_)),
48 parent_node_(parent), 49 parent_node_(parent),
49 observer_(NULL), 50 observer_(NULL),
50 close_on_remove_(close_on_remove) { 51 close_on_remove_(close_on_remove) {
51 52
52 ui::SimpleMenuModel* menu_model = controller_->menu_model(); 53 ui::SimpleMenuModel* menu_model = controller_->menu_model();
53 for (int i = 0; i < menu_model->GetItemCount(); ++i) { 54 for (int i = 0; i < menu_model->GetItemCount(); ++i) {
54 menu_->AppendMenuItemFromModel( 55 views::MenuModelAdapter::AppendMenuItemFromModel(
55 menu_model, i, menu_model->GetCommandIdAt(i)); 56 menu_model, i, menu_, menu_model->GetCommandIdAt(i));
56 } 57 }
57 } 58 }
58 59
59 BookmarkContextMenu::~BookmarkContextMenu() { 60 BookmarkContextMenu::~BookmarkContextMenu() {
60 } 61 }
61 62
62 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point, 63 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point,
63 ui::MenuSourceType source_type) { 64 ui::MenuSourceType source_type) {
64 content::NotificationService::current()->Notify( 65 content::NotificationService::current()->Notify(
65 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN, 66 chrome::NOTIFICATION_BOOKMARK_CONTEXT_MENU_SHOWN,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 int command_id, 111 int command_id,
111 const std::vector<const BookmarkNode*>& bookmarks) { 112 const std::vector<const BookmarkNode*>& bookmarks) {
112 if (observer_ && IsRemoveBookmarksCommand(command_id)) 113 if (observer_ && IsRemoveBookmarksCommand(command_id))
113 observer_->WillRemoveBookmarks(bookmarks); 114 observer_->WillRemoveBookmarks(bookmarks);
114 } 115 }
115 116
116 void BookmarkContextMenu::DidExecuteCommand(int command_id) { 117 void BookmarkContextMenu::DidExecuteCommand(int command_id) {
117 if (observer_ && IsRemoveBookmarksCommand(command_id)) 118 if (observer_ && IsRemoveBookmarksCommand(command_id))
118 observer_->DidRemoveBookmarks(); 119 observer_->DidRemoveBookmarks();
119 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698