Chromium Code Reviews| 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, | |
|
sky
2011/06/10 16:24:14
Does this really need to be in the header?
| |
| 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 COMMAND_SWITCH_TO_PROFILE, | |
| 101 }; | |
| 102 | |
| 103 void Build(); | |
| 104 void GetProfileOnIOThread(FilePath profile_path); | |
|
sky
2011/06/10 16:24:14
const FilePath& (and on next line).
Also, add desc
| |
| 105 void OpenWindowWithProfile(FilePath profile_path); | |
| 106 | |
| 107 Browser* browser_; // weak | |
| 108 ui::SimpleMenuModel::Delegate* delegate_; // weak | |
| 109 | |
| 110 DISALLOW_COPY_AND_ASSIGN(ProfilesSubMenuModel); | |
| 111 }; | |
| 112 | |
| 84 // A menu model that builds the contents of the wrench menu. | 113 // A menu model that builds the contents of the wrench menu. |
| 85 class WrenchMenuModel : public ui::SimpleMenuModel, | 114 class WrenchMenuModel : public ui::SimpleMenuModel, |
| 86 public ui::SimpleMenuModel::Delegate, | 115 public ui::SimpleMenuModel::Delegate, |
| 87 public ui::ButtonMenuItemModel::Delegate, | 116 public ui::ButtonMenuItemModel::Delegate, |
| 88 public TabStripModelObserver, | 117 public TabStripModelObserver, |
| 89 public NotificationObserver { | 118 public NotificationObserver { |
| 90 public: | 119 public: |
| 91 WrenchMenuModel(ui::AcceleratorProvider* provider, Browser* browser); | 120 WrenchMenuModel(ui::AcceleratorProvider* provider, Browser* browser); |
| 92 virtual ~WrenchMenuModel(); | 121 virtual ~WrenchMenuModel(); |
| 93 | 122 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 // Calculates |zoom_label_| in response to a zoom change. | 158 // Calculates |zoom_label_| in response to a zoom change. |
| 130 void UpdateZoomControls(); | 159 void UpdateZoomControls(); |
| 131 | 160 |
| 132 private: | 161 private: |
| 133 // Testing constructor used for mocking. | 162 // Testing constructor used for mocking. |
| 134 friend class ::MockWrenchMenuModel; | 163 friend class ::MockWrenchMenuModel; |
| 135 WrenchMenuModel(); | 164 WrenchMenuModel(); |
| 136 | 165 |
| 137 void Build(); | 166 void Build(); |
| 138 | 167 |
| 168 void AddProfilesMenuItemAt(int index); | |
| 169 | |
| 139 // Adds custom items to the menu. Deprecated in favor of a cross platform | 170 // Adds custom items to the menu. Deprecated in favor of a cross platform |
| 140 // model for button items. | 171 // model for button items. |
| 141 void CreateCutCopyPaste(); | 172 void CreateCutCopyPaste(); |
| 142 void CreateZoomFullscreen(); | 173 void CreateZoomFullscreen(); |
| 143 | 174 |
| 144 string16 GetSyncMenuLabel() const; | 175 string16 GetSyncMenuLabel() const; |
| 145 | 176 |
| 146 // Models for the special menu items with buttons. | 177 // Models for the special menu items with buttons. |
| 147 scoped_ptr<ui::ButtonMenuItemModel> edit_menu_item_model_; | 178 scoped_ptr<ui::ButtonMenuItemModel> edit_menu_item_model_; |
| 148 scoped_ptr<ui::ButtonMenuItemModel> zoom_menu_item_model_; | 179 scoped_ptr<ui::ButtonMenuItemModel> zoom_menu_item_model_; |
| 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 |