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

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

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

Powered by Google App Engine
This is Rietveld 408576698