| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_VIEWS_TOOLBAR_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/menus/simple_menu_model.h" | 10 #include "app/menus/simple_menu_model.h" |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "chrome/browser/bubble_positioner.h" | 13 #include "chrome/browser/bubble_positioner.h" |
| 14 #include "chrome/browser/command_updater.h" | 14 #include "chrome/browser/command_updater.h" |
| 15 #include "chrome/browser/page_menu_model.h" |
| 15 #include "chrome/browser/user_data_manager.h" | 16 #include "chrome/browser/user_data_manager.h" |
| 16 #include "chrome/browser/views/accessible_toolbar_view.h" | 17 #include "chrome/browser/views/accessible_toolbar_view.h" |
| 17 #include "chrome/browser/views/go_button.h" | 18 #include "chrome/browser/views/go_button.h" |
| 18 #include "chrome/browser/views/location_bar_view.h" | 19 #include "chrome/browser/views/location_bar_view.h" |
| 19 #include "chrome/common/pref_member.h" | 20 #include "chrome/common/pref_member.h" |
| 20 #include "views/controls/button/menu_button.h" | 21 #include "views/controls/button/menu_button.h" |
| 21 #include "views/controls/menu/menu.h" | 22 #include "views/controls/menu/menu.h" |
| 22 #include "views/controls/menu/view_menu_delegate.h" | 23 #include "views/controls/menu/view_menu_delegate.h" |
| 23 #include "views/view.h" | 24 #include "views/view.h" |
| 24 | 25 |
| 25 class BackForwardMenuModelViews; | 26 class BackForwardMenuModelViews; |
| 26 class BrowserActionsContainer; | 27 class BrowserActionsContainer; |
| 27 class Browser; | 28 class Browser; |
| 28 class Profile; | 29 class Profile; |
| 29 class ToolbarStarToggle; | 30 class ToolbarStarToggle; |
| 30 | 31 |
| 31 namespace views { | 32 namespace views { |
| 32 class Menu2; | 33 class Menu2; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // A menu model that builds the contents of an encoding menu. | |
| 36 class EncodingMenuModel : public menus::SimpleMenuModel, | |
| 37 public menus::SimpleMenuModel::Delegate { | |
| 38 public: | |
| 39 explicit EncodingMenuModel(Browser* browser); | |
| 40 virtual ~EncodingMenuModel() {} | |
| 41 | |
| 42 // Overridden from menus::SimpleMenuModel::Delegate: | |
| 43 virtual bool IsCommandIdChecked(int command_id) const; | |
| 44 virtual bool IsCommandIdEnabled(int command_id) const; | |
| 45 virtual bool GetAcceleratorForCommandId(int command_id, | |
| 46 menus::Accelerator* accelerator); | |
| 47 virtual void ExecuteCommand(int command_id); | |
| 48 | |
| 49 private: | |
| 50 void Build(); | |
| 51 | |
| 52 Browser* browser_; | |
| 53 | |
| 54 DISALLOW_COPY_AND_ASSIGN(EncodingMenuModel); | |
| 55 }; | |
| 56 | |
| 57 class ZoomMenuModel : public menus::SimpleMenuModel { | |
| 58 public: | |
| 59 explicit ZoomMenuModel(menus::SimpleMenuModel::Delegate* delegate); | |
| 60 virtual ~ZoomMenuModel() {} | |
| 61 | |
| 62 private: | |
| 63 void Build(); | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(ZoomMenuModel); | |
| 66 }; | |
| 67 | |
| 68 // The Browser Window's toolbar. | 36 // The Browser Window's toolbar. |
| 69 class ToolbarView : public AccessibleToolbarView, | 37 class ToolbarView : public AccessibleToolbarView, |
| 70 public views::ViewMenuDelegate, | 38 public views::ViewMenuDelegate, |
| 71 public views::DragController, | 39 public views::DragController, |
| 72 public menus::SimpleMenuModel::Delegate, | 40 public menus::SimpleMenuModel::Delegate, |
| 73 public LocationBarView::Delegate, | 41 public LocationBarView::Delegate, |
| 74 public NotificationObserver, | 42 public NotificationObserver, |
| 75 public GetProfilesHelper::Delegate, | 43 public GetProfilesHelper::Delegate, |
| 76 public CommandUpdater::CommandObserver, | 44 public CommandUpdater::CommandObserver, |
| 77 public views::ButtonListener, | 45 public views::ButtonListener, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 void CreateCenterStack(Profile* profile); | 136 void CreateCenterStack(Profile* profile); |
| 169 void CreateRightSideControls(Profile* profile); | 137 void CreateRightSideControls(Profile* profile); |
| 170 void LoadLeftSideControlsImages(); | 138 void LoadLeftSideControlsImages(); |
| 171 void LoadCenterStackImages(); | 139 void LoadCenterStackImages(); |
| 172 void LoadRightSideControlsImages(); | 140 void LoadRightSideControlsImages(); |
| 173 | 141 |
| 174 // Runs various menus. | 142 // Runs various menus. |
| 175 void RunPageMenu(const gfx::Point& pt); | 143 void RunPageMenu(const gfx::Point& pt); |
| 176 void RunAppMenu(const gfx::Point& pt); | 144 void RunAppMenu(const gfx::Point& pt); |
| 177 | 145 |
| 178 void CreatePageMenu(); | |
| 179 void CreateZoomMenuContents(); | |
| 180 void CreateEncodingMenuContents(); | |
| 181 #if defined(OS_WIN) | |
| 182 void CreateDevToolsMenuContents(); | |
| 183 #endif | |
| 184 void CreateAppMenu(); | 146 void CreateAppMenu(); |
| 185 | 147 |
| 186 // Types of display mode this toolbar can have. | 148 // Types of display mode this toolbar can have. |
| 187 enum DisplayMode { | 149 enum DisplayMode { |
| 188 DISPLAYMODE_NORMAL, // Normal toolbar with buttons, etc. | 150 DISPLAYMODE_NORMAL, // Normal toolbar with buttons, etc. |
| 189 DISPLAYMODE_LOCATION // Slimline toolbar showing only compact location | 151 DISPLAYMODE_LOCATION // Slimline toolbar showing only compact location |
| 190 // bar, used for popups. | 152 // bar, used for popups. |
| 191 }; | 153 }; |
| 192 bool IsDisplayModeNormal() const { | 154 bool IsDisplayModeNormal() const { |
| 193 return display_mode_ == DISPLAYMODE_NORMAL; | 155 return display_mode_ == DISPLAYMODE_NORMAL; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 221 // Helper class to enumerate profiles information on the file thread. | 183 // Helper class to enumerate profiles information on the file thread. |
| 222 scoped_refptr<GetProfilesHelper> profiles_helper_; | 184 scoped_refptr<GetProfilesHelper> profiles_helper_; |
| 223 | 185 |
| 224 // Controls whether or not a home button should be shown on the toolbar. | 186 // Controls whether or not a home button should be shown on the toolbar. |
| 225 BooleanPrefMember show_home_button_; | 187 BooleanPrefMember show_home_button_; |
| 226 | 188 |
| 227 // The display mode used when laying out the toolbar. | 189 // The display mode used when laying out the toolbar. |
| 228 DisplayMode display_mode_; | 190 DisplayMode display_mode_; |
| 229 | 191 |
| 230 // The contents of the various menus. | 192 // The contents of the various menus. |
| 231 scoped_ptr<menus::SimpleMenuModel> page_menu_contents_; | 193 scoped_ptr<PageMenuModel> page_menu_model_; |
| 232 scoped_ptr<ZoomMenuModel> zoom_menu_contents_; | |
| 233 scoped_ptr<EncodingMenuModel> encoding_menu_contents_; | |
| 234 scoped_ptr<menus::SimpleMenuModel> devtools_menu_contents_; | |
| 235 scoped_ptr<menus::SimpleMenuModel> app_menu_contents_; | 194 scoped_ptr<menus::SimpleMenuModel> app_menu_contents_; |
| 236 | 195 |
| 237 // TODO(beng): build these into MenuButton. | 196 // TODO(beng): build these into MenuButton. |
| 238 scoped_ptr<views::Menu2> page_menu_menu_; | 197 scoped_ptr<views::Menu2> page_menu_menu_; |
| 239 scoped_ptr<views::Menu2> app_menu_menu_; | 198 scoped_ptr<views::Menu2> app_menu_menu_; |
| 240 }; | 199 }; |
| 241 | 200 |
| 242 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 201 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| OLD | NEW |