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

Side by Side Diff: chrome/browser/ui/views/toolbar/wrench_menu.h

Issue 413323002: Resubmit: Open the WrenchMenu on mouseover when dragging a browser action (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Created 6 years, 5 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
OLDNEW
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
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 // TODO: remove |use_new_menu| and |supports_new_separators|. 40 enum RunFlags {
41 WrenchMenu(Browser* browser, 41 // TODO: remove |USE_NEW_MENU| and |SUPPORTS_NEW_SEPARATORS|.
42 bool use_new_menu, 42 USE_NEW_MENU = 1 << 0,
43 bool supports_new_separators); 43 SUPPORTS_NEW_SEPARATORS = 1 << 1,
44
45 // Indicates that the menu was opened for a drag-and-drop operation.
46 FOR_DROP = 1 << 2,
47 };
48
49 WrenchMenu(Browser* browser, int run_flags);
44 virtual ~WrenchMenu(); 50 virtual ~WrenchMenu();
45 51
46 void Init(ui::MenuModel* model); 52 void Init(ui::MenuModel* model);
47 53
48 // Shows the menu relative to the specified view. 54 // Shows the menu relative to the specified view.
49 void RunMenu(views::MenuButton* host); 55 void RunMenu(views::MenuButton* host);
50 56
57 // Closes the menu if it is open, otherwise does nothing.
58 void CloseMenu();
59
51 // Whether the menu is currently visible to the user. 60 // Whether the menu is currently visible to the user.
52 bool IsShowing(); 61 bool IsShowing();
53 62
54 bool use_new_menu() const { return use_new_menu_; } 63 bool use_new_menu() const { return (run_flags_ & USE_NEW_MENU) != 0; }
64 bool for_drop() const { return (run_flags_ & FOR_DROP) != 0; }
55 65
56 void AddObserver(WrenchMenuObserver* observer); 66 void AddObserver(WrenchMenuObserver* observer);
57 void RemoveObserver(WrenchMenuObserver* observer); 67 void RemoveObserver(WrenchMenuObserver* observer);
58 68
59 // MenuDelegate overrides: 69 // MenuDelegate overrides:
60 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; 70 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE;
61 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( 71 virtual bool GetShouldUseDisabledEmphasizedForegroundColor(
62 int command_id) const OVERRIDE; 72 int command_id) const OVERRIDE;
63 virtual base::string16 GetTooltipText(int command_id, 73 virtual base::string16 GetTooltipText(int command_id,
64 const gfx::Point& p) const OVERRIDE; 74 const gfx::Point& p) const OVERRIDE;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 const content::NotificationDetails& details) OVERRIDE; 114 const content::NotificationDetails& details) OVERRIDE;
105 115
106 private: 116 private:
107 class CutCopyPasteView; 117 class CutCopyPasteView;
108 class RecentTabsMenuModelDelegate; 118 class RecentTabsMenuModelDelegate;
109 class ZoomView; 119 class ZoomView;
110 120
111 typedef std::pair<ui::MenuModel*,int> Entry; 121 typedef std::pair<ui::MenuModel*,int> Entry;
112 typedef std::map<int,Entry> CommandIDToEntry; 122 typedef std::map<int,Entry> CommandIDToEntry;
113 123
124 bool supports_new_separators() const {
125 return (run_flags_ & SUPPORTS_NEW_SEPARATORS) != 0;
126 }
127
114 // Populates |parent| with all the child menus in |model|. Recursively invokes 128 // Populates |parent| with all the child menus in |model|. Recursively invokes
115 // |PopulateMenu| for any submenu. 129 // |PopulateMenu| for any submenu.
116 void PopulateMenu(views::MenuItemView* parent, 130 void PopulateMenu(views::MenuItemView* parent,
117 ui::MenuModel* model); 131 ui::MenuModel* model);
118 132
119 // Adds a new menu item to |parent| at |menu_index| to represent the item in 133 // Adds a new menu item to |parent| at |menu_index| to represent the item in
120 // |model| at |model_index|: 134 // |model| at |model_index|:
121 // - |menu_index|: position in |parent| to add the new item. 135 // - |menu_index|: position in |parent| to add the new item.
122 // - |model_index|: position in |model| to retrieve information about the 136 // - |model_index|: position in |model| to retrieve information about the
123 // new menu item. 137 // new menu item.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 views::MenuItemView* bookmark_menu_; 184 views::MenuItemView* bookmark_menu_;
171 185
172 // Menu corresponding to IDC_FEEDBACK. 186 // Menu corresponding to IDC_FEEDBACK.
173 views::MenuItemView* feedback_menu_item_; 187 views::MenuItemView* feedback_menu_item_;
174 188
175 // Used for managing "Recent tabs" menu items. 189 // Used for managing "Recent tabs" menu items.
176 scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; 190 scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_;
177 191
178 content::NotificationRegistrar registrar_; 192 content::NotificationRegistrar registrar_;
179 193
180 const bool use_new_menu_; 194 // The bit mask of RunFlags.
181 195 const int run_flags_;
182 const bool supports_new_separators_;
183 196
184 ObserverList<WrenchMenuObserver> observer_list_; 197 ObserverList<WrenchMenuObserver> observer_list_;
185 198
186 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); 199 DISALLOW_COPY_AND_ASSIGN(WrenchMenu);
187 }; 200 };
188 201
189 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ 202 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698