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

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

Issue 7076027: Couple more wrench menu issues. The patch I sent around a couple of (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Makes unit test compile Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/utf_string_conversions.h" 8 #include "base/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/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "content/common/notification_service.h" 12 #include "content/common/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 "views/controls/menu/menu_item_view.h" 15 #include "views/controls/menu/menu_item_view.h"
16 16
17 //////////////////////////////////////////////////////////////////////////////// 17 ////////////////////////////////////////////////////////////////////////////////
18 // BookmarkContextMenu, public: 18 // BookmarkContextMenu, public:
19 19
20 BookmarkContextMenu::BookmarkContextMenu( 20 BookmarkContextMenu::BookmarkContextMenu(
21 gfx::NativeWindow parent_window, 21 gfx::NativeWindow parent_window,
22 Profile* profile, 22 Profile* profile,
23 PageNavigator* page_navigator, 23 PageNavigator* page_navigator,
24 const BookmarkNode* parent, 24 const BookmarkNode* parent,
25 const std::vector<const BookmarkNode*>& selection) 25 const std::vector<const BookmarkNode*>& selection,
26 bool close_on_remove)
26 : ALLOW_THIS_IN_INITIALIZER_LIST( 27 : ALLOW_THIS_IN_INITIALIZER_LIST(
27 controller_(new BookmarkContextMenuControllerViews(parent_window, 28 controller_(new BookmarkContextMenuControllerViews(parent_window,
28 this, profile, page_navigator, parent, selection))), 29 this, profile, page_navigator, parent, selection))),
29 parent_window_(parent_window), 30 parent_window_(parent_window),
30 ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))), 31 ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))),
31 parent_node_(parent), 32 parent_node_(parent),
32 observer_(NULL) { 33 observer_(NULL),
34 close_on_remove_(close_on_remove) {
33 controller_->BuildMenu(); 35 controller_->BuildMenu();
34 } 36 }
35 37
36 BookmarkContextMenu::~BookmarkContextMenu() { 38 BookmarkContextMenu::~BookmarkContextMenu() {
37 } 39 }
38 40
39 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) { 41 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) {
40 NotificationService::current()->Notify( 42 NotificationService::current()->Notify(
41 NotificationType::BOOKMARK_CONTEXT_MENU_SHOWN, 43 NotificationType::BOOKMARK_CONTEXT_MENU_SHOWN,
42 Source<BookmarkContextMenu>(this), 44 Source<BookmarkContextMenu>(this),
(...skipping 14 matching lines...) Expand all
57 59
58 bool BookmarkContextMenu::IsItemChecked(int command_id) const { 60 bool BookmarkContextMenu::IsItemChecked(int command_id) const {
59 return controller_->IsItemChecked(command_id); 61 return controller_->IsItemChecked(command_id);
60 } 62 }
61 63
62 bool BookmarkContextMenu::IsCommandEnabled(int command_id) const { 64 bool BookmarkContextMenu::IsCommandEnabled(int command_id) const {
63 return controller_->IsCommandEnabled(command_id); 65 return controller_->IsCommandEnabled(command_id);
64 } 66 }
65 67
66 bool BookmarkContextMenu::ShouldCloseAllMenusOnExecute(int id) { 68 bool BookmarkContextMenu::ShouldCloseAllMenusOnExecute(int id) {
67 return id != IDC_BOOKMARK_BAR_REMOVE || 69 return (id != IDC_BOOKMARK_BAR_REMOVE) || close_on_remove_;
68 (parent_node_ ==
69 controller_->profile()->GetBookmarkModel()->other_node() &&
70 parent_node_->child_count() == 1);
71 } 70 }
72 71
73 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
74 // BookmarkContextMenu, BookmarkContextMenuControllerViewsDelegate 73 // BookmarkContextMenu, BookmarkContextMenuControllerViewsDelegate
75 // implementation: 74 // implementation:
76 75
77 void BookmarkContextMenu::CloseMenu() { 76 void BookmarkContextMenu::CloseMenu() {
78 menu_->Cancel(); 77 menu_->Cancel();
79 } 78 }
80 79
(...skipping 15 matching lines...) Expand all
96 void BookmarkContextMenu::WillRemoveBookmarks( 95 void BookmarkContextMenu::WillRemoveBookmarks(
97 const std::vector<const BookmarkNode*>& bookmarks) { 96 const std::vector<const BookmarkNode*>& bookmarks) {
98 if (observer_) 97 if (observer_)
99 observer_->WillRemoveBookmarks(bookmarks); 98 observer_->WillRemoveBookmarks(bookmarks);
100 } 99 }
101 100
102 void BookmarkContextMenu::DidRemoveBookmarks() { 101 void BookmarkContextMenu::DidRemoveBookmarks() {
103 if (observer_) 102 if (observer_)
104 observer_->DidRemoveBookmarks(); 103 observer_->DidRemoveBookmarks();
105 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698