| 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 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" | 13 #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "ui/base/models/menu_model.h" | 16 #include "ui/base/models/menu_model.h" |
| 17 #include "ui/views/controls/menu/menu_delegate.h" | 17 #include "ui/views/controls/menu/menu_delegate.h" |
| 18 | 18 |
| 19 class BookmarkMenuDelegate; | 19 class BookmarkMenuDelegate; |
| 20 class Browser; | 20 class Browser; |
| 21 class WrenchMenuObserver; | 21 class WrenchMenuObserver; |
| 22 | 22 |
| 23 namespace ui { | 23 namespace ui { |
| 24 class NativeTheme; | 24 class NativeTheme; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace views { | 27 namespace views { |
| 28 class MenuButton; | 28 class MenuButton; |
| 29 struct MenuConfig; | |
| 30 class MenuItemView; | 29 class MenuItemView; |
| 31 class MenuRunner; | 30 class MenuRunner; |
| 32 class View; | 31 class View; |
| 33 } // namespace views | 32 } // namespace views |
| 34 | 33 |
| 35 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes. | 34 // WrenchMenu adapts the WrenchMenuModel to view's menu related classes. |
| 36 class WrenchMenu : public views::MenuDelegate, | 35 class WrenchMenu : public views::MenuDelegate, |
| 37 public BaseBookmarkModelObserver, | 36 public BaseBookmarkModelObserver, |
| 38 public content::NotificationObserver { | 37 public content::NotificationObserver { |
| 39 public: | 38 public: |
| 40 // TODO: remove |use_new_menu| and |supports_new_separators|. | 39 // TODO: remove |use_new_menu| and |supports_new_separators|. |
| 41 WrenchMenu(Browser* browser, | 40 WrenchMenu(Browser* browser, |
| 42 bool use_new_menu, | 41 bool use_new_menu, |
| 43 bool supports_new_separators); | 42 bool supports_new_separators); |
| 44 virtual ~WrenchMenu(); | 43 virtual ~WrenchMenu(); |
| 45 | 44 |
| 46 void Init(ui::MenuModel* model); | 45 void Init(ui::MenuModel* model); |
| 47 | 46 |
| 48 // Shows the menu relative to the specified view. | 47 // Shows the menu relative to the specified view. |
| 49 void RunMenu(views::MenuButton* host); | 48 void RunMenu(views::MenuButton* host); |
| 50 | 49 |
| 51 // Whether the menu is currently visible to the user. | 50 // Whether the menu is currently visible to the user. |
| 52 bool IsShowing(); | 51 bool IsShowing(); |
| 53 | 52 |
| 54 const views::MenuConfig& GetMenuConfig() const; | |
| 55 | |
| 56 bool use_new_menu() const { return use_new_menu_; } | 53 bool use_new_menu() const { return use_new_menu_; } |
| 57 | 54 |
| 58 void AddObserver(WrenchMenuObserver* observer); | 55 void AddObserver(WrenchMenuObserver* observer); |
| 59 void RemoveObserver(WrenchMenuObserver* observer); | 56 void RemoveObserver(WrenchMenuObserver* observer); |
| 60 | 57 |
| 61 // MenuDelegate overrides: | 58 // MenuDelegate overrides: |
| 62 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; | 59 virtual const gfx::FontList* GetLabelFontList(int command_id) const OVERRIDE; |
| 63 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( | 60 virtual bool GetShouldUseDisabledEmphasizedForegroundColor( |
| 64 int command_id) const OVERRIDE; | 61 int command_id) const OVERRIDE; |
| 65 virtual base::string16 GetTooltipText(int command_id, | 62 virtual base::string16 GetTooltipText(int command_id, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 const content::NotificationDetails& details) OVERRIDE; | 102 const content::NotificationDetails& details) OVERRIDE; |
| 106 | 103 |
| 107 private: | 104 private: |
| 108 class CutCopyPasteView; | 105 class CutCopyPasteView; |
| 109 class RecentTabsMenuModelDelegate; | 106 class RecentTabsMenuModelDelegate; |
| 110 class ZoomView; | 107 class ZoomView; |
| 111 | 108 |
| 112 typedef std::pair<ui::MenuModel*,int> Entry; | 109 typedef std::pair<ui::MenuModel*,int> Entry; |
| 113 typedef std::map<int,Entry> CommandIDToEntry; | 110 typedef std::map<int,Entry> CommandIDToEntry; |
| 114 | 111 |
| 115 const ui::NativeTheme* GetNativeTheme() const; | |
| 116 | |
| 117 // Populates |parent| with all the child menus in |model|. Recursively invokes | 112 // Populates |parent| with all the child menus in |model|. Recursively invokes |
| 118 // |PopulateMenu| for any submenu. | 113 // |PopulateMenu| for any submenu. |
| 119 void PopulateMenu(views::MenuItemView* parent, | 114 void PopulateMenu(views::MenuItemView* parent, |
| 120 ui::MenuModel* model); | 115 ui::MenuModel* model); |
| 121 | 116 |
| 122 // Adds a new menu item to |parent| at |menu_index| to represent the item in | 117 // Adds a new menu item to |parent| at |menu_index| to represent the item in |
| 123 // |model| at |model_index|: | 118 // |model| at |model_index|: |
| 124 // - |menu_index|: position in |parent| to add the new item. | 119 // - |menu_index|: position in |parent| to add the new item. |
| 125 // - |model_index|: position in |model| to retrieve information about the | 120 // - |model_index|: position in |model| to retrieve information about the |
| 126 // new menu item. | 121 // new menu item. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 const bool use_new_menu_; | 178 const bool use_new_menu_; |
| 184 | 179 |
| 185 const bool supports_new_separators_; | 180 const bool supports_new_separators_; |
| 186 | 181 |
| 187 ObserverList<WrenchMenuObserver> observer_list_; | 182 ObserverList<WrenchMenuObserver> observer_list_; |
| 188 | 183 |
| 189 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); | 184 DISALLOW_COPY_AND_ASSIGN(WrenchMenu); |
| 190 }; | 185 }; |
| 191 | 186 |
| 192 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ | 187 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_WRENCH_MENU_H_ |
| OLD | NEW |