| 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_BROWSER_ACTIONS_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 6 #define CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 ExtensionAction* browser_action() const { return browser_action_; } | 62 ExtensionAction* browser_action() const { return browser_action_; } |
| 63 Extension* extension() { return extension_; } | 63 Extension* extension() { return extension_; } |
| 64 | 64 |
| 65 // Called to update the display to match the browser action's state. | 65 // Called to update the display to match the browser action's state. |
| 66 void UpdateState(); | 66 void UpdateState(); |
| 67 | 67 |
| 68 // Returns the default icon, if any. | 68 // Returns the default icon, if any. |
| 69 const SkBitmap& default_icon() const { return default_icon_; } | 69 const SkBitmap& default_icon() const { return default_icon_; } |
| 70 | 70 |
| 71 // Overridden from views::View. Return a 0-inset so the icon can draw all the | |
| 72 // way to the edge of the view if it wants. | |
| 73 virtual gfx::Insets GetInsets() const; | |
| 74 | |
| 75 // Overridden from views::ButtonListener: | 71 // Overridden from views::ButtonListener: |
| 76 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 72 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 77 | 73 |
| 78 // Overridden from ImageLoadingTracker. | 74 // Overridden from ImageLoadingTracker. |
| 79 virtual void OnImageLoaded( | 75 virtual void OnImageLoaded( |
| 80 SkBitmap* image, ExtensionResource resource, int index); | 76 SkBitmap* image, ExtensionResource resource, int index); |
| 81 | 77 |
| 82 // Overridden from NotificationObserver: | 78 // Overridden from NotificationObserver: |
| 83 virtual void Observe(NotificationType type, | 79 virtual void Observe(NotificationType type, |
| 84 const NotificationSource& source, | 80 const NotificationSource& source, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // size for the container (animation_target_size_), clamp that value to the | 225 // size for the container (animation_target_size_), clamp that value to the |
| 230 // containers min and max and then animate from the *current* position (that the | 226 // containers min and max and then animate from the *current* position (that the |
| 231 // user has dragged the view to) to the target size. | 227 // user has dragged the view to) to the target size. |
| 232 // | 228 // |
| 233 // Animating the BrowserActionsContainer: | 229 // Animating the BrowserActionsContainer: |
| 234 // | 230 // |
| 235 // Animations are used when snapping the container to a value that fits all | 231 // Animations are used when snapping the container to a value that fits all |
| 236 // visible icons. This can be triggered when the user finishes resizing the | 232 // visible icons. This can be triggered when the user finishes resizing the |
| 237 // container or when Browser Actions are added/removed. | 233 // container or when Browser Actions are added/removed. |
| 238 // | 234 // |
| 239 // We always animate from the current width (container_size_.width()) to the | 235 // We always animate from the current width (container_width_) to the target |
| 240 // target size (animation_target_size_), using |resize_amount| to keep track of | 236 // size (animation_target_size_), using |resize_amount| to keep track of the |
| 241 // the animation progress. | 237 // animation progress. |
| 242 // | 238 // |
| 243 // NOTE: When adding Browser Actions to a maximum width container (no overflow) | 239 // NOTE: When adding Browser Actions to a maximum width container (no overflow) |
| 244 // we make sure to suppress the chevron menu if it wasn't visible. This is | 240 // we make sure to suppress the chevron menu if it wasn't visible. This is |
| 245 // because we won't have enough space to show the new Browser Action until the | 241 // because we won't have enough space to show the new Browser Action until the |
| 246 // animation ends and we don't want the chevron to flash into view while we are | 242 // animation ends and we don't want the chevron to flash into view while we are |
| 247 // growing the container. | 243 // growing the container. |
| 248 // | 244 // |
| 249 //////////////////////////////////////////////////////////////////////////////// | 245 //////////////////////////////////////////////////////////////////////////////// |
| 250 class BrowserActionsContainer | 246 class BrowserActionsContainer |
| 251 : public views::View, | 247 : public views::View, |
| 252 public views::ViewMenuDelegate, | 248 public views::ViewMenuDelegate, |
| 253 public views::DragController, | 249 public views::DragController, |
| 254 public views::ResizeArea::ResizeAreaDelegate, | 250 public views::ResizeArea::ResizeAreaDelegate, |
| 255 public AnimationDelegate, | 251 public AnimationDelegate, |
| 256 public ExtensionToolbarModel::Observer, | 252 public ExtensionToolbarModel::Observer, |
| 257 public BrowserActionOverflowMenuController::Observer, | 253 public BrowserActionOverflowMenuController::Observer, |
| 258 public ExtensionContextMenuModel::PopupDelegate, | 254 public ExtensionContextMenuModel::PopupDelegate, |
| 259 public ExtensionPopup::Observer { | 255 public ExtensionPopup::Observer { |
| 260 public: | 256 public: |
| 261 BrowserActionsContainer(Browser* browser, views::View* owner_view); | 257 BrowserActionsContainer(Browser* browser, views::View* owner_view); |
| 262 virtual ~BrowserActionsContainer(); | 258 virtual ~BrowserActionsContainer(); |
| 263 | 259 |
| 264 static void RegisterUserPrefs(PrefService* prefs); | 260 static void RegisterUserPrefs(PrefService* prefs); |
| 265 | 261 |
| 266 // Get the number of browser actions being displayed. | 262 // Get the number of browser actions being displayed. |
| 267 int num_browser_actions() const { return browser_action_views_.size(); } | 263 int num_browser_actions() const { return browser_action_views_.size(); } |
| 268 | 264 |
| 269 // Whether we are performing resize animation on the container. | 265 // Whether we are performing resize animation on the container. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 // The current popup and the button it came from. NULL if no popup. | 449 // The current popup and the button it came from. NULL if no popup. |
| 454 ExtensionPopup* popup_; | 450 ExtensionPopup* popup_; |
| 455 | 451 |
| 456 // The button that triggered the current popup (just a reference to a button | 452 // The button that triggered the current popup (just a reference to a button |
| 457 // from browser_action_views_). | 453 // from browser_action_views_). |
| 458 BrowserActionButton* popup_button_; | 454 BrowserActionButton* popup_button_; |
| 459 | 455 |
| 460 // The model that tracks the order of the toolbar icons. | 456 // The model that tracks the order of the toolbar icons. |
| 461 ExtensionToolbarModel* model_; | 457 ExtensionToolbarModel* model_; |
| 462 | 458 |
| 463 // The current size of the container. | 459 // The current width of the container. |
| 464 gfx::Size container_size_; | 460 int container_width_; |
| 465 | 461 |
| 466 // The resize area for the container. | 462 // The resize area for the container. |
| 467 views::ResizeArea* resize_area_; | 463 views::ResizeArea* resize_area_; |
| 468 | 464 |
| 469 // The chevron for accessing the overflow items. | 465 // The chevron for accessing the overflow items. |
| 470 views::MenuButton* chevron_; | 466 views::MenuButton* chevron_; |
| 471 | 467 |
| 472 // The menu to show for the overflow button (chevron). This class manages its | 468 // The menu to show for the overflow button (chevron). This class manages its |
| 473 // own lifetime so that it can stay alive during drag and drop operations. | 469 // own lifetime so that it can stay alive during drag and drop operations. |
| 474 BrowserActionOverflowMenuController* overflow_menu_; | 470 BrowserActionOverflowMenuController* overflow_menu_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 493 | 489 |
| 494 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; | 490 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; |
| 495 | 491 |
| 496 // Handles delayed showing of the overflow menu when hovering. | 492 // Handles delayed showing of the overflow menu when hovering. |
| 497 ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_; | 493 ScopedRunnableMethodFactory<BrowserActionsContainer> show_menu_task_factory_; |
| 498 | 494 |
| 499 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 495 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 500 }; | 496 }; |
| 501 | 497 |
| 502 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 498 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| OLD | NEW |