| 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_ICON_IMAGE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_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 "chrome/common/extensions/extension_icon_set.h" | 13 #include "chrome/common/extensions/extension_icon_set.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 "ui/base/layout.h" |
| 16 #include "ui/gfx/image/image_skia.h" | 17 #include "ui/gfx/image/image_skia.h" |
| 17 | 18 |
| 18 class Profile; | 19 class Profile; |
| 19 | 20 |
| 20 namespace extensions { | 21 namespace extensions { |
| 21 class Extension; | 22 class Extension; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace gfx { | 25 namespace gfx { |
| 25 class Size; | 26 class Size; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 class Source; | 75 class Source; |
| 75 | 76 |
| 76 // Loads an image representation for the scale factor. | 77 // Loads an image representation for the scale factor. |
| 77 // If the representation gets loaded synchronously, it is returned by this | 78 // If the representation gets loaded synchronously, it is returned by this |
| 78 // method. | 79 // method. |
| 79 // If representation loading is asynchronous, an empty image | 80 // If representation loading is asynchronous, an empty image |
| 80 // representation is returned. When the representation gets loaded the | 81 // representation is returned. When the representation gets loaded the |
| 81 // observer's |OnExtensionIconImageLoaded| will be called. | 82 // observer's |OnExtensionIconImageLoaded| will be called. |
| 82 gfx::ImageSkiaRep LoadImageForScaleFactor(ui::ScaleFactor scale_factor); | 83 gfx::ImageSkiaRep LoadImageForScaleFactor(ui::ScaleFactor scale_factor); |
| 83 | 84 |
| 84 void OnImageLoaded(ui::ScaleFactor scale_factor, const gfx::Image& image); | 85 void OnImageLoaded(float scale_factor, const gfx::Image& image); |
| 85 | 86 |
| 86 // content::NotificationObserver overrides: | 87 // content::NotificationObserver overrides: |
| 87 virtual void Observe(int type, | 88 virtual void Observe(int type, |
| 88 const content::NotificationSource& source, | 89 const content::NotificationSource& source, |
| 89 const content::NotificationDetails& details) OVERRIDE; | 90 const content::NotificationDetails& details) OVERRIDE; |
| 90 | 91 |
| 91 Profile* profile_; | 92 Profile* profile_; |
| 92 const Extension* extension_; | 93 const Extension* extension_; |
| 93 const ExtensionIconSet& icon_set_; | 94 const ExtensionIconSet& icon_set_; |
| 94 const int resource_size_in_dip_; | 95 const int resource_size_in_dip_; |
| 95 | 96 |
| 96 Observer* observer_; | 97 Observer* observer_; |
| 97 | 98 |
| 98 Source* source_; // Owned by ImageSkia storage. | 99 Source* source_; // Owned by ImageSkia storage. |
| 99 gfx::ImageSkia image_skia_; | 100 gfx::ImageSkia image_skia_; |
| 100 // The icon with whose representation |image_skia_| should be updated if | 101 // The icon with whose representation |image_skia_| should be updated if |
| 101 // its own representation load fails. | 102 // its own representation load fails. |
| 102 gfx::ImageSkia default_icon_; | 103 gfx::ImageSkia default_icon_; |
| 103 | 104 |
| 104 content::NotificationRegistrar registrar_; | 105 content::NotificationRegistrar registrar_; |
| 105 | 106 |
| 106 base::WeakPtrFactory<IconImage> weak_ptr_factory_; | 107 base::WeakPtrFactory<IconImage> weak_ptr_factory_; |
| 107 | 108 |
| 108 DISALLOW_COPY_AND_ASSIGN(IconImage); | 109 DISALLOW_COPY_AND_ASSIGN(IconImage); |
| 109 }; | 110 }; |
| 110 | 111 |
| 111 } // namespace extensions | 112 } // namespace extensions |
| 112 | 113 |
| 113 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_ | 114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_ |
| OLD | NEW |