| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" | 9 #include "chrome/browser/extensions/extension_keybinding_registry.h" |
| 10 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 11 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" | 11 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" |
| 12 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" | 12 #include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views
.h" |
| 13 #include "chrome/browser/ui/views/toolbar/chevron_menu_button.h" | 13 #include "chrome/browser/ui/views/toolbar/chevron_menu_button.h" |
| 14 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" | 14 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| 15 #include "ui/gfx/animation/animation_delegate.h" | 15 #include "ui/gfx/animation/animation_delegate.h" |
| 16 #include "ui/gfx/animation/slide_animation.h" | 16 #include "ui/gfx/animation/slide_animation.h" |
| 17 #include "ui/gfx/animation/tween.h" | 17 #include "ui/gfx/animation/tween.h" |
| 18 #include "ui/views/controls/resize_area_delegate.h" | 18 #include "ui/views/controls/resize_area_delegate.h" |
| 19 #include "ui/views/drag_controller.h" | 19 #include "ui/views/drag_controller.h" |
| 20 #include "ui/views/view.h" | 20 #include "ui/views/view.h" |
| 21 #include "ui/views/widget/widget_observer.h" |
| 21 | 22 |
| 22 class BrowserActionsContainerObserver; | 23 class BrowserActionsContainerObserver; |
| 23 class ExtensionPopup; | 24 class ExtensionPopup; |
| 24 | 25 |
| 25 namespace extensions { | 26 namespace extensions { |
| 26 class ActiveTabPermissionGranter; | 27 class ActiveTabPermissionGranter; |
| 27 class Command; | 28 class Command; |
| 28 class Extension; | 29 class Extension; |
| 29 } | 30 } |
| 30 | 31 |
| 31 namespace views { | 32 namespace views { |
| 33 class BubbleDelegateView; |
| 32 class ResizeArea; | 34 class ResizeArea; |
| 33 } | 35 } |
| 34 | 36 |
| 35 // The BrowserActionsContainer is a container view, responsible for drawing the | 37 // The BrowserActionsContainer is a container view, responsible for drawing the |
| 36 // toolbar action icons (including extension icons and icons for component | 38 // toolbar action icons (including extension icons and icons for component |
| 37 // toolbar actions). It comes intwo flavors, a main container (when residing on | 39 // toolbar actions). It comes intwo flavors, a main container (when residing on |
| 38 // the toolbar) and an overflow container (that resides in the main application | 40 // the toolbar) and an overflow container (that resides in the main application |
| 39 // menu, aka the Chrome menu). | 41 // menu, aka the Chrome menu). |
| 40 // | 42 // |
| 41 // When in 'main' mode, the container supports the full functionality of a | 43 // When in 'main' mode, the container supports the full functionality of a |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // animation ends and we don't want the chevron to flash into view while we are | 120 // animation ends and we don't want the chevron to flash into view while we are |
| 119 // growing the container. | 121 // growing the container. |
| 120 // | 122 // |
| 121 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
| 122 class BrowserActionsContainer | 124 class BrowserActionsContainer |
| 123 : public views::View, | 125 : public views::View, |
| 124 public ToolbarActionsBarDelegate, | 126 public ToolbarActionsBarDelegate, |
| 125 public views::ResizeAreaDelegate, | 127 public views::ResizeAreaDelegate, |
| 126 public gfx::AnimationDelegate, | 128 public gfx::AnimationDelegate, |
| 127 public ToolbarActionView::Delegate, | 129 public ToolbarActionView::Delegate, |
| 130 public views::WidgetObserver, |
| 128 public extensions::ExtensionKeybindingRegistry::Delegate { | 131 public extensions::ExtensionKeybindingRegistry::Delegate { |
| 129 public: | 132 public: |
| 130 // Constructs a BrowserActionContainer for a particular |browser| object. For | 133 // Constructs a BrowserActionContainer for a particular |browser| object. For |
| 131 // documentation of |main_container|, see class comments. | 134 // documentation of |main_container|, see class comments. |
| 132 BrowserActionsContainer(Browser* browser, | 135 BrowserActionsContainer(Browser* browser, |
| 133 BrowserActionsContainer* main_container); | 136 BrowserActionsContainer* main_container); |
| 134 ~BrowserActionsContainer() override; | 137 ~BrowserActionsContainer() override; |
| 135 | 138 |
| 136 void Init(); | 139 void Init(); |
| 137 | 140 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 int target_width, | 248 int target_width, |
| 246 bool suppress_chevron) override; | 249 bool suppress_chevron) override; |
| 247 void SetChevronVisibility(bool chevron_visible) override; | 250 void SetChevronVisibility(bool chevron_visible) override; |
| 248 int GetWidth() const override; | 251 int GetWidth() const override; |
| 249 bool IsAnimating() const override; | 252 bool IsAnimating() const override; |
| 250 void StopAnimating() override; | 253 void StopAnimating() override; |
| 251 int GetChevronWidth() const override; | 254 int GetChevronWidth() const override; |
| 252 bool IsPopupRunning() const override; | 255 bool IsPopupRunning() const override; |
| 253 void OnOverflowedActionWantsToRunChanged( | 256 void OnOverflowedActionWantsToRunChanged( |
| 254 bool overflowed_action_wants_to_run) override; | 257 bool overflowed_action_wants_to_run) override; |
| 258 void ShowExtensionMessageBubble( |
| 259 scoped_ptr<extensions::ExtensionMessageBubbleController> controller) |
| 260 override; |
| 261 |
| 262 // views::WidgetObserver: |
| 263 void OnWidgetClosing(views::Widget* widget) override; |
| 264 void OnWidgetDestroying(views::Widget* widget) override; |
| 255 | 265 |
| 256 // Overridden from extension::ExtensionKeybindingRegistry::Delegate: | 266 // Overridden from extension::ExtensionKeybindingRegistry::Delegate: |
| 257 extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter() | 267 extensions::ActiveTabPermissionGranter* GetActiveTabPermissionGranter() |
| 258 override; | 268 override; |
| 259 | 269 |
| 260 // Retrieve the current popup. This should only be used by unit tests. | 270 // Retrieve the current popup. This should only be used by unit tests. |
| 261 gfx::NativeView TestGetPopup(); | 271 gfx::NativeView TestGetPopup(); |
| 262 | 272 |
| 273 views::BubbleDelegateView* active_bubble() { return active_bubble_; } |
| 274 |
| 263 protected: | 275 protected: |
| 264 // Overridden from views::View: | 276 // Overridden from views::View: |
| 265 void ViewHierarchyChanged( | 277 void ViewHierarchyChanged( |
| 266 const ViewHierarchyChangedDetails& details) override; | 278 const ViewHierarchyChangedDetails& details) override; |
| 267 void OnPaint(gfx::Canvas* canvas) override; | 279 void OnPaint(gfx::Canvas* canvas) override; |
| 268 void OnThemeChanged() override; | 280 void OnThemeChanged() override; |
| 269 | 281 |
| 270 private: | 282 private: |
| 271 // A struct representing the position at which an action will be dropped. | 283 // A struct representing the position at which an action will be dropped. |
| 272 struct DropPosition; | 284 struct DropPosition; |
| 273 | 285 |
| 274 typedef std::vector<ToolbarActionView*> ToolbarActionViews; | 286 typedef std::vector<ToolbarActionView*> ToolbarActionViews; |
| 275 | 287 |
| 276 void LoadImages(); | 288 void LoadImages(); |
| 277 | 289 |
| 290 // Clears the |active_bubble_|, and unregisters the container as an observer. |
| 291 void ClearActiveBubble(views::Widget* widget); |
| 292 |
| 278 const ToolbarActionsBar::PlatformSettings& platform_settings() const { | 293 const ToolbarActionsBar::PlatformSettings& platform_settings() const { |
| 279 return toolbar_actions_bar_->platform_settings(); | 294 return toolbar_actions_bar_->platform_settings(); |
| 280 } | 295 } |
| 281 | 296 |
| 282 // Whether this container is in overflow mode (as opposed to in 'main' | 297 // Whether this container is in overflow mode (as opposed to in 'main' |
| 283 // mode). See class comments for details on the difference. | 298 // mode). See class comments for details on the difference. |
| 284 bool in_overflow_mode() const { return main_container_ != NULL; } | 299 bool in_overflow_mode() const { return main_container_ != NULL; } |
| 285 | 300 |
| 286 // The controlling ToolbarActionsBar, which handles most non-view logic. | 301 // The controlling ToolbarActionsBar, which handles most non-view logic. |
| 287 scoped_ptr<ToolbarActionsBar> toolbar_actions_bar_; | 302 scoped_ptr<ToolbarActionsBar> toolbar_actions_bar_; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 // are done animating. | 350 // are done animating. |
| 336 int animation_target_size_; | 351 int animation_target_size_; |
| 337 | 352 |
| 338 // The DropPosition for the current drag-and-drop operation, or NULL if there | 353 // The DropPosition for the current drag-and-drop operation, or NULL if there |
| 339 // is none. | 354 // is none. |
| 340 scoped_ptr<DropPosition> drop_position_; | 355 scoped_ptr<DropPosition> drop_position_; |
| 341 | 356 |
| 342 // The class that registers for keyboard shortcuts for extension commands. | 357 // The class that registers for keyboard shortcuts for extension commands. |
| 343 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; | 358 scoped_ptr<ExtensionKeybindingRegistryViews> extension_keybinding_registry_; |
| 344 | 359 |
| 360 // The controller of the bubble to show once animation finishes, if any. |
| 361 scoped_ptr<extensions::ExtensionMessageBubbleController> |
| 362 pending_extension_bubble_controller_; |
| 363 |
| 364 // The extension bubble that is actively showing, if any. |
| 365 views::BubbleDelegateView* active_bubble_; |
| 366 |
| 345 ObserverList<BrowserActionsContainerObserver> observers_; | 367 ObserverList<BrowserActionsContainerObserver> observers_; |
| 346 | 368 |
| 347 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 369 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 348 }; | 370 }; |
| 349 | 371 |
| 350 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ | 372 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTIONS_CONTAINER_H_ |
| OLD | NEW |