Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Unified Diff: chrome/browser/extensions/extension_icon_image.h

Issue 10861034: Supply default icon to extension icon image. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_icon_image.h
diff --git a/chrome/browser/extensions/extension_icon_image.h b/chrome/browser/extensions/extension_icon_image.h
index c2f98526e4224985aa7fdbe983876f76b9af956e..1c2e04870905832bae40e863235fa2d3ccf2d4ed 100644
--- a/chrome/browser/extensions/extension_icon_image.h
+++ b/chrome/browser/extensions/extension_icon_image.h
@@ -31,7 +31,12 @@ namespace extensions {
// should be outlived by the observer. In painting code, UI code paints with the
// ImageSkia provided by this class. If required extension icon resource is not
// present, this class uses ImageLoadingTracker to load it and call on its
-// observer interface when the resource is loaded.
+// observer interface when the resource is loaded. Until the resource is loaded,
+// the UI code will be provided with blank, transparent image representation.
+// UI code can supply default icon whose representations will be added to the
+// icon if icon's own representation for some scale factor cannot be loaded.
pkotwicz 2012/08/28 18:56:57 Nit: if a representation for some scale factor can
tbarzic 2012/08/29 18:41:28 Done.
+// If default icon is supplied, it is assumed that it contains representations
+// for all the scale factors we need.
pkotwicz 2012/08/28 18:56:57 Nit: scale factors we need -> scale factors suppor
tbarzic 2012/08/29 18:41:28 Done.
class IconImage : public ImageLoadingTracker::Observer,
public content::NotificationObserver {
public:
@@ -41,10 +46,6 @@ class IconImage : public ImageLoadingTracker::Observer,
// is loaded and added to |image|.
virtual void OnExtensionIconImageChanged(IconImage* image) = 0;
- // Invoked when the icon image couldn't be loaded.
- virtual void OnIconImageLoadFailed(IconImage* image,
- ui::ScaleFactor scale_factor) = 0;
-
protected:
virtual ~Observer() {}
};
@@ -52,6 +53,7 @@ class IconImage : public ImageLoadingTracker::Observer,
IconImage(const Extension* extension,
const ExtensionIconSet& icon_set,
int resource_size_in_dip,
+ const gfx::ImageSkia& default_icon,
Observer* observer);
virtual ~IconImage();
@@ -60,10 +62,15 @@ class IconImage : public ImageLoadingTracker::Observer,
private:
class Source;
- typedef std::map<int, ui::ScaleFactor> LoadMap;
+ struct LoadRequest {
+ ui::ScaleFactor scale_factor;
+ bool is_async;
+ };
+
+ typedef std::map<int, LoadRequest> LoadMap;
// Loads bitmap for additional scale factor.
- void LoadImageForScaleFactor(ui::ScaleFactor scale_factor);
+ gfx::ImageSkiaRep LoadImageForScaleFactor(ui::ScaleFactor scale_factor);
// ImageLoadingTracker::Observer overrides:
virtual void OnImageLoaded(const gfx::Image& image,
@@ -84,6 +91,9 @@ class IconImage : public ImageLoadingTracker::Observer,
Source* source_; // Owned by ImageSkia storage.
gfx::ImageSkia image_skia_;
+ // The icon with whose representation |image_skia_| should be updated if
+ // its own representation load fails.
+ gfx::ImageSkia default_icon_;
ImageLoadingTracker tracker_;
content::NotificationRegistrar registrar_;
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_icon_image.cc » ('j') | chrome/browser/extensions/extension_icon_image.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698