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

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

Issue 6798006: Makes the other bookmark folder menu close if you delete the last item (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_context_menu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "content/common/notification_service.h" 12 #include "content/common/notification_service.h"
12 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
14 #include "views/controls/menu/menu_item_view.h" 15 #include "views/controls/menu/menu_item_view.h"
15 16
16 //////////////////////////////////////////////////////////////////////////////// 17 ////////////////////////////////////////////////////////////////////////////////
17 // BookmarkContextMenu, public: 18 // BookmarkContextMenu, public:
18 19
19 BookmarkContextMenu::BookmarkContextMenu( 20 BookmarkContextMenu::BookmarkContextMenu(
20 gfx::NativeWindow parent_window, 21 gfx::NativeWindow parent_window,
21 Profile* profile, 22 Profile* profile,
22 PageNavigator* page_navigator, 23 PageNavigator* page_navigator,
23 const BookmarkNode* parent, 24 const BookmarkNode* parent,
24 const std::vector<const BookmarkNode*>& selection) 25 const std::vector<const BookmarkNode*>& selection)
25 : ALLOW_THIS_IN_INITIALIZER_LIST( 26 : ALLOW_THIS_IN_INITIALIZER_LIST(
26 controller_(new BookmarkContextMenuControllerViews(parent_window, 27 controller_(new BookmarkContextMenuControllerViews(parent_window,
27 this, profile, page_navigator, parent, selection))), 28 this, profile, page_navigator, parent, selection))),
28 parent_window_(parent_window), 29 parent_window_(parent_window),
29 ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))), 30 ALLOW_THIS_IN_INITIALIZER_LIST(menu_(new views::MenuItemView(this))),
31 parent_node_(parent),
30 observer_(NULL) { 32 observer_(NULL) {
31 controller_->BuildMenu(); 33 controller_->BuildMenu();
32 } 34 }
33 35
34 BookmarkContextMenu::~BookmarkContextMenu() { 36 BookmarkContextMenu::~BookmarkContextMenu() {
35 } 37 }
36 38
37 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) { 39 void BookmarkContextMenu::RunMenuAt(const gfx::Point& point) {
38 NotificationService::current()->Notify( 40 NotificationService::current()->Notify(
39 NotificationType::BOOKMARK_CONTEXT_MENU_SHOWN, 41 NotificationType::BOOKMARK_CONTEXT_MENU_SHOWN,
(...skipping 15 matching lines...) Expand all
55 57
56 bool BookmarkContextMenu::IsItemChecked(int command_id) const { 58 bool BookmarkContextMenu::IsItemChecked(int command_id) const {
57 return controller_->IsItemChecked(command_id); 59 return controller_->IsItemChecked(command_id);
58 } 60 }
59 61
60 bool BookmarkContextMenu::IsCommandEnabled(int command_id) const { 62 bool BookmarkContextMenu::IsCommandEnabled(int command_id) const {
61 return controller_->IsCommandEnabled(command_id); 63 return controller_->IsCommandEnabled(command_id);
62 } 64 }
63 65
64 bool BookmarkContextMenu::ShouldCloseAllMenusOnExecute(int id) { 66 bool BookmarkContextMenu::ShouldCloseAllMenusOnExecute(int id) {
65 return id != IDC_BOOKMARK_BAR_REMOVE; 67 return id != IDC_BOOKMARK_BAR_REMOVE ||
68 (parent_node_ ==
69 controller_->profile()->GetBookmarkModel()->other_node() &&
70 parent_node_->child_count() == 1);
66 } 71 }
67 72
68 //////////////////////////////////////////////////////////////////////////////// 73 ////////////////////////////////////////////////////////////////////////////////
69 // BookmarkContextMenu, BookmarkContextMenuControllerViewsDelegate 74 // BookmarkContextMenu, BookmarkContextMenuControllerViewsDelegate
70 // implementation: 75 // implementation:
71 76
72 void BookmarkContextMenu::CloseMenu() { 77 void BookmarkContextMenu::CloseMenu() {
73 menu_->Cancel(); 78 menu_->Cancel();
74 } 79 }
75 80
(...skipping 15 matching lines...) Expand all
91 void BookmarkContextMenu::WillRemoveBookmarks( 96 void BookmarkContextMenu::WillRemoveBookmarks(
92 const std::vector<const BookmarkNode*>& bookmarks) { 97 const std::vector<const BookmarkNode*>& bookmarks) {
93 if (observer_) 98 if (observer_)
94 observer_->WillRemoveBookmarks(bookmarks); 99 observer_->WillRemoveBookmarks(bookmarks);
95 } 100 }
96 101
97 void BookmarkContextMenu::DidRemoveBookmarks() { 102 void BookmarkContextMenu::DidRemoveBookmarks() {
98 if (observer_) 103 if (observer_)
99 observer_->DidRemoveBookmarks(); 104 observer_->DidRemoveBookmarks();
100 } 105 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_context_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698