OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BOOKMARKS_BOOKMARK_CONTEXT_MENU_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_CONTEXT_MENU_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_CONTEXT_MENU_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_CONTEXT_MENU_CONTROLLER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 virtual void WillExecuteCommand( | 33 virtual void WillExecuteCommand( |
34 int command_id, | 34 int command_id, |
35 const std::vector<const BookmarkNode*>& bookmarks) {} | 35 const std::vector<const BookmarkNode*>& bookmarks) {} |
36 | 36 |
37 // Sent after any command from the menu is executed. | 37 // Sent after any command from the menu is executed. |
38 virtual void DidExecuteCommand(int command_id) {} | 38 virtual void DidExecuteCommand(int command_id) {} |
39 }; | 39 }; |
40 | 40 |
41 // BookmarkContextMenuController creates and manages state for the context menu | 41 // BookmarkContextMenuController creates and manages state for the context menu |
42 // shown for any bookmark item. | 42 // shown for any bookmark item. |
43 class BookmarkContextMenuController : public BaseBookmarkModelObserver, | 43 class BookmarkContextMenuController |
44 public ui::SimpleMenuModel::Delegate { | 44 : public bookmarks::BaseBookmarkModelObserver, |
| 45 public ui::SimpleMenuModel::Delegate { |
45 public: | 46 public: |
46 // Creates the bookmark context menu. | 47 // Creates the bookmark context menu. |
47 // |browser| is used to open the bookmark manager and is NULL in tests. | 48 // |browser| is used to open the bookmark manager and is NULL in tests. |
48 // |profile| is used for opening urls as well as enabling 'open incognito'. | 49 // |profile| is used for opening urls as well as enabling 'open incognito'. |
49 // |navigator| is used if |browser| is null, and is provided for testing. | 50 // |navigator| is used if |browser| is null, and is provided for testing. |
50 // |parent| is the parent for newly created nodes if |selection| is empty. | 51 // |parent| is the parent for newly created nodes if |selection| is empty. |
51 // |selection| is the nodes the context menu operates on and may be empty. | 52 // |selection| is the nodes the context menu operates on and may be empty. |
52 BookmarkContextMenuController( | 53 BookmarkContextMenuController( |
53 gfx::NativeWindow parent_window, | 54 gfx::NativeWindow parent_window, |
54 BookmarkContextMenuControllerDelegate* delegate, | 55 BookmarkContextMenuControllerDelegate* delegate, |
(...skipping 23 matching lines...) Expand all Loading... |
78 private: | 79 private: |
79 void BuildMenu(); | 80 void BuildMenu(); |
80 | 81 |
81 // Adds a IDC_* style command to the menu with a localized string. | 82 // Adds a IDC_* style command to the menu with a localized string. |
82 void AddItem(int id, int localization_id); | 83 void AddItem(int id, int localization_id); |
83 // Adds a separator to the menu. | 84 // Adds a separator to the menu. |
84 void AddSeparator(); | 85 void AddSeparator(); |
85 // Adds a checkable item to the menu. | 86 // Adds a checkable item to the menu. |
86 void AddCheckboxItem(int id, int localization_id); | 87 void AddCheckboxItem(int id, int localization_id); |
87 | 88 |
88 // Overridden from BaseBookmarkModelObserver: | 89 // Overridden from bookmarks::BaseBookmarkModelObserver: |
89 // Any change to the model results in closing the menu. | 90 // Any change to the model results in closing the menu. |
90 void BookmarkModelChanged() override; | 91 void BookmarkModelChanged() override; |
91 | 92 |
92 gfx::NativeWindow parent_window_; | 93 gfx::NativeWindow parent_window_; |
93 BookmarkContextMenuControllerDelegate* delegate_; | 94 BookmarkContextMenuControllerDelegate* delegate_; |
94 Browser* browser_; | 95 Browser* browser_; |
95 Profile* profile_; | 96 Profile* profile_; |
96 content::PageNavigator* navigator_; | 97 content::PageNavigator* navigator_; |
97 const BookmarkNode* parent_; | 98 const BookmarkNode* parent_; |
98 std::vector<const BookmarkNode*> selection_; | 99 std::vector<const BookmarkNode*> selection_; |
99 BookmarkModel* model_; | 100 BookmarkModel* model_; |
100 scoped_ptr<ui::SimpleMenuModel> menu_model_; | 101 scoped_ptr<ui::SimpleMenuModel> menu_model_; |
101 | 102 |
102 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuController); | 103 DISALLOW_COPY_AND_ASSIGN(BookmarkContextMenuController); |
103 }; | 104 }; |
104 | 105 |
105 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_CONTEXT_MENU_CONTROLLER_H_ | 106 #endif // CHROME_BROWSER_UI_BOOKMARKS_BOOKMARK_CONTEXT_MENU_CONTROLLER_H_ |
OLD | NEW |