OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include "base/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/tabs/tab_strip_model_observer.h" | 11 #include "chrome/browser/tabs/tab_strip_model_observer.h" |
11 #include "content/common/notification_observer.h" | 12 #include "content/common/notification_observer.h" |
12 #include "content/common/notification_registrar.h" | 13 #include "content/common/notification_registrar.h" |
13 #include "ui/base/models/accelerator.h" | 14 #include "ui/base/models/accelerator.h" |
14 #include "ui/base/models/button_menu_item_model.h" | 15 #include "ui/base/models/button_menu_item_model.h" |
15 #include "ui/base/models/simple_menu_model.h" | 16 #include "ui/base/models/simple_menu_model.h" |
16 | 17 |
17 class Browser; | 18 class Browser; |
18 class TabStripModel; | 19 class TabStripModel; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 BookmarkSubMenuModel(ui::SimpleMenuModel::Delegate* delegate, | 75 BookmarkSubMenuModel(ui::SimpleMenuModel::Delegate* delegate, |
75 Browser* browser); | 76 Browser* browser); |
76 virtual ~BookmarkSubMenuModel(); | 77 virtual ~BookmarkSubMenuModel(); |
77 | 78 |
78 private: | 79 private: |
79 void Build(Browser* browser); | 80 void Build(Browser* browser); |
80 | 81 |
81 DISALLOW_COPY_AND_ASSIGN(BookmarkSubMenuModel); | 82 DISALLOW_COPY_AND_ASSIGN(BookmarkSubMenuModel); |
82 }; | 83 }; |
83 | 84 |
| 85 class ProfilesSubMenuModel : public ui::SimpleMenuModel, |
| 86 public ui::SimpleMenuModel::Delegate { |
| 87 public: |
| 88 ProfilesSubMenuModel(ui::SimpleMenuModel::Delegate* delegate, |
| 89 Browser* browser); |
| 90 |
| 91 virtual void ExecuteCommand(int command_id) OVERRIDE; |
| 92 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE; |
| 93 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE; |
| 94 virtual bool GetAcceleratorForCommandId( |
| 95 int command_id, |
| 96 ui::Accelerator* accelerator) OVERRIDE; |
| 97 |
| 98 private: |
| 99 enum { |
| 100 // The profiles submenu contains a menu item for each profile. For |
| 101 // the i'th profile the command ID is COMMAND_SWITCH_TO_PROFILE + i. |
| 102 // If the profile matches the profile of the wrench button's browser |
| 103 // then the menu item is checked. |
| 104 COMMAND_SWITCH_TO_PROFILE, |
| 105 }; |
| 106 |
| 107 void Build(); |
| 108 |
| 109 Browser* browser_; // weak |
| 110 ui::SimpleMenuModel::Delegate* delegate_; // weak |
| 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(ProfilesSubMenuModel); |
| 113 }; |
| 114 |
84 // A menu model that builds the contents of the wrench menu. | 115 // A menu model that builds the contents of the wrench menu. |
85 class WrenchMenuModel : public ui::SimpleMenuModel, | 116 class WrenchMenuModel : public ui::SimpleMenuModel, |
86 public ui::SimpleMenuModel::Delegate, | 117 public ui::SimpleMenuModel::Delegate, |
87 public ui::ButtonMenuItemModel::Delegate, | 118 public ui::ButtonMenuItemModel::Delegate, |
88 public TabStripModelObserver, | 119 public TabStripModelObserver, |
89 public NotificationObserver { | 120 public NotificationObserver { |
90 public: | 121 public: |
91 WrenchMenuModel(ui::AcceleratorProvider* provider, Browser* browser); | 122 WrenchMenuModel(ui::AcceleratorProvider* provider, Browser* browser); |
92 virtual ~WrenchMenuModel(); | 123 virtual ~WrenchMenuModel(); |
93 | 124 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 180 |
150 // Label of the zoom label in the zoom menu item. | 181 // Label of the zoom label in the zoom menu item. |
151 string16 zoom_label_; | 182 string16 zoom_label_; |
152 | 183 |
153 // Tools menu. | 184 // Tools menu. |
154 scoped_ptr<ToolsMenuModel> tools_menu_model_; | 185 scoped_ptr<ToolsMenuModel> tools_menu_model_; |
155 | 186 |
156 // Bookmark submenu. | 187 // Bookmark submenu. |
157 scoped_ptr<BookmarkSubMenuModel> bookmark_sub_menu_model_; | 188 scoped_ptr<BookmarkSubMenuModel> bookmark_sub_menu_model_; |
158 | 189 |
| 190 // Profiles submenu. |
| 191 scoped_ptr<ProfilesSubMenuModel> profiles_sub_menu_model_; |
| 192 |
159 ui::AcceleratorProvider* provider_; // weak | 193 ui::AcceleratorProvider* provider_; // weak |
160 | 194 |
161 Browser* browser_; // weak | 195 Browser* browser_; // weak |
162 TabStripModel* tabstrip_model_; // weak | 196 TabStripModel* tabstrip_model_; // weak |
163 | 197 |
164 NotificationRegistrar registrar_; | 198 NotificationRegistrar registrar_; |
165 | 199 |
166 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); | 200 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); |
167 }; | 201 }; |
168 | 202 |
169 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 203 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ |
OLD | NEW |