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

Side by Side Diff: chrome/browser/extensions/extension_action_icon_factory.h

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: icon_factory: NULL check on the observer Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/extensions/extension_icon_image.h"
10
11 class ExtensionAction;
12 class ExtensionIconSet;
13
14 namespace extensions {
15 class Extension;
16 }
17
18 // Used to get an icon to be used in the UI for an extension action.
19 // If the extension action icon is the default icon defined in the extension's
20 // manifest, it is loaded using extensions::IconImage. This icon can be loaded
21 // asynchronously. The factory observes underlying IconImage and notifies its
22 // own observer when the icon image changes.
23 class ExtensionActionIconFactory : public extensions::IconImage::Observer {
24 public:
25 class Observer {
26 public:
27 virtual ~Observer() {}
28 // Called when the underlying icon image changes.
29 virtual void OnIconUpdated() = 0;
30 };
31
32 // Observer should outlive this.
33 ExtensionActionIconFactory(const extensions::Extension* extension,
34 Observer* observer);
35 virtual ~ExtensionActionIconFactory();
36
37 // extensions::IconImage override.
38 virtual void OnExtensionIconImageChanged(
39 extensions::IconImage* image) OVERRIDE;
40
41 // Gets the extension action icon for the tab.
42 // If there is an icon set using |SetIcon|, that icon is returned.
43 // Else, if there is a default icon set for the extension action, the icon is
44 // created using IconImage. Observer is triggered wheniever the icon gets
45 // updated.
46 // Else, extension favicon is returned.
47 // In all cases, action's attention and animation icon transformations are
48 // applied on the icon.
49 gfx::Image GetIcon(const ExtensionAction* action, int tab_id);
50
51 private:
52 // Gets the icon that should be returned by |GetIcon| (without the attention
53 // and animation transformations).
54 gfx::ImageSkia GetBaseIconFromAction(const ExtensionAction* action,
55 int tab_id);
56
57 const extensions::Extension* extension_;
58 Observer* observer_;
59 // Underlying icon image for the default icon.
60 scoped_ptr<extensions::IconImage> icon_;
61
62 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactory);
63 };
64
65 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698