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

Side by Side 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: rebase 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "chrome/browser/extensions/image_loading_tracker.h"
13 #include "chrome/common/extensions/extension_icon_set.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "ui/gfx/image/image_skia.h"
17
18 namespace extensions {
19 class Extension;
20 }
21
22 namespace gfx {
23 class Size;
24 }
25
26 class ExtensionIconImageDelegate;
Aaron Boodman 2012/08/02 17:50:56 Can the delegate be defined as a nested class inst
tbarzic 2012/08/02 20:12:52 Done.
27
28 // A class that provides an ImageSkia for UI code to use. It handles extension
29 // icon resource loading, screen scale factor change etc. UI code that uses
30 // extension icon should host this class and be its delegate. ExtensionIconImage
31 // should be outlived by the delegate. In painting code, UI code paints with the
32 // ImageSkia provided by this class. If required extension icon resource is not
33 // present, this class uses ImageLoadingTracker to load it and call on its
34 // delegate interface when the resource is loaded.
35 class ExtensionIconImage : public ImageLoadingTracker::Observer,
Aaron Boodman 2012/08/02 17:50:56 Please put this in the extensions namespace and re
tbarzic 2012/08/02 20:12:52 Done.
36 public content::NotificationObserver {
37 public:
38 ExtensionIconImage(const extensions::Extension* extension,
39 const ExtensionIconSet& icon_set,
40 int resource_size_in_dip,
41 ExtensionIconSet::MatchType resource_match_type,
42 const gfx::Size& desired_size_in_dip,
43 ImageLoadingTracker::CacheParam cache_param,
44 ExtensionIconImageDelegate* delegate);
45 virtual ~ExtensionIconImage();
46
47 // True if no images can be loaded. This does not imply any images have
Aaron Boodman 2012/08/02 17:50:56 The second sentence of this comment makes no sense
tbarzic 2012/08/02 20:12:52 Yeah, it made (slightly) more sense when the metho
48 // actually been loaded.
49 bool IsNull() const { return image_skia_.isNull(); }
50
51 const gfx::ImageSkia& image_skia() const { return image_skia_; }
52
53 private:
54 class Source;
55 typedef std::map<int, ui::ScaleFactor> LoadMap;
56
57 // Loads bitmap for additional scale factor.
58 void LoadImageForScaleFactor(ui::ScaleFactor scale_factor);
59
60 // ImageLoadingTracker::Observer overrides:
61 virtual void OnImageLoaded(const gfx::Image& image,
62 const std::string& extension_id,
63 int index) OVERRIDE;
64
65 // content::NotificationObserver overrides:
66 virtual void Observe(int type,
67 const content::NotificationSource& source,
68 const content::NotificationDetails& details) OVERRIDE;
69
70 const extensions::Extension* extension_;
71 const ExtensionIconSet& icon_set_;
72 const int resource_size_in_dip_;
73 const ExtensionIconSet::MatchType resource_match_type_;
74 const gfx::Size desired_size_in_dip_;
75 const ImageLoadingTracker::CacheParam cache_param_;
76
77 ExtensionIconImageDelegate* delegate_;
78
79 Source* source_; // Owned by ImageSkia storage.
80 gfx::ImageSkia image_skia_;
81
82 ImageLoadingTracker tracker_;
83 content::NotificationRegistrar registrar_;
84
85 LoadMap load_map_;
86
87 DISALLOW_COPY_AND_ASSIGN(ExtensionIconImage);
88 };
89
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ICON_IMAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698