Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_action_view.h

Issue 148143004: Add notification mechanism when BrowserActionButton's icon has been updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_ACTION_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/extensions/extension_action_icon_factory.h" 10 #include "chrome/browser/extensions/extension_action_icon_factory.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 104
105 // The BrowserActionButton is a specialization of the MenuButton class. 105 // The BrowserActionButton is a specialization of the MenuButton class.
106 // It acts on a ExtensionAction, in this case a BrowserAction and handles 106 // It acts on a ExtensionAction, in this case a BrowserAction and handles
107 // loading the image for the button asynchronously on the file thread. 107 // loading the image for the button asynchronously on the file thread.
108 class BrowserActionButton : public views::MenuButton, 108 class BrowserActionButton : public views::MenuButton,
109 public views::ButtonListener, 109 public views::ButtonListener,
110 public views::ContextMenuController, 110 public views::ContextMenuController,
111 public content::NotificationObserver, 111 public content::NotificationObserver,
112 public ExtensionActionIconFactory::Observer { 112 public ExtensionActionIconFactory::Observer {
113 public: 113 public:
114 // The IconObserver will receive a notification when the button's icon has
115 // been updated.
116 class IconObserver {
117 public:
118 virtual ~IconObserver() {}
119 virtual void OnIconUpdated(const gfx::ImageSkia& icon) = 0;
120 };
121
122 void set_icon_observer(IconObserver* icon_observer) {
123 icon_observer_ = icon_observer;
124 }
Finnur 2014/02/19 11:46:31 nit: constructor should appear ahead of this funct
125
114 BrowserActionButton(const extensions::Extension* extension, 126 BrowserActionButton(const extensions::Extension* extension,
115 Browser* browser_, 127 Browser* browser_,
116 BrowserActionView::Delegate* delegate); 128 BrowserActionView::Delegate* delegate);
117 129
118 // Call this instead of delete. 130 // Call this instead of delete.
119 void Destroy(); 131 void Destroy();
120 132
121 ExtensionAction* browser_action() const { return browser_action_; } 133 ExtensionAction* browser_action() const { return browser_action_; }
122 const extensions::Extension* extension() { return extension_; } 134 const extensions::Extension* extension() { return extension_; }
123 135
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 void SetButtonNotPushed(); 182 void SetButtonNotPushed();
171 183
172 // Whether the browser action is enabled on this tab. Note that we cannot use 184 // Whether the browser action is enabled on this tab. Note that we cannot use
173 // the built-in views enabled/SetEnabled because disabled views do not 185 // the built-in views enabled/SetEnabled because disabled views do not
174 // receive drag events. 186 // receive drag events.
175 bool IsEnabled(int tab_id) const; 187 bool IsEnabled(int tab_id) const;
176 188
177 // Returns icon factory for the button. 189 // Returns icon factory for the button.
178 ExtensionActionIconFactory& icon_factory() { return icon_factory_; } 190 ExtensionActionIconFactory& icon_factory() { return icon_factory_; }
179 191
192 // Gets the icon of this button and its badge.
193 gfx::ImageSkia GetIconWithBadge();
194
180 // Returns button icon so it can be accessed during tests. 195 // Returns button icon so it can be accessed during tests.
181 gfx::ImageSkia GetIconForTest(); 196 gfx::ImageSkia GetIconForTest();
182 197
183 protected: 198 protected:
184 // Overridden from views::View: 199 // Overridden from views::View:
185 virtual void ViewHierarchyChanged( 200 virtual void ViewHierarchyChanged(
186 const ViewHierarchyChangedDetails& details) OVERRIDE; 201 const ViewHierarchyChangedDetails& details) OVERRIDE;
187 202
188 private: 203 private:
189 virtual ~BrowserActionButton(); 204 virtual ~BrowserActionButton();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 238
224 content::NotificationRegistrar registrar_; 239 content::NotificationRegistrar registrar_;
225 240
226 // The extension key binding accelerator this browser action is listening for 241 // The extension key binding accelerator this browser action is listening for
227 // (to show the popup). 242 // (to show the popup).
228 scoped_ptr<ui::Accelerator> keybinding_; 243 scoped_ptr<ui::Accelerator> keybinding_;
229 244
230 // Responsible for running the menu. 245 // Responsible for running the menu.
231 scoped_ptr<views::MenuRunner> menu_runner_; 246 scoped_ptr<views::MenuRunner> menu_runner_;
232 247
248 // The observer that we need to notify when the icon of the button has been
249 // updated.
250 IconObserver* icon_observer_;
251
233 friend class base::DeleteHelper<BrowserActionButton>; 252 friend class base::DeleteHelper<BrowserActionButton>;
234 253
235 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton); 254 DISALLOW_COPY_AND_ASSIGN(BrowserActionButton);
236 }; 255 };
237 256
238 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_ 257 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_BROWSER_ACTION_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698