| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "app/menus/simple_menu_model.h" | 11 #include "app/menus/accelerator.h" |
| 12 #include "app/slide_animation.h" | 12 #include "app/slide_animation.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "chrome/browser/back_forward_menu_model.h" | 14 #include "chrome/browser/back_forward_menu_model.h" |
| 15 #include "chrome/browser/command_updater.h" | 15 #include "chrome/browser/command_updater.h" |
| 16 #include "chrome/browser/pref_member.h" | 16 #include "chrome/browser/pref_member.h" |
| 17 #include "chrome/browser/views/accessible_toolbar_view.h" | 17 #include "chrome/browser/views/accessible_toolbar_view.h" |
| 18 #include "chrome/browser/views/location_bar/location_bar_view.h" | 18 #include "chrome/browser/views/location_bar/location_bar_view.h" |
| 19 #include "chrome/browser/views/reload_button.h" | 19 #include "chrome/browser/views/reload_button.h" |
| 20 #include "views/controls/button/menu_button.h" | 20 #include "views/controls/button/menu_button.h" |
| 21 #include "views/controls/menu/menu.h" | 21 #include "views/controls/menu/menu.h" |
| 22 #include "views/controls/menu/menu_wrapper.h" | 22 #include "views/controls/menu/menu_wrapper.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 BrowserActionsContainer; | 26 class BrowserActionsContainer; |
| 27 class Browser; | 27 class Browser; |
| 28 class Profile; | 28 class Profile; |
| 29 class WrenchMenu; | 29 class WrenchMenu; |
| 30 class WrenchMenuModel; |
| 30 | 31 |
| 31 // The Browser Window's toolbar. | 32 // The Browser Window's toolbar. |
| 32 class ToolbarView : public AccessibleToolbarView, | 33 class ToolbarView : public AccessibleToolbarView, |
| 33 public views::ViewMenuDelegate, | 34 public views::ViewMenuDelegate, |
| 34 public menus::SimpleMenuModel::Delegate, | 35 public menus::AcceleratorProvider, |
| 35 public LocationBarView::Delegate, | 36 public LocationBarView::Delegate, |
| 36 public AnimationDelegate, | 37 public AnimationDelegate, |
| 37 public NotificationObserver, | 38 public NotificationObserver, |
| 38 public CommandUpdater::CommandObserver, | 39 public CommandUpdater::CommandObserver, |
| 39 public views::ButtonListener { | 40 public views::ButtonListener { |
| 40 public: | 41 public: |
| 41 explicit ToolbarView(Browser* browser); | 42 explicit ToolbarView(Browser* browser); |
| 42 virtual ~ToolbarView(); | 43 virtual ~ToolbarView(); |
| 43 | 44 |
| 44 // Create the contents of the Browser Toolbar | 45 // Create the contents of the Browser Toolbar |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 virtual void EnabledStateChangedForCommand(int id, bool enabled); | 98 virtual void EnabledStateChangedForCommand(int id, bool enabled); |
| 98 | 99 |
| 99 // Overridden from views::BaseButton::ButtonListener: | 100 // Overridden from views::BaseButton::ButtonListener: |
| 100 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 101 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 101 | 102 |
| 102 // Overridden from NotificationObserver: | 103 // Overridden from NotificationObserver: |
| 103 virtual void Observe(NotificationType type, | 104 virtual void Observe(NotificationType type, |
| 104 const NotificationSource& source, | 105 const NotificationSource& source, |
| 105 const NotificationDetails& details); | 106 const NotificationDetails& details); |
| 106 | 107 |
| 107 // Overridden from menus::SimpleMenuModel::Delegate: | 108 // Overridden from menus::AcceleratorProvider: |
| 108 virtual bool IsCommandIdChecked(int command_id) const; | |
| 109 virtual bool IsCommandIdEnabled(int command_id) const; | |
| 110 virtual bool GetAcceleratorForCommandId(int command_id, | 109 virtual bool GetAcceleratorForCommandId(int command_id, |
| 111 menus::Accelerator* accelerator); | 110 menus::Accelerator* accelerator); |
| 112 virtual void ExecuteCommand(int command_id); | |
| 113 | 111 |
| 114 // Overridden from views::View: | 112 // Overridden from views::View: |
| 115 virtual gfx::Size GetPreferredSize(); | 113 virtual gfx::Size GetPreferredSize(); |
| 116 virtual void Layout(); | 114 virtual void Layout(); |
| 117 virtual void Paint(gfx::Canvas* canvas); | 115 virtual void Paint(gfx::Canvas* canvas); |
| 118 virtual void OnThemeChanged(); | 116 virtual void OnThemeChanged(); |
| 119 | 117 |
| 120 // The apparent horizontal space between most items, and the vertical padding | 118 // The apparent horizontal space between most items, and the vertical padding |
| 121 // above and below them. | 119 // above and below them. |
| 122 static const int kStandardSpacing; | 120 static const int kStandardSpacing; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Contents of the profiles menu to populate with profile names. | 176 // Contents of the profiles menu to populate with profile names. |
| 179 scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_; | 177 scoped_ptr<menus::SimpleMenuModel> profiles_menu_contents_; |
| 180 | 178 |
| 181 // Controls whether or not a home button should be shown on the toolbar. | 179 // Controls whether or not a home button should be shown on the toolbar. |
| 182 BooleanPrefMember show_home_button_; | 180 BooleanPrefMember show_home_button_; |
| 183 | 181 |
| 184 // The display mode used when laying out the toolbar. | 182 // The display mode used when laying out the toolbar. |
| 185 DisplayMode display_mode_; | 183 DisplayMode display_mode_; |
| 186 | 184 |
| 187 // The contents of the app menu. | 185 // The contents of the app menu. |
| 188 scoped_ptr<menus::SimpleMenuModel> app_menu_model_; | 186 scoped_ptr<WrenchMenuModel> wrench_menu_model_; |
| 189 | 187 |
| 190 // Wrench menu. | 188 // Wrench menu. |
| 191 scoped_ptr<WrenchMenu> wrench_menu_; | 189 scoped_ptr<WrenchMenu> wrench_menu_; |
| 192 | 190 |
| 193 // Vector of listeners to receive callbacks when the menu opens. | 191 // Vector of listeners to receive callbacks when the menu opens. |
| 194 std::vector<views::MenuListener*> menu_listeners_; | 192 std::vector<views::MenuListener*> menu_listeners_; |
| 195 | 193 |
| 196 // The animation that makes the update reminder pulse. | 194 // The animation that makes the update reminder pulse. |
| 197 scoped_ptr<SlideAnimation> update_reminder_animation_; | 195 scoped_ptr<SlideAnimation> update_reminder_animation_; |
| 198 | 196 |
| 199 // We periodically restart the animation after it has been showed | 197 // We periodically restart the animation after it has been showed |
| 200 // once, to create a pulsating effect. | 198 // once, to create a pulsating effect. |
| 201 base::RepeatingTimer<ToolbarView> upgrade_reminder_pulse_timer_; | 199 base::RepeatingTimer<ToolbarView> upgrade_reminder_pulse_timer_; |
| 202 | 200 |
| 203 // Used to post tasks to switch to the next/previous menu. | 201 // Used to post tasks to switch to the next/previous menu. |
| 204 ScopedRunnableMethodFactory<ToolbarView> method_factory_; | 202 ScopedRunnableMethodFactory<ToolbarView> method_factory_; |
| 205 | 203 |
| 206 NotificationRegistrar registrar_; | 204 NotificationRegistrar registrar_; |
| 207 | 205 |
| 208 // If non-null the destructor sets this to true. This is set to a non-null | 206 // If non-null the destructor sets this to true. This is set to a non-null |
| 209 // while the menu is showing and used to detect if the menu was deleted while | 207 // while the menu is showing and used to detect if the menu was deleted while |
| 210 // running. | 208 // running. |
| 211 bool* destroyed_flag_; | 209 bool* destroyed_flag_; |
| 212 | 210 |
| 213 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarView); | 211 DISALLOW_IMPLICIT_CONSTRUCTORS(ToolbarView); |
| 214 }; | 212 }; |
| 215 | 213 |
| 216 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ | 214 #endif // CHROME_BROWSER_VIEWS_TOOLBAR_VIEW_H_ |
| OLD | NEW |