OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BROWSER_ACTION_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BROWSER_ACTION_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_ACTION_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BROWSER_ACTION_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/extensions/image_loading_tracker.h" | 11 #include "chrome/browser/extensions/image_loading_tracker.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "ui/views/controls/button/menu_button.h" | 13 #include "ui/views/controls/button/menu_button.h" |
14 #include "ui/views/controls/button/menu_button_listener.h" | 14 #include "ui/views/controls/button/menu_button_listener.h" |
15 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
16 | 16 |
17 class BrowserActionsContainer; | 17 class BrowserActionsHostDelegate; |
18 class ExtensionAction; | 18 class ExtensionAction; |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 class MenuItemView; | 21 class MenuItemView; |
22 } | 22 } |
23 | 23 |
24 //////////////////////////////////////////////////////////////////////////////// | 24 //////////////////////////////////////////////////////////////////////////////// |
25 // BrowserActionButton | 25 // BrowserActionButton |
26 | 26 |
27 // The BrowserActionButton is a specialization of the MenuButton class. | 27 // The BrowserActionButton is a specialization of the MenuButton class. |
28 // It acts on a ExtensionAction, in this case a BrowserAction and handles | 28 // It acts on a ExtensionAction, in this case a BrowserAction and handles |
29 // loading the image for the button asynchronously on the file thread. | 29 // loading the image for the button asynchronously on the file thread. |
30 class BrowserActionButton : public views::MenuButton, | 30 class BrowserActionButton : public views::MenuButton, |
31 public views::ButtonListener, | 31 public views::ButtonListener, |
32 public ImageLoadingTracker::Observer, | 32 public ImageLoadingTracker::Observer, |
33 public content::NotificationObserver { | 33 public content::NotificationObserver { |
34 public: | 34 public: |
35 BrowserActionButton(const extensions::Extension* extension, | 35 BrowserActionButton(const extensions::Extension* extension, |
36 BrowserActionsContainer* panel); | 36 BrowserActionsHostDelegate* panel); |
37 | 37 |
38 // Call this instead of delete. | 38 // Call this instead of delete. |
39 void Destroy(); | 39 void Destroy(); |
40 | 40 |
41 ExtensionAction* browser_action() const { return browser_action_; } | 41 ExtensionAction* browser_action() const { return browser_action_; } |
42 const extensions::Extension* extension() { return extension_; } | 42 const extensions::Extension* extension() { return extension_; } |
43 | 43 |
44 // Called to update the display to match the browser action's state. | 44 // Called to update the display to match the browser action's state. |
45 void UpdateState(); | 45 void UpdateState(); |
46 | 46 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 | 107 |
108 // The object that is waiting for the image loading to complete | 108 // The object that is waiting for the image loading to complete |
109 // asynchronously. | 109 // asynchronously. |
110 ImageLoadingTracker tracker_; | 110 ImageLoadingTracker tracker_; |
111 | 111 |
112 // The default icon for our browser action. This might be non-empty if the | 112 // The default icon for our browser action. This might be non-empty if the |
113 // browser action had a value for default_icon in the manifest. | 113 // browser action had a value for default_icon in the manifest. |
114 SkBitmap default_icon_; | 114 SkBitmap default_icon_; |
115 | 115 |
116 // The browser action shelf. | 116 // The browser action shelf. |
117 BrowserActionsContainer* panel_; | 117 BrowserActionsHostDelegate* panel_; |
Aaron Boodman
2012/06/12 05:53:44
s/panel_/delegate_/
yefimt
2012/06/13 01:24:21
Done.
| |
118 | 118 |
119 // The context menu. This member is non-NULL only when the menu is shown. | 119 // The context menu. This member is non-NULL only when the menu is shown. |
120 views::MenuItemView* context_menu_; | 120 views::MenuItemView* context_menu_; |
121 | 121 |
122 content::NotificationRegistrar registrar_; | 122 content::NotificationRegistrar registrar_; |
123 | 123 |
124 // The extension keybinding accelerator this browser action is listening for | 124 // The extension keybinding accelerator this browser action is listening for |
125 // (to show the popup). | 125 // (to show the popup). |
126 scoped_ptr<ui::Accelerator> keybinding_; | 126 scoped_ptr<ui::Accelerator> keybinding_; |
127 | 127 |
128 friend class base::DeleteHelper<BrowserActionButton>; | 128 friend class base::DeleteHelper<BrowserActionButton>; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton); | 130 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton); |
131 }; | 131 }; |
132 | 132 |
133 | 133 |
134 //////////////////////////////////////////////////////////////////////////////// | 134 //////////////////////////////////////////////////////////////////////////////// |
135 // BrowserActionView | 135 // BrowserActionView |
136 // A single section in the browser action container. This contains the actual | 136 // A single section in the browser action container. This contains the actual |
137 // BrowserActionButton, as well as the logic to paint the badge. | 137 // BrowserActionButton, as well as the logic to paint the badge. |
138 | 138 |
139 class BrowserActionView : public views::View { | 139 class BrowserActionView : public views::View { |
140 public: | 140 public: |
141 BrowserActionView(const extensions::Extension* extension, | 141 BrowserActionView(const extensions::Extension* extension, |
142 BrowserActionsContainer* panel); | 142 BrowserActionsHostDelegate* panel); |
143 virtual ~BrowserActionView(); | 143 virtual ~BrowserActionView(); |
144 | 144 |
145 BrowserActionButton* button() { return button_; } | 145 BrowserActionButton* button() { return button_; } |
146 | 146 |
147 // Allocates a canvas object on the heap and draws into it the icon for the | 147 // Allocates a canvas object on the heap and draws into it the icon for the |
148 // view as well as the badge (if any). Caller is responsible for deleting the | 148 // view as well as the badge (if any). Caller is responsible for deleting the |
149 // returned object. | 149 // returned object. |
150 gfx::Canvas* GetIconWithBadge(); | 150 gfx::Canvas* GetIconWithBadge(); |
151 | 151 |
152 // Overridden from views::View: | 152 // Overridden from views::View: |
153 virtual void Layout() OVERRIDE; | 153 virtual void Layout() OVERRIDE; |
154 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 154 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
155 | 155 |
156 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
157 | |
156 protected: | 158 protected: |
157 // Overridden from views::View to paint the badge on top of children. | 159 // Overridden from views::View to paint the badge on top of children. |
158 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; | 160 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; |
159 | 161 |
160 private: | 162 private: |
161 // The container for this view. | 163 // The container for this view. |
162 BrowserActionsContainer* panel_; | 164 BrowserActionsHostDelegate* panel_; |
163 | 165 |
164 // The button this view contains. | 166 // The button this view contains. |
165 BrowserActionButton* button_; | 167 BrowserActionButton* button_; |
166 | 168 |
167 DISALLOW_COPY_AND_ASSIGN(BrowserActionView); | 169 DISALLOW_COPY_AND_ASSIGN(BrowserActionView); |
168 }; | 170 }; |
169 | 171 |
170 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTION_VIEW_H_ | 172 #endif // CHROME_BROWSER_UI_VIEWS_BROWSER_ACTION_VIEW_H_ |
OLD | NEW |