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