OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TOOLBAR_WRENCH_MENU_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... | |
30 class MenuItemView; | 30 class MenuItemView; |
31 class MenuRunner; | 31 class MenuRunner; |
32 class View; | 32 class View; |
33 } // namespace views | 33 } // namespace views |
34 | 34 |
35 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes. | 35 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes. |
36 class WrenchMenu : public views::MenuDelegate, | 36 class WrenchMenu : public views::MenuDelegate, |
37 public BaseBookmarkModelObserver, | 37 public BaseBookmarkModelObserver, |
38 public content::NotificationObserver { | 38 public content::NotificationObserver { |
39 public: | 39 public: |
40 // |for_drop| indicates whether or not the menu is being opened for a | |
41 // drag-and-drop operation. | |
40 // TODO: remove |use_new_menu| and |supports_new_separators|. | 42 // TODO: remove |use_new_menu| and |supports_new_separators|. |
41 WrenchMenu(Browser* browser, | 43 WrenchMenu(Browser* browser, |
42 bool use_new_menu, | 44 bool use_new_menu, |
sky
2014/07/18 19:36:54
I think it's time to convert to a bitmask here.
Devlin
2014/07/18 21:38:31
Done.
| |
43 bool supports_new_separators); | 45 bool supports_new_separators, |
46 bool for_drop); | |
44 virtual ~WrenchMenu(); | 47 virtual ~WrenchMenu(); |
45 | 48 |
46 void Init(ui::MenuModel* model); | 49 void Init(ui::MenuModel* model); |
47 | 50 |
48 // Shows the menu relative to the specified view. | 51 // Shows the menu relative to the specified view. |
49 void RunMenu(views::MenuButton* host); | 52 void RunMenu(views::MenuButton* host); |
50 | 53 |
54 // Closes the menu if it is open, otherwise does nothing. | |
55 void CloseMenu(); | |
sky
2014/07/18 19:36:54
Instead of the close can you just delete this obje
Devlin
2014/07/18 21:38:31
Nope - doing so causes a segfault.
| |
56 | |
51 // Whether the menu is currently visible to the user. | 57 // Whether the menu is currently visible to the user. |
52 bool IsShowing(); | 58 bool IsShowing(); |
53 | 59 |
54 bool use_new_menu() const { return use_new_menu_; } | 60 bool use_new_menu() const { return use_new_menu_; } |
61 bool for_drop() const { return for_drop_; } | |
55 | 62 |
56 void AddObserver(WrenchMenuObserver* observer); | 63 void AddObserver(WrenchMenuObserver* observer); |
57 void RemoveObserver(WrenchMenuObserver* observer); | 64 void RemoveObserver(WrenchMenuObserver* observer); |
58 | 65 |
59 // MenuDelegate overrides: | 66 // MenuDelegate overrides: |
60 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; | 67 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; |
61 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( | 68 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( |
62 int command_id) const OVERRIDE; | 69 int command_id) const OVERRIDE; |
63 virtual base::string16 GetTooltipText(int command_id, | 70 virtual base::string16 GetTooltipText(int command_id, |
64 const gfx::Point& p) const OVERRIDE; | 71 const gfx::Point& p) const OVERRIDE; |
(...skipping 22 matching lines...) Expand all Loading... | |
87 virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE; | 94 virtual int GetDragOperations(views::MenuItemView* sender) OVERRIDE; |
88 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE; | 95 virtual int GetMaxWidthForMenu(views::MenuItemView* menu) OVERRIDE; |
89 virtual bool IsItemChecked(int command_id) const OVERRIDE; | 96 virtual bool IsItemChecked(int command_id) const OVERRIDE; |
90 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; | 97 virtual bool IsCommandEnabled(int command_id) const OVERRIDE; |
91 virtual void ExecuteCommand(int command_id, int mouse_event_flags) OVERRIDE; | 98 virtual void ExecuteCommand(int command_id, int mouse_event_flags) OVERRIDE; |
92 virtual bool GetAccelerator(int command_id, | 99 virtual bool GetAccelerator(int command_id, |
93 ui::Accelerator* accelerator) const OVERRIDE; | 100 ui::Accelerator* accelerator) const OVERRIDE; |
94 virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE; | 101 virtual void WillShowMenu(views::MenuItemView* menu) OVERRIDE; |
95 virtual void WillHideMenu(views::MenuItemView* menu) OVERRIDE; | 102 virtual void WillHideMenu(views::MenuItemView* menu) OVERRIDE; |
96 virtual bool ShouldCloseOnDragComplete() OVERRIDE; | 103 virtual bool ShouldCloseOnDragComplete() OVERRIDE; |
104 virtual bool InNestedDrag() OVERRIDE; | |
97 | 105 |
98 // BaseBookmarkModelObserver overrides: | 106 // BaseBookmarkModelObserver overrides: |
99 virtual void BookmarkModelChanged() OVERRIDE; | 107 virtual void BookmarkModelChanged() OVERRIDE; |
100 | 108 |
101 // content::NotificationObserver overrides: | 109 // content::NotificationObserver overrides: |
102 virtual void Observe(int type, | 110 virtual void Observe(int type, |
103 const content::NotificationSource& source, | 111 const content::NotificationSource& source, |
104 const content::NotificationDetails& details) OVERRIDE; | 112 const content::NotificationDetails& details) OVERRIDE; |
105 | 113 |
106 private: | 114 private: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 | 182 |
175 // Used for managing "Recent tabs" menu items. | 183 // Used for managing "Recent tabs" menu items. |
176 scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; | 184 scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; |
177 | 185 |
178 content::NotificationRegistrar registrar_; | 186 content::NotificationRegistrar registrar_; |
179 | 187 |
180 const bool use_new_menu_; | 188 const bool use_new_menu_; |
181 | 189 |
182 const bool supports_new_separators_; | 190 const bool supports_new_separators_; |
183 | 191 |
192 // Whether or not the menu is opened for a drag and drop operation. | |
193 bool for_drop_; | |
194 | |
184 ObserverList<WrenchMenuObserver> observer_list_; | 195 ObserverList<WrenchMenuObserver> observer_list_; |
185 | 196 |
186 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); | 197 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); |
187 }; | 198 }; |
188 | 199 |
189 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ | 200 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
OLD | NEW |