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