OLD | NEW |
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 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h" | 9 #include "chrome/browser/ui/bookmarks/bookmark_context_menu_controller.h" |
10 #include "ui/views/controls/menu/menu_delegate.h" | 10 #include "ui/views/controls/menu/menu_delegate.h" |
11 | 11 |
12 class Browser; | 12 class Browser; |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 class MenuRunner; | 15 class MenuRunner; |
16 class Widget; | 16 class Widget; |
17 } | 17 } |
18 | 18 |
19 // Observer for the BookmarkContextMenu. | 19 // Observer for the BookmarkContextMenu. |
20 class BookmarkContextMenuObserver { | 20 class BookmarkContextMenuObserver { |
21 public: | 21 public: |
22 // Invoked before the specified items are removed from the bookmark model. | 22 // Invoked before the specified items are removed from the bookmark model. |
23 virtual void WillRemoveBookmarks( | 23 virtual void WillRemoveBookmarks( |
24 const std::vector<const BookmarkNode*>& bookmarks) = 0; | 24 const std::vector<const bookmarks::BookmarkNode*>& bookmarks) = 0; |
25 | 25 |
26 // Invoked after the items have been removed from the model. | 26 // Invoked after the items have been removed from the model. |
27 virtual void DidRemoveBookmarks() = 0; | 27 virtual void DidRemoveBookmarks() = 0; |
28 | 28 |
29 protected: | 29 protected: |
30 virtual ~BookmarkContextMenuObserver() {} | 30 virtual ~BookmarkContextMenuObserver() {} |
31 }; | 31 }; |
32 | 32 |
33 class BookmarkContextMenu : public BookmarkContextMenuControllerDelegate, | 33 class BookmarkContextMenu : public BookmarkContextMenuControllerDelegate, |
34 public views::MenuDelegate { | 34 public views::MenuDelegate { |
35 public: | 35 public: |
36 // |browser| is used to open the bookmark manager, and is NULL in tests. | 36 // |browser| is used to open the bookmark manager, and is NULL in tests. |
37 BookmarkContextMenu( | 37 BookmarkContextMenu( |
38 views::Widget* parent_widget, | 38 views::Widget* parent_widget, |
39 Browser* browser, | 39 Browser* browser, |
40 Profile* profile, | 40 Profile* profile, |
41 content::PageNavigator* page_navigator, | 41 content::PageNavigator* page_navigator, |
42 const BookmarkNode* parent, | 42 const bookmarks::BookmarkNode* parent, |
43 const std::vector<const BookmarkNode*>& selection, | 43 const std::vector<const bookmarks::BookmarkNode*>& selection, |
44 bool close_on_remove); | 44 bool close_on_remove); |
45 ~BookmarkContextMenu() override; | 45 ~BookmarkContextMenu() override; |
46 | 46 |
47 // Shows the context menu at the specified point. | 47 // Shows the context menu at the specified point. |
48 void RunMenuAt(const gfx::Point& point, | 48 void RunMenuAt(const gfx::Point& point, |
49 ui::MenuSourceType source_type); | 49 ui::MenuSourceType source_type); |
50 | 50 |
51 views::MenuItemView* menu() const { return menu_; } | 51 views::MenuItemView* menu() const { return menu_; } |
52 | 52 |
53 void set_observer(BookmarkContextMenuObserver* observer) { | 53 void set_observer(BookmarkContextMenuObserver* observer) { |
54 observer_ = observer; | 54 observer_ = observer; |
55 } | 55 } |
56 | 56 |
57 // Sets the PageNavigator. | 57 // Sets the PageNavigator. |
58 void SetPageNavigator(content::PageNavigator* navigator); | 58 void SetPageNavigator(content::PageNavigator* navigator); |
59 | 59 |
60 // Overridden from views::MenuDelegate: | 60 // Overridden from views::MenuDelegate: |
61 void ExecuteCommand(int command_id, int event_flags) override; | 61 void ExecuteCommand(int command_id, int event_flags) override; |
62 bool IsItemChecked(int command_id) const override; | 62 bool IsItemChecked(int command_id) const override; |
63 bool IsCommandEnabled(int command_id) const override; | 63 bool IsCommandEnabled(int command_id) const override; |
64 bool IsCommandVisible(int command_id) const override; | 64 bool IsCommandVisible(int command_id) const override; |
65 bool ShouldCloseAllMenusOnExecute(int id) override; | 65 bool ShouldCloseAllMenusOnExecute(int id) override; |
66 | 66 |
67 // Overridden from BookmarkContextMenuControllerDelegate: | 67 // Overridden from BookmarkContextMenuControllerDelegate: |
68 void CloseMenu() override; | 68 void CloseMenu() override; |
69 void WillExecuteCommand( | 69 void WillExecuteCommand( |
70 int command_id, | 70 int command_id, |
71 const std::vector<const BookmarkNode*>& bookmarks) override; | 71 const std::vector<const bookmarks::BookmarkNode*>& bookmarks) override; |
72 void DidExecuteCommand(int command_id) override; | 72 void DidExecuteCommand(int command_id) override; |
73 | 73 |
74 private: | 74 private: |
75 scoped_ptr<BookmarkContextMenuController> controller_; | 75 scoped_ptr<BookmarkContextMenuController> controller_; |
76 | 76 |
77 // The parent of dialog boxes opened from the context menu. | 77 // The parent of dialog boxes opened from the context menu. |
78 views::Widget* parent_widget_; | 78 views::Widget* parent_widget_; |
79 | 79 |
80 // The menu itself. This is owned by |menu_runner_|. | 80 // The menu itself. This is owned by |menu_runner_|. |
81 views::MenuItemView* menu_; | 81 views::MenuItemView* menu_; |
82 | 82 |
83 // Responsible for running the menu. | 83 // Responsible for running the menu. |
84 scoped_ptr<views::MenuRunner> menu_runner_; | 84 scoped_ptr<views::MenuRunner> menu_runner_; |
85 | 85 |
86 BookmarkContextMenuObserver* observer_; | 86 BookmarkContextMenuObserver* observer_; |
87 | 87 |
88 // Should the menu close when a node is removed. | 88 // Should the menu close when a node is removed. |
89 bool close_on_remove_; | 89 bool close_on_remove_; |
90 | 90 |
91 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu); | 91 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenu); |
92 }; | 92 }; |
93 | 93 |
94 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ | 94 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_CONTEXT_MENU_H_ |
OLD | NEW |