| 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_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "extensions/browser/extension_icon_image.h" | 9 #include "extensions/browser/extension_icon_image.h" |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 virtual ~Observer() {} | 28 virtual ~Observer() {} |
| 29 // Called when the underlying icon image changes. | 29 // Called when the underlying icon image changes. |
| 30 virtual void OnIconUpdated() = 0; | 30 virtual void OnIconUpdated() = 0; |
| 31 }; | 31 }; |
| 32 | 32 |
| 33 // Observer should outlive this. | 33 // Observer should outlive this. |
| 34 ExtensionActionIconFactory(Profile* profile, | 34 ExtensionActionIconFactory(Profile* profile, |
| 35 const extensions::Extension* extension, | 35 const extensions::Extension* extension, |
| 36 const ExtensionAction* action, | 36 const ExtensionAction* action, |
| 37 Observer* observer); | 37 Observer* observer); |
| 38 virtual ~ExtensionActionIconFactory(); | 38 ~ExtensionActionIconFactory() override; |
| 39 | 39 |
| 40 // extensions::IconImage override. | 40 // extensions::IconImage override. |
| 41 virtual void OnExtensionIconImageChanged( | 41 void OnExtensionIconImageChanged(extensions::IconImage* image) override; |
| 42 extensions::IconImage* image) override; | |
| 43 | 42 |
| 44 // Gets the extension action icon for the tab. | 43 // Gets the extension action icon for the tab. |
| 45 // If there is an icon set using |SetIcon|, that icon is returned. | 44 // If there is an icon set using |SetIcon|, that icon is returned. |
| 46 // Else, if there is a default icon set for the extension action, the icon is | 45 // Else, if there is a default icon set for the extension action, the icon is |
| 47 // created using IconImage. Observer is triggered wheniever the icon gets | 46 // created using IconImage. Observer is triggered wheniever the icon gets |
| 48 // updated. | 47 // updated. |
| 49 // Else, extension favicon is returned. | 48 // Else, extension favicon is returned. |
| 50 // In all cases, action's attention and animation icon transformations are | 49 // In all cases, action's attention and animation icon transformations are |
| 51 // applied on the icon. | 50 // applied on the icon. |
| 52 gfx::Image GetIcon(int tab_id); | 51 gfx::Image GetIcon(int tab_id); |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 // Gets the icon that should be returned by |GetIcon| (without the attention | 54 // Gets the icon that should be returned by |GetIcon| (without the attention |
| 56 // and animation transformations). | 55 // and animation transformations). |
| 57 gfx::ImageSkia GetBaseIconFromAction(int tab_id); | 56 gfx::ImageSkia GetBaseIconFromAction(int tab_id); |
| 58 | 57 |
| 59 const extensions::Extension* extension_; | 58 const extensions::Extension* extension_; |
| 60 const ExtensionAction* action_; | 59 const ExtensionAction* action_; |
| 61 Observer* observer_; | 60 Observer* observer_; |
| 62 // Underlying icon image for the default icon. | 61 // Underlying icon image for the default icon. |
| 63 scoped_ptr<extensions::IconImage> default_icon_; | 62 scoped_ptr<extensions::IconImage> default_icon_; |
| 64 | 63 |
| 65 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactory); | 64 DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactory); |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_ | 67 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_ |
| OLD | NEW |