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

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

Issue 10825012: chromeos: Fix pixelated icons in app list and launcher (part 2) (by xiyuan) (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
new file mode 100644
index 0000000000000000000000000000000000000000..dfa2e5a358c0804a26a43592e2c4f1fe0c123e75
--- /dev/null
+++ b/chrome/browser/extensions/extension_icon_image.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_
+
+#include <map>
+#include <string>
+
+#include "base/basictypes.h"
+#include "chrome/browser/extensions/image_loading_tracker.h"
+#include "chrome/common/extensions/extension_icon_set.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "ui/gfx/image/image_skia.h"
+
+namespace extensions {
+class Extension;
+}
+
+namespace gfx {
+class Size;
+}
+
+namespace extensions {
+
+// A class that provides an ImageSkia for UI code to use. It handles extension
+// icon resource loading, screen scale factor change etc. UI code that uses
+// extension icon should host this class and be its delegate. ExtensionIconImage
+// should be outlived by the delegate. 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
+// delegate interface when the resource is loaded.
+class IconImage : public ImageLoadingTracker::Observer,
+ public content::NotificationObserver {
+ public:
+ class Delegate {
oshima 2012/08/07 07:43:05 This should probably called Observer instead of De
tbarzic 2012/08/07 18:10:26 Done.
+ public:
+ // Invoked when |image| is updated with image reps for additional scale
+ // factors.
oshima 2012/08/07 07:43:05 How about // Invoked when a new image reps for add
tbarzic 2012/08/07 18:10:26 Done.
+ virtual void OnExtensionIconImageChanged(IconImage* image) = 0;
+
+ protected:
+ virtual ~Delegate() {}
+ };
+
+ IconImage(const Extension* extension,
+ const ExtensionIconSet& icon_set,
+ int resource_size_in_dip,
+ ExtensionIconSet::MatchType resource_match_type,
+ const gfx::Size& desired_size_in_dip,
+ ImageLoadingTracker::CacheParam cache_param,
+ Delegate* delegate);
+ virtual ~IconImage();
+
+ const gfx::ImageSkia& image_skia() const { return image_skia_; }
+
+ private:
+ class Source;
+ typedef std::map<int, ui::ScaleFactor> LoadMap;
+
+ // Loads bitmap for additional scale factor.
+ void LoadImageForScaleFactor(ui::ScaleFactor scale_factor);
+
+ // ImageLoadingTracker::Observer overrides:
+ virtual void OnImageLoaded(const gfx::Image& image,
+ const std::string& extension_id,
+ int index) OVERRIDE;
+
+ // content::NotificationObserver overrides:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ const Extension* extension_;
+ const ExtensionIconSet& icon_set_;
+ const int resource_size_in_dip_;
+ const ExtensionIconSet::MatchType resource_match_type_;
+ const gfx::Size desired_size_in_dip_;
+ const ImageLoadingTracker::CacheParam cache_param_;
+
+ Delegate* delegate_;
+
+ Source* source_; // Owned by ImageSkia storage.
+ gfx::ImageSkia image_skia_;
+
+ ImageLoadingTracker tracker_;
+ content::NotificationRegistrar registrar_;
+
+ LoadMap load_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(IconImage);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_

Powered by Google App Engine
This is Rietveld 408576698