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 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 // |context| is required by the underlying implementation to retrieve the | 63 // |context| is required by the underlying implementation to retrieve the |
64 // |ImageLoader| instance associated with the given context. |ImageLoader| is | 64 // |ImageLoader| instance associated with the given context. |ImageLoader| is |
65 // used to perform the asynchronous image load work. | 65 // used to perform the asynchronous image load work. |
66 IconImage(content::BrowserContext* context, | 66 IconImage(content::BrowserContext* context, |
67 const Extension* extension, | 67 const Extension* extension, |
68 const ExtensionIconSet& icon_set, | 68 const ExtensionIconSet& icon_set, |
69 int resource_size_in_dip, | 69 int resource_size_in_dip, |
70 const gfx::ImageSkia& default_icon, | 70 const gfx::ImageSkia& default_icon, |
71 Observer* observer); | 71 Observer* observer); |
72 virtual ~IconImage(); | 72 ~IconImage() override; |
73 | 73 |
74 const gfx::ImageSkia& image_skia() const { return image_skia_; } | 74 const gfx::ImageSkia& image_skia() const { return image_skia_; } |
75 | 75 |
76 private: | 76 private: |
77 class Source; | 77 class Source; |
78 | 78 |
79 // Loads an image representation for the scale factor. | 79 // Loads an image representation for the scale factor. |
80 // If the representation gets loaded synchronously, it is returned by this | 80 // If the representation gets loaded synchronously, it is returned by this |
81 // method. | 81 // method. |
82 // If representation loading is asynchronous, an empty image | 82 // If representation loading is asynchronous, an empty image |
83 // representation is returned. When the representation gets loaded the | 83 // representation is returned. When the representation gets loaded the |
84 // observer's |OnExtensionIconImageLoaded| will be called. | 84 // observer's |OnExtensionIconImageLoaded| will be called. |
85 gfx::ImageSkiaRep LoadImageForScaleFactor(ui::ScaleFactor scale_factor); | 85 gfx::ImageSkiaRep LoadImageForScaleFactor(ui::ScaleFactor scale_factor); |
86 | 86 |
87 void OnImageLoaded(float scale_factor, const gfx::Image& image); | 87 void OnImageLoaded(float scale_factor, const gfx::Image& image); |
88 | 88 |
89 // content::NotificationObserver overrides: | 89 // content::NotificationObserver overrides: |
90 virtual void Observe(int type, | 90 void Observe(int type, |
91 const content::NotificationSource& source, | 91 const content::NotificationSource& source, |
92 const content::NotificationDetails& details) override; | 92 const content::NotificationDetails& details) override; |
93 | 93 |
94 content::BrowserContext* browser_context_; | 94 content::BrowserContext* browser_context_; |
95 const Extension* extension_; | 95 const Extension* extension_; |
96 const ExtensionIconSet& icon_set_; | 96 const ExtensionIconSet& icon_set_; |
97 const int resource_size_in_dip_; | 97 const int resource_size_in_dip_; |
98 | 98 |
99 Observer* observer_; | 99 Observer* observer_; |
100 | 100 |
101 Source* source_; // Owned by ImageSkia storage. | 101 Source* source_; // Owned by ImageSkia storage. |
102 gfx::ImageSkia image_skia_; | 102 gfx::ImageSkia image_skia_; |
103 // The icon with whose representation |image_skia_| should be updated if | 103 // The icon with whose representation |image_skia_| should be updated if |
104 // its own representation load fails. | 104 // its own representation load fails. |
105 gfx::ImageSkia default_icon_; | 105 gfx::ImageSkia default_icon_; |
106 | 106 |
107 content::NotificationRegistrar registrar_; | 107 content::NotificationRegistrar registrar_; |
108 | 108 |
109 base::WeakPtrFactory<IconImage> weak_ptr_factory_; | 109 base::WeakPtrFactory<IconImage> weak_ptr_factory_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(IconImage); | 111 DISALLOW_COPY_AND_ASSIGN(IconImage); |
112 }; | 112 }; |
113 | 113 |
114 } // namespace extensions | 114 } // namespace extensions |
115 | 115 |
116 #endif // EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ | 116 #endif // EXTENSIONS_BROWSER_EXTENSION_ICON_IMAGE_H_ |
OLD | NEW |