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

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: disable unittest on android 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 const ExtensionAction* action,
35 Observer* observer);
36 virtual ~ExtensionActionIconFactory();
37
38 // extensions::IconImage override.
39 virtual void OnExtensionIconImageChanged(
40 extensions::IconImage* image) OVERRIDE;
41
42 // Gets the extension action icon for the tab.
43 // If there is an icon set using |SetIcon|, that icon is returned.
44 // Else, if there is a default icon set for the extension action, the icon is
45 // created using IconImage. Observer is triggered wheniever the icon gets
46 // updated.
47 // Else, extension favicon is returned.
48 // In all cases, action's attention and animation icon transformations are
49 // applied on the icon.
50 gfx::Image GetIcon(int tab_id);
51
52 private:
53 // Gets the icon that should be returned by |GetIcon| (without the attention
54 // and animation transformations).
55 gfx::ImageSkia GetBaseIconFromAction(int tab_id);
56
57 const extensions::Extension* extension_;
58 const ExtensionAction* action_;
59 Observer* observer_;
60 // Underlying icon image for the default icon.
61 scoped_ptr<extensions::IconImage> default_icon_;
62
63 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactory);
64 };
65
66 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698