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