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

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

Issue 7720012: Moves ownership of MenuItemView to MenuRunner as well as responbility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test Created 9 years, 4 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 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_vie ws.h" 9 #include "chrome/browser/ui/views/bookmarks/bookmark_context_menu_controller_vie ws.h"
10 #include "views/controls/menu/menu_delegate.h" 10 #include "views/controls/menu/menu_delegate.h"
11 11
12 namespace views { 12 namespace views {
13 class MenuRunner;
13 class Widget; 14 class Widget;
14 } 15 }
15 16
16 // Observer for the BookmarkContextMenu. 17 // Observer for the BookmarkContextMenu.
17 class BookmarkContextMenuObserver { 18 class BookmarkContextMenuObserver {
18 public: 19 public:
19 // Invoked before the specified items are removed from the bookmark model. 20 // Invoked before the specified items are removed from the bookmark model.
20 virtual void WillRemoveBookmarks( 21 virtual void WillRemoveBookmarks(
21 const std::vector<const BookmarkNode*>& bookmarks) = 0; 22 const std::vector<const BookmarkNode*>& bookmarks) = 0;
22 23
(...skipping 12 matching lines...) Expand all
35 Profile* profile, 36 Profile* profile,
36 PageNavigator* page_navigator, 37 PageNavigator* page_navigator,
37 const BookmarkNode* parent, 38 const BookmarkNode* parent,
38 const std::vector<const BookmarkNode*>& selection, 39 const std::vector<const BookmarkNode*>& selection,
39 bool close_on_remove); 40 bool close_on_remove);
40 virtual ~BookmarkContextMenu(); 41 virtual ~BookmarkContextMenu();
41 42
42 // Shows the context menu at the specified point. 43 // Shows the context menu at the specified point.
43 void RunMenuAt(const gfx::Point& point); 44 void RunMenuAt(const gfx::Point& point);
44 45
45 views::MenuItemView* menu() const { return menu_.get(); } 46 views::MenuItemView* menu() const { return menu_; }
46 47
47 void set_observer(BookmarkContextMenuObserver* observer) { 48 void set_observer(BookmarkContextMenuObserver* observer) {
48 observer_ = observer; 49 observer_ = observer;
49 } 50 }
50 51
51 // Overridden from views::MenuDelegate: 52 // Overridden from views::MenuDelegate:
52 virtual void ExecuteCommand(int command_id); 53 virtual void ExecuteCommand(int command_id);
53 virtual bool IsItemChecked(int command_id) const; 54 virtual bool IsItemChecked(int command_id) const;
54 virtual bool IsCommandEnabled(int command_id) const; 55 virtual bool IsCommandEnabled(int command_id) const;
55 virtual bool ShouldCloseAllMenusOnExecute(int id); 56 virtual bool ShouldCloseAllMenusOnExecute(int id);
56 57
57 // Overridden from BookmarkContextMenuControllerViewsDelegate: 58 // Overridden from BookmarkContextMenuControllerViewsDelegate:
58 virtual void CloseMenu(); 59 virtual void CloseMenu();
59 virtual void AddItemWithStringId(int command_id, int string_id); 60 virtual void AddItemWithStringId(int command_id, int string_id);
60 virtual void AddSeparator(); 61 virtual void AddSeparator();
61 virtual void AddCheckboxItem(int command_id, int string_id); 62 virtual void AddCheckboxItem(int command_id, int string_id);
62 virtual void WillRemoveBookmarks( 63 virtual void WillRemoveBookmarks(
63 const std::vector<const BookmarkNode*>& bookmarks); 64 const std::vector<const BookmarkNode*>& bookmarks);
64 virtual void DidRemoveBookmarks(); 65 virtual void DidRemoveBookmarks();
65 66
66 private: 67 private:
67 scoped_ptr<BookmarkContextMenuControllerViews> controller_; 68 scoped_ptr<BookmarkContextMenuControllerViews> controller_;
68 69
69 // The parent of dialog boxes opened from the context menu. 70 // The parent of dialog boxes opened from the context menu.
70 views::Widget* parent_widget_; 71 views::Widget* parent_widget_;
71 72
72 // The menu itself. 73 // The menu itself. This is owned by |menu_runner_|.
73 scoped_ptr<views::MenuItemView> menu_; 74 views::MenuItemView* menu_;
75
76 // Responsible for running the menu.
77 scoped_ptr<views::MenuRunner> menu_runner_;
74 78
75 // The node we're showing the menu for. 79 // The node we're showing the menu for.
76 const BookmarkNode* parent_node_; 80 const BookmarkNode* parent_node_;
77 81
78 BookmarkContextMenuObserver* observer_; 82 BookmarkContextMenuObserver* observer_;
79 83
80 // Should the menu close when a node is removed. 84 // Should the menu close when a node is removed.
81 bool close_on_remove_; 85 bool close_on_remove_;
82 86
83 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu); 87 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu);
84 }; 88 };
85 89
86 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ 90 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698