| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ |
| 6 #define EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 16 #include "extensions/common/extension_icon_set.h" | 16 #include "extensions/common/extension_icon_set.h" |
| 17 #include "ui/base/layout.h" | 17 #include "ui/base/layout.h" |
| 18 #include "ui/gfx/image/image.h" |
| 18 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 19 | 20 |
| 20 namespace content { | 21 namespace content { |
| 21 class BrowserContext; | 22 class BrowserContext; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace extensions { | 25 namespace extensions { |
| 25 class Extension; | 26 class Extension; |
| 26 } | 27 } |
| 27 | 28 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // |ImageLoader| instance associated with the given context. |ImageLoader| is | 69 // |ImageLoader| instance associated with the given context. |ImageLoader| is |
| 69 // used to perform the asynchronous image load work. | 70 // used to perform the asynchronous image load work. |
| 70 IconImage(content::BrowserContext* context, | 71 IconImage(content::BrowserContext* context, |
| 71 const Extension* extension, | 72 const Extension* extension, |
| 72 const ExtensionIconSet& icon_set, | 73 const ExtensionIconSet& icon_set, |
| 73 int resource_size_in_dip, | 74 int resource_size_in_dip, |
| 74 const gfx::ImageSkia& default_icon, | 75 const gfx::ImageSkia& default_icon, |
| 75 Observer* observer); | 76 Observer* observer); |
| 76 ~IconImage() override; | 77 ~IconImage() override; |
| 77 | 78 |
| 79 gfx::Image image() const { return image_; } |
| 78 const gfx::ImageSkia& image_skia() const { return image_skia_; } | 80 const gfx::ImageSkia& image_skia() const { return image_skia_; } |
| 79 | 81 |
| 80 void AddObserver(Observer* observer); | 82 void AddObserver(Observer* observer); |
| 81 void RemoveObserver(Observer* observer); | 83 void RemoveObserver(Observer* observer); |
| 82 | 84 |
| 83 private: | 85 private: |
| 84 class Source; | 86 class Source; |
| 85 | 87 |
| 86 // Loads an image representation for the scale factor. | 88 // Loads an image representation for the scale factor. |
| 87 // If the representation gets loaded synchronously, it is returned by this | 89 // If the representation gets loaded synchronously, it is returned by this |
| (...skipping 16 matching lines...) Expand all Loading... |
| 104 const int resource_size_in_dip_; | 106 const int resource_size_in_dip_; |
| 105 | 107 |
| 106 ObserverList<Observer> observers_; | 108 ObserverList<Observer> observers_; |
| 107 | 109 |
| 108 Source* source_; // Owned by ImageSkia storage. | 110 Source* source_; // Owned by ImageSkia storage. |
| 109 gfx::ImageSkia image_skia_; | 111 gfx::ImageSkia image_skia_; |
| 110 // The icon with whose representation |image_skia_| should be updated if | 112 // The icon with whose representation |image_skia_| should be updated if |
| 111 // its own representation load fails. | 113 // its own representation load fails. |
| 112 gfx::ImageSkia default_icon_; | 114 gfx::ImageSkia default_icon_; |
| 113 | 115 |
| 116 // The image wrapper around |image_skia_|. |
| 117 // Note: this is reset each time a new representation is loaded. |
| 118 gfx::Image image_; |
| 119 |
| 114 content::NotificationRegistrar registrar_; | 120 content::NotificationRegistrar registrar_; |
| 115 | 121 |
| 116 base::WeakPtrFactory<IconImage> weak_ptr_factory_; | 122 base::WeakPtrFactory<IconImage> weak_ptr_factory_; |
| 117 | 123 |
| 118 DISALLOW_COPY_AND_ASSIGN(IconImage); | 124 DISALLOW_COPY_AND_ASSIGN(IconImage); |
| 119 }; | 125 }; |
| 120 | 126 |
| 121 } // namespace extensions | 127 } // namespace extensions |
| 122 | 128 |
| 123 #endif // EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ | 129 #endif // EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ |
| OLD | NEW |