| 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" | |
| 12 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "chrome/browser/app_menu_model.h" |
| 13 #include "chrome/browser/back_forward_menu_model_views.h" |
| 13 #include "chrome/browser/bubble_positioner.h" | 14 #include "chrome/browser/bubble_positioner.h" |
| 14 #include "chrome/browser/command_updater.h" | 15 #include "chrome/browser/command_updater.h" |
| 15 #include "chrome/browser/page_menu_model.h" | 16 #include "chrome/browser/page_menu_model.h" |
| 16 #include "chrome/browser/user_data_manager.h" | |
| 17 #include "chrome/browser/views/accessible_toolbar_view.h" | 17 #include "chrome/browser/views/accessible_toolbar_view.h" |
| 18 #include "chrome/browser/views/go_button.h" | 18 #include "chrome/browser/views/go_button.h" |
| 19 #include "chrome/browser/views/location_bar_view.h" | 19 #include "chrome/browser/views/location_bar_view.h" |
| 20 #include "chrome/common/pref_member.h" | 20 #include "chrome/common/pref_member.h" |
| 21 #include "views/controls/button/menu_button.h" | 21 #include "views/controls/button/menu_button.h" |
| 22 #include "views/controls/menu/menu.h" | 22 #include "views/controls/menu/menu.h" |
| 23 #include "views/controls/menu/view_menu_delegate.h" | 23 #include "views/controls/menu/view_menu_delegate.h" |
| 24 #include "views/view.h" | 24 #include "views/view.h" |
| 25 | 25 |
| 26 class BackForwardMenuModelViews; | |
| 27 class BrowserActionsContainer; | 26 class BrowserActionsContainer; |
| 28 class Browser; | 27 class Browser; |
| 29 class Profile; | 28 class Profile; |
| 30 class ToolbarStarToggle; | 29 class ToolbarStarToggle; |
| 31 | 30 |
| 32 namespace views { | 31 namespace views { |
| 33 class Menu2; | 32 class Menu2; |
| 34 } | 33 } |
| 35 | 34 |
| 36 // The Browser Window's toolbar. | 35 // The Browser Window's toolbar. |
| 37 class ToolbarView : public AccessibleToolbarView, | 36 class ToolbarView : public AccessibleToolbarView, |
| 38 public views::ViewMenuDelegate, | 37 public views::ViewMenuDelegate, |
| 39 public views::DragController, | 38 public views::DragController, |
| 40 public menus::SimpleMenuModel::Delegate, | 39 public menus::SimpleMenuModel::Delegate, |
| 41 public LocationBarView::Delegate, | 40 public LocationBarView::Delegate, |
| 42 public NotificationObserver, | 41 public NotificationObserver, |
| 43 public GetProfilesHelper::Delegate, | |
| 44 public CommandUpdater::CommandObserver, | 42 public CommandUpdater::CommandObserver, |
| 45 public views::ButtonListener, | 43 public views::ButtonListener, |
| 46 public BubblePositioner { | 44 public BubblePositioner { |
| 47 public: | 45 public: |
| 48 explicit ToolbarView(Browser* browser); | 46 explicit ToolbarView(Browser* browser); |
| 49 virtual ~ToolbarView(); | 47 virtual ~ToolbarView() { } |
| 50 | 48 |
| 51 // Create the contents of the Browser Toolbar | 49 // Create the contents of the Browser Toolbar |
| 52 void Init(Profile* profile); | 50 void Init(Profile* profile); |
| 53 | 51 |
| 54 // Sets the profile which is active on the currently-active tab. | 52 // Sets the profile which is active on the currently-active tab. |
| 55 void SetProfile(Profile* profile); | 53 void SetProfile(Profile* profile); |
| 56 Profile* profile() { return profile_; } | 54 Profile* profile() { return profile_; } |
| 57 | 55 |
| 58 // Updates the toolbar (and transitively the location bar) with the states of | 56 // Updates the toolbar (and transitively the location bar) with the states of |
| 59 // the specified |tab|. If |should_restore_state| is true, we're switching | 57 // the specified |tab|. If |should_restore_state| is true, we're switching |
| (...skipping 12 matching lines...) Expand all Loading... |
| 72 | 70 |
| 73 // Overridden from AccessibleToolbarView: | 71 // Overridden from AccessibleToolbarView: |
| 74 virtual bool IsAccessibleViewTraversable(views::View* view); | 72 virtual bool IsAccessibleViewTraversable(views::View* view); |
| 75 | 73 |
| 76 // Overridden from Menu::BaseControllerDelegate: | 74 // Overridden from Menu::BaseControllerDelegate: |
| 77 virtual bool GetAcceleratorInfo(int id, menus::Accelerator* accel); | 75 virtual bool GetAcceleratorInfo(int id, menus::Accelerator* accel); |
| 78 | 76 |
| 79 // Overridden from views::MenuDelegate: | 77 // Overridden from views::MenuDelegate: |
| 80 virtual void RunMenu(views::View* source, const gfx::Point& pt); | 78 virtual void RunMenu(views::View* source, const gfx::Point& pt); |
| 81 | 79 |
| 82 // Overridden from GetProfilesHelper::Delegate: | |
| 83 virtual void OnGetProfilesDone(const std::vector<std::wstring>& profiles); | |
| 84 | |
| 85 // Overridden from LocationBarView::Delegate: | 80 // Overridden from LocationBarView::Delegate: |
| 86 virtual TabContents* GetTabContents(); | 81 virtual TabContents* GetTabContents(); |
| 87 virtual void OnInputInProgress(bool in_progress); | 82 virtual void OnInputInProgress(bool in_progress); |
| 88 | 83 |
| 89 // Overridden from CommandUpdater::CommandObserver: | 84 // Overridden from CommandUpdater::CommandObserver: |
| 90 virtual void EnabledStateChangedForCommand(int id, bool enabled); | 85 virtual void EnabledStateChangedForCommand(int id, bool enabled); |
| 91 | 86 |
| 92 // Overridden from views::BaseButton::ButtonListener: | 87 // Overridden from views::BaseButton::ButtonListener: |
| 93 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 88 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 94 | 89 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 void CreateCenterStack(Profile* profile); | 131 void CreateCenterStack(Profile* profile); |
| 137 void CreateRightSideControls(Profile* profile); | 132 void CreateRightSideControls(Profile* profile); |
| 138 void LoadLeftSideControlsImages(); | 133 void LoadLeftSideControlsImages(); |
| 139 void LoadCenterStackImages(); | 134 void LoadCenterStackImages(); |
| 140 void LoadRightSideControlsImages(); | 135 void LoadRightSideControlsImages(); |
| 141 | 136 |
| 142 // Runs various menus. | 137 // Runs various menus. |
| 143 void RunPageMenu(const gfx::Point& pt); | 138 void RunPageMenu(const gfx::Point& pt); |
| 144 void RunAppMenu(const gfx::Point& pt); | 139 void RunAppMenu(const gfx::Point& pt); |
| 145 | 140 |
| 146 void CreateAppMenu(); | |
| 147 | |
| 148 // Types of display mode this toolbar can have. | 141 // Types of display mode this toolbar can have. |
| 149 enum DisplayMode { | 142 enum DisplayMode { |
| 150 DISPLAYMODE_NORMAL, // Normal toolbar with buttons, etc. | 143 DISPLAYMODE_NORMAL, // Normal toolbar with buttons, etc. |
| 151 DISPLAYMODE_LOCATION // Slimline toolbar showing only compact location | 144 DISPLAYMODE_LOCATION // Slimline toolbar showing only compact location |
| 152 // bar, used for popups. | 145 // bar, used for popups. |
| 153 }; | 146 }; |
| 154 bool IsDisplayModeNormal() const { | 147 bool IsDisplayModeNormal() const { |
| 155 return display_mode_ == DISPLAYMODE_NORMAL; | 148 return display_mode_ == DISPLAYMODE_NORMAL; |
| 156 } | 149 } |
| 157 | 150 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 173 views::MenuButton* page_menu_; | 166 views::MenuButton* page_menu_; |
| 174 views::MenuButton* app_menu_; | 167 views::MenuButton* app_menu_; |
| 175 // The bookmark menu button. This may be null. | 168 // The bookmark menu button. This may be null. |
| 176 views::MenuButton* bookmark_menu_; | 169 views::MenuButton* bookmark_menu_; |
| 177 Profile* profile_; | 170 Profile* profile_; |
| 178 Browser* browser_; | 171 Browser* browser_; |
| 179 | 172 |
| 180 // Contents of the profiles menu to populate with profile names. | 173 // Contents of the profiles menu to populate with profile names. |
| 181 scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_; | 174 scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_; |
| 182 | 175 |
| 183 // Helper class to enumerate profiles information on the file thread. | |
| 184 scoped_refptr<GetProfilesHelper> profiles_helper_; | |
| 185 | |
| 186 // Controls whether or not a home button should be shown on the toolbar. | 176 // Controls whether or not a home button should be shown on the toolbar. |
| 187 BooleanPrefMember show_home_button_; | 177 BooleanPrefMember show_home_button_; |
| 188 | 178 |
| 189 // The display mode used when laying out the toolbar. | 179 // The display mode used when laying out the toolbar. |
| 190 DisplayMode display_mode_; | 180 DisplayMode display_mode_; |
| 191 | 181 |
| 192 // The contents of the various menus. | 182 // The contents of the various menus. |
| 193 scoped_ptr<PageMenuModel> page_menu_model_; | 183 scoped_ptr<PageMenuModel> page_menu_model_; |
| 194 scoped_ptr<menus::SimpleMenuModel> app_menu_contents_; | 184 scoped_ptr<AppMenuModel> app_menu_model_; |
| 195 | 185 |
| 196 // TODO(beng): build these into MenuButton. | 186 // TODO(beng): build these into MenuButton. |
| 197 scoped_ptr<views::Menu2> page_menu_menu_; | 187 scoped_ptr<views::Menu2> page_menu_menu_; |
| 198 scoped_ptr<views::Menu2> app_menu_menu_; | 188 scoped_ptr<views::Menu2> app_menu_menu_; |
| 199 }; | 189 }; |
| 200 | 190 |
| 201 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 191 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| OLD | NEW |