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_TOOLBAR_WRENCH_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace { | 23 namespace { |
24 class MockWrenchMenuModel; | 24 class MockWrenchMenuModel; |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 // A menu model that builds the contents of an encoding menu. | 27 // A menu model that builds the contents of an encoding menu. |
28 class EncodingMenuModel : public ui::SimpleMenuModel, | 28 class EncodingMenuModel : public ui::SimpleMenuModel, |
29 public ui::SimpleMenuModel::Delegate { | 29 public ui::SimpleMenuModel::Delegate { |
30 public: | 30 public: |
31 explicit EncodingMenuModel(Browser* browser); | 31 explicit EncodingMenuModel(Browser* browser); |
32 virtual ~EncodingMenuModel(); | 32 ~EncodingMenuModel() override; |
33 | 33 |
34 // Overridden from ui::SimpleMenuModel::Delegate: | 34 // Overridden from ui::SimpleMenuModel::Delegate: |
35 virtual bool IsCommandIdChecked(int command_id) const override; | 35 bool IsCommandIdChecked(int command_id) const override; |
36 virtual bool IsCommandIdEnabled(int command_id) const override; | 36 bool IsCommandIdEnabled(int command_id) const override; |
37 virtual bool GetAcceleratorForCommandId( | 37 bool GetAcceleratorForCommandId(int command_id, |
38 int command_id, | 38 ui::Accelerator* accelerator) override; |
39 ui::Accelerator* accelerator) override; | 39 void ExecuteCommand(int command_id, int event_flags) override; |
40 virtual void ExecuteCommand(int command_id, int event_flags) override; | |
41 | 40 |
42 private: | 41 private: |
43 void Build(); | 42 void Build(); |
44 | 43 |
45 Browser* browser_; // weak | 44 Browser* browser_; // weak |
46 | 45 |
47 DISALLOW_COPY_AND_ASSIGN(EncodingMenuModel); | 46 DISALLOW_COPY_AND_ASSIGN(EncodingMenuModel); |
48 }; | 47 }; |
49 | 48 |
50 // A menu model that builds the contents of the zoom menu. | 49 // A menu model that builds the contents of the zoom menu. |
51 class ZoomMenuModel : public ui::SimpleMenuModel { | 50 class ZoomMenuModel : public ui::SimpleMenuModel { |
52 public: | 51 public: |
53 explicit ZoomMenuModel(ui::SimpleMenuModel::Delegate* delegate); | 52 explicit ZoomMenuModel(ui::SimpleMenuModel::Delegate* delegate); |
54 virtual ~ZoomMenuModel(); | 53 ~ZoomMenuModel() override; |
55 | 54 |
56 private: | 55 private: |
57 void Build(); | 56 void Build(); |
58 | 57 |
59 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); | 58 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); |
60 }; | 59 }; |
61 | 60 |
62 class ToolsMenuModel : public ui::SimpleMenuModel { | 61 class ToolsMenuModel : public ui::SimpleMenuModel { |
63 public: | 62 public: |
64 ToolsMenuModel(ui::SimpleMenuModel::Delegate* delegate, Browser* browser); | 63 ToolsMenuModel(ui::SimpleMenuModel::Delegate* delegate, Browser* browser); |
65 virtual ~ToolsMenuModel(); | 64 ~ToolsMenuModel() override; |
66 | 65 |
67 private: | 66 private: |
68 void Build(Browser* browser); | 67 void Build(Browser* browser); |
69 | 68 |
70 scoped_ptr<EncodingMenuModel> encoding_menu_model_; | 69 scoped_ptr<EncodingMenuModel> encoding_menu_model_; |
71 | 70 |
72 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel); | 71 DISALLOW_COPY_AND_ASSIGN(ToolsMenuModel); |
73 }; | 72 }; |
74 | 73 |
75 // A menu model that builds the contents of the wrench menu. | 74 // A menu model that builds the contents of the wrench menu. |
76 class WrenchMenuModel : public ui::SimpleMenuModel, | 75 class WrenchMenuModel : public ui::SimpleMenuModel, |
77 public ui::SimpleMenuModel::Delegate, | 76 public ui::SimpleMenuModel::Delegate, |
78 public ui::ButtonMenuItemModel::Delegate, | 77 public ui::ButtonMenuItemModel::Delegate, |
79 public TabStripModelObserver, | 78 public TabStripModelObserver, |
80 public content::NotificationObserver { | 79 public content::NotificationObserver { |
81 public: | 80 public: |
82 // Range of command ID's to use for the items representing bookmarks in the | 81 // Range of command ID's to use for the items representing bookmarks in the |
83 // bookmark menu, must not overlap with that for recent tabs submenu. | 82 // bookmark menu, must not overlap with that for recent tabs submenu. |
84 static const int kMinBookmarkCommandId = 1; | 83 static const int kMinBookmarkCommandId = 1; |
85 static const int kMaxBookmarkCommandId = 1000; | 84 static const int kMaxBookmarkCommandId = 1000; |
86 | 85 |
87 // Range of command ID's to use for the items in the recent tabs submenu, must | 86 // Range of command ID's to use for the items in the recent tabs submenu, must |
88 // not overlap with that for bookmarks. | 87 // not overlap with that for bookmarks. |
89 static const int kMinRecentTabsCommandId = 1001; | 88 static const int kMinRecentTabsCommandId = 1001; |
90 static const int kMaxRecentTabsCommandId = 1200; | 89 static const int kMaxRecentTabsCommandId = 1200; |
91 | 90 |
92 WrenchMenuModel(ui::AcceleratorProvider* provider, Browser* browser); | 91 WrenchMenuModel(ui::AcceleratorProvider* provider, Browser* browser); |
93 virtual ~WrenchMenuModel(); | 92 ~WrenchMenuModel() override; |
94 | 93 |
95 // Overridden for ButtonMenuItemModel::Delegate: | 94 // Overridden for ButtonMenuItemModel::Delegate: |
96 virtual bool DoesCommandIdDismissMenu(int command_id) const override; | 95 bool DoesCommandIdDismissMenu(int command_id) const override; |
97 | 96 |
98 // Overridden for both ButtonMenuItemModel::Delegate and SimpleMenuModel: | 97 // Overridden for both ButtonMenuItemModel::Delegate and SimpleMenuModel: |
99 virtual bool IsItemForCommandIdDynamic(int command_id) const override; | 98 bool IsItemForCommandIdDynamic(int command_id) const override; |
100 virtual base::string16 GetLabelForCommandId(int command_id) const override; | 99 base::string16 GetLabelForCommandId(int command_id) const override; |
101 virtual bool GetIconForCommandId(int command_id, | 100 bool GetIconForCommandId(int command_id, gfx::Image* icon) const override; |
102 gfx::Image* icon) const override; | 101 void ExecuteCommand(int command_id, int event_flags) override; |
103 virtual void ExecuteCommand(int command_id, int event_flags) override; | 102 bool IsCommandIdChecked(int command_id) const override; |
104 virtual bool IsCommandIdChecked(int command_id) const override; | 103 bool IsCommandIdEnabled(int command_id) const override; |
105 virtual bool IsCommandIdEnabled(int command_id) const override; | 104 bool IsCommandIdVisible(int command_id) const override; |
106 virtual bool IsCommandIdVisible(int command_id) const override; | 105 bool GetAcceleratorForCommandId(int command_id, |
107 virtual bool GetAcceleratorForCommandId( | 106 ui::Accelerator* accelerator) override; |
108 int command_id, | |
109 ui::Accelerator* accelerator) override; | |
110 | 107 |
111 // Overridden from TabStripModelObserver: | 108 // Overridden from TabStripModelObserver: |
112 virtual void ActiveTabChanged(content::WebContents* old_contents, | 109 void ActiveTabChanged(content::WebContents* old_contents, |
113 content::WebContents* new_contents, | 110 content::WebContents* new_contents, |
114 int index, | 111 int index, |
115 int reason) override; | 112 int reason) override; |
116 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 113 void TabReplacedAt(TabStripModel* tab_strip_model, |
117 content::WebContents* old_contents, | 114 content::WebContents* old_contents, |
118 content::WebContents* new_contents, | 115 content::WebContents* new_contents, |
119 int index) override; | 116 int index) override; |
120 virtual void TabStripModelDeleted() override; | 117 void TabStripModelDeleted() override; |
121 | 118 |
122 // Overridden from content::NotificationObserver: | 119 // Overridden from content::NotificationObserver: |
123 virtual void Observe(int type, | 120 void Observe(int type, |
124 const content::NotificationSource& source, | 121 const content::NotificationSource& source, |
125 const content::NotificationDetails& details) override; | 122 const content::NotificationDetails& details) override; |
126 | 123 |
127 // Getters. | 124 // Getters. |
128 Browser* browser() const { return browser_; } | 125 Browser* browser() const { return browser_; } |
129 | 126 |
130 BookmarkSubMenuModel* bookmark_sub_menu_model() const { | 127 BookmarkSubMenuModel* bookmark_sub_menu_model() const { |
131 return bookmark_sub_menu_model_.get(); | 128 return bookmark_sub_menu_model_.get(); |
132 } | 129 } |
133 | 130 |
134 // Calculates |zoom_label_| in response to a zoom change. | 131 // Calculates |zoom_label_| in response to a zoom change. |
135 void UpdateZoomControls(); | 132 void UpdateZoomControls(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 TabStripModel* tab_strip_model_; // weak | 184 TabStripModel* tab_strip_model_; // weak |
188 | 185 |
189 scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; | 186 scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; |
190 scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; | 187 scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; |
191 content::NotificationRegistrar registrar_; | 188 content::NotificationRegistrar registrar_; |
192 | 189 |
193 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); | 190 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); |
194 }; | 191 }; |
195 | 192 |
196 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 193 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ |
OLD | NEW |