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