| 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_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 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "chrome/browser/extensions/image_loading_tracker.h" | 11 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 12 #include "chrome/browser/views/browser_bubble.h" | 12 #include "chrome/browser/views/browser_bubble.h" |
| 13 #include "chrome/browser/views/extensions/extension_action_context_menu.h" | |
| 14 #include "chrome/common/notification_observer.h" | 13 #include "chrome/common/notification_observer.h" |
| 15 #include "chrome/common/notification_registrar.h" | 14 #include "chrome/common/notification_registrar.h" |
| 16 #include "views/controls/button/menu_button.h" | 15 #include "views/controls/button/menu_button.h" |
| 17 #include "views/view.h" | 16 #include "views/view.h" |
| 18 | 17 |
| 19 class BrowserActionsContainer; | 18 class BrowserActionsContainer; |
| 20 class Extension; | 19 class Extension; |
| 21 class ExtensionAction; | 20 class ExtensionAction; |
| 22 class ExtensionPopup; | 21 class ExtensionPopup; |
| 23 class Profile; | 22 class Profile; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 public: | 35 public: |
| 37 BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); | 36 BrowserActionButton(Extension* extension, BrowserActionsContainer* panel); |
| 38 ~BrowserActionButton(); | 37 ~BrowserActionButton(); |
| 39 | 38 |
| 40 ExtensionAction* browser_action() const { return browser_action_; } | 39 ExtensionAction* browser_action() const { return browser_action_; } |
| 41 Extension* extension() { return extension_; } | 40 Extension* extension() { return extension_; } |
| 42 | 41 |
| 43 // Called to update the display to match the browser action's state. | 42 // Called to update the display to match the browser action's state. |
| 44 void UpdateState(); | 43 void UpdateState(); |
| 45 | 44 |
| 46 // Overridden from views::View. Return a 0-inset so the icon can draw all the | 45 // Overriden from views::View. Return a 0-inset so the icon can draw all the |
| 47 // way to the edge of the view if it wants. | 46 // way to the edge of the view if it wants. |
| 48 virtual gfx::Insets GetInsets() const; | 47 virtual gfx::Insets GetInsets() const; |
| 49 | 48 |
| 50 // Overridden from views::ButtonListener: | 49 // Overridden from views::ButtonListener: |
| 51 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 50 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 52 | 51 |
| 53 // Overridden from ImageLoadingTracker. | 52 // Overridden from ImageLoadingTracker. |
| 54 virtual void OnImageLoaded(SkBitmap* image, size_t index); | 53 virtual void OnImageLoaded(SkBitmap* image, size_t index); |
| 55 | 54 |
| 56 // Overridden from NotificationObserver: | 55 // Overridden from NotificationObserver: |
| 57 virtual void Observe(NotificationType type, | 56 virtual void Observe(NotificationType type, |
| 58 const NotificationSource& source, | 57 const NotificationSource& source, |
| 59 const NotificationDetails& details); | 58 const NotificationDetails& details); |
| 60 | 59 |
| 61 // MenuButton behavior overrides. These methods all default to TextButton | 60 // MenuButton behavior overrides. These methods all default to TextButton |
| 62 // behavior unless this button is a popup. In that case, it uses MenuButton | 61 // behavior unless this button is a popup. In that case, it uses MenuButton |
| 63 // behavior. MenuButton has the notion of a child popup being shown where the | 62 // behavior. MenuButton has the notion of a child popup being shown where the |
| 64 // button will stay in the pushed state until the "menu" (a popup in this | 63 // button will stay in the pushed state until the "menu" (a popup in this |
| 65 // case) is dismissed. | 64 // case) is dismissed. |
| 66 virtual bool Activate(); | 65 virtual bool Activate(); |
| 67 virtual bool OnMousePressed(const views::MouseEvent& e); | 66 virtual bool OnMousePressed(const views::MouseEvent& e); |
| 68 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); | 67 virtual void OnMouseReleased(const views::MouseEvent& e, bool canceled); |
| 69 virtual bool OnKeyReleased(const views::KeyEvent& e); | 68 virtual bool OnKeyReleased(const views::KeyEvent& e); |
| 70 virtual void OnMouseExited(const views::MouseEvent& event); | 69 virtual void OnMouseExited(const views::MouseEvent& event); |
| 71 | 70 |
| 72 // Does this button's action have a popup? | 71 // Does this button's action have a popup? |
| 73 virtual bool IsPopup(); | 72 virtual bool IsPopup(); |
| 74 | 73 |
| 75 // Notifications when to set button state to pushed/not pushed (for when the | 74 // Notifications when the popup is hidden or shown by the container. |
| 76 // popup/context menu is hidden or shown by the container). | 75 virtual void PopupDidShow(); |
| 77 virtual void SetButtonPushed(); | 76 virtual void PopupDidHide(); |
| 78 virtual void SetButtonNotPushed(); | |
| 79 | 77 |
| 80 private: | 78 private: |
| 81 // The browser action this view represents. The ExtensionAction is not owned | 79 // The browser action this view represents. The ExtensionAction is not owned |
| 82 // by this class. | 80 // by this class. |
| 83 ExtensionAction* browser_action_; | 81 ExtensionAction* browser_action_; |
| 84 | 82 |
| 85 // The extension associated with the browser action we're displaying. | 83 // The extension associated with the browser action we're displaying. |
| 86 Extension* extension_; | 84 Extension* extension_; |
| 87 | 85 |
| 88 // The object that is waiting for the image loading to complete | 86 // The object that is waiting for the image loading to complete |
| 89 // asynchronously. This object can potentially outlive the BrowserActionView, | 87 // asynchronously. This object can potentially outlive the BrowserActionView, |
| 90 // and takes care of deleting itself. | 88 // and takes care of deleting itself. |
| 91 ImageLoadingTracker* tracker_; | 89 ImageLoadingTracker* tracker_; |
| 92 | 90 |
| 93 // The context menu for browser action icons. | |
| 94 scoped_ptr<ExtensionActionContextMenu> context_menu_; | |
| 95 | |
| 96 // Whether we are currently showing/just finished showing a context menu. | |
| 97 bool showing_context_menu_; | |
| 98 | |
| 99 // The default icon for our browser action. This might be non-empty if the | 91 // The default icon for our browser action. This might be non-empty if the |
| 100 // browser action had a value for default_icon in the manifest. | 92 // browser action had a value for default_icon in the manifest. |
| 101 SkBitmap default_icon_; | 93 SkBitmap default_icon_; |
| 102 | 94 |
| 103 // The browser action shelf. | 95 // The browser action shelf. |
| 104 BrowserActionsContainer* panel_; | 96 BrowserActionsContainer* panel_; |
| 105 | 97 |
| 106 NotificationRegistrar registrar_; | 98 NotificationRegistrar registrar_; |
| 107 | 99 |
| 108 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton); | 100 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // The button that triggered the current popup (just a reference to a button | 221 // The button that triggered the current popup (just a reference to a button |
| 230 // from browser_action_views_). | 222 // from browser_action_views_). |
| 231 BrowserActionButton* popup_button_; | 223 BrowserActionButton* popup_button_; |
| 232 | 224 |
| 233 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; | 225 ScopedRunnableMethodFactory<BrowserActionsContainer> task_factory_; |
| 234 | 226 |
| 235 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); | 227 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainer); |
| 236 }; | 228 }; |
| 237 | 229 |
| 238 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ | 230 #endif // CHROME_BROWSER_VIEWS_BROWSER_ACTIONS_CONTAINER_H_ |
| OLD | NEW |