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

Side by Side Diff: chrome/browser/ui/webui/extensions/extension_icon_source.h

Issue 25050005: Refactored loading of applications / extensions icons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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
OLDNEW
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_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int render_process_id, 77 int render_process_id,
78 int render_view_id, 78 int render_view_id,
79 const content::URLDataSource::GotDataCallback& callback) OVERRIDE; 79 const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
80 80
81 private: 81 private:
82 // Encapsulates the request parameters for |request_id|. 82 // Encapsulates the request parameters for |request_id|.
83 struct ExtensionIconRequest; 83 struct ExtensionIconRequest;
84 84
85 virtual ~ExtensionIconSource(); 85 virtual ~ExtensionIconSource();
86 86
87 // Returns the bitmap for the default app image. 87 // Loads the extension's icon for the given |request_id| and returns the
88 const SkBitmap* GetDefaultAppImage(); 88 // image to the client.
89 void LoadExtensionImage(int request_id);
89 90
90 // Returns the bitmap for the default extension. 91 // LoadExtensionImage() will load the icon using
91 const SkBitmap* GetDefaultExtensionImage(); 92 // ImageLoader::LoadExtensionIconAsync(). OnIconLoaded
Finnur 2013/09/30 15:11:21 OnIconLoaded... what? :)
dvh-g 2013/10/01 04:19:26 Done.
92 93 void OnIconLoaded(int request_id, const gfx::Image& image);
93 // Performs any remaining transformations (like desaturating the |image|),
94 // then returns the |image| to the client and clears up any temporary data
95 // associated with the |request_id|.
96 void FinalizeImage(const SkBitmap* image, int request_id);
97
98 // Loads the default image for |request_id| and returns to the client.
99 void LoadDefaultImage(int request_id);
100
101 // Loads the extension's |icon| for the given |request_id| and returns the
102 // image to the client.
103 void LoadExtensionImage(const ExtensionResource& icon,
104 int request_id);
105
106 // Loads the favicon image for the app associated with the |request_id|. If
107 // the image does not exist, we fall back to the default image.
108 void LoadFaviconImage(int request_id);
109
110 // FaviconService callback
111 void OnFaviconDataAvailable(
112 int request_id,
113 const chrome::FaviconBitmapResult& bitmap_result);
114
115 // ImageLoader callback
116 void OnImageLoaded(int request_id, const gfx::Image& image);
117
118 // Called when the extension doesn't have an icon. We fall back to multiple
119 // sources, using the following order:
120 // 1) The icons as listed in the extension / app manifests.
121 // 2) If a 16px icon and the extension has a launch URL, see if Chrome
122 // has a corresponding favicon.
123 // 3) If still no matches, load the default extension / application icon.
124 void LoadIconFailed(int request_id);
125 94
126 // Parses and savse an ExtensionIconRequest for the URL |path| for the 95 // Parses and savse an ExtensionIconRequest for the URL |path| for the
127 // specified |request_id|. 96 // specified |request_id|.
128 bool ParseData(const std::string& path, 97 bool ParseData(const std::string& path,
129 int request_id, 98 int request_id,
130 const content::URLDataSource::GotDataCallback& callback); 99 const content::URLDataSource::GotDataCallback& callback);
131 100
132 // Stores the parameters associated with the |request_id|, making them 101 // Stores the parameters associated with the |request_id|, making them
133 // as an ExtensionIconRequest via GetData. 102 // as an ExtensionIconRequest via GetData.
134 void SetData(int request_id, 103 void SetData(int request_id,
135 const content::URLDataSource::GotDataCallback& callback, 104 const content::URLDataSource::GotDataCallback& callback,
136 const Extension* extension, 105 const Extension* extension,
137 bool grayscale, 106 bool grayscale,
138 int size, 107 int size,
139 ExtensionIconSet::MatchType match); 108 ExtensionIconSet::MatchType match);
140 109
141 // Returns the ExtensionIconRequest for the given |request_id|. 110 // Returns the ExtensionIconRequest for the given |request_id|.
142 ExtensionIconRequest* GetData(int request_id); 111 ExtensionIconRequest* GetData(int request_id);
143 112
144 // Removes temporary data associated with |request_id|. 113 // Removes temporary data associated with |request_id|.
145 void ClearData(int request_id); 114 void ClearData(int request_id);
146 115
147 Profile* profile_; 116 Profile* profile_;
148 117
149 // Maps tracker ids to request ids.
150 std::map<int, int> tracker_map_;
151
152 // Maps request_ids to ExtensionIconRequests. 118 // Maps request_ids to ExtensionIconRequests.
153 std::map<int, ExtensionIconRequest*> request_map_; 119 std::map<int, ExtensionIconRequest*> request_map_;
154 120
155 scoped_ptr<SkBitmap> default_app_data_;
156
157 scoped_ptr<SkBitmap> default_extension_data_;
158
159 CancelableTaskTracker cancelable_task_tracker_;
160
161 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource); 121 DISALLOW_COPY_AND_ASSIGN(ExtensionIconSource);
162 }; 122 };
163 123
164 } // namespace extensions 124 } // namespace extensions
165 125
166 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_ 126 #endif // CHROME_BROWSER_UI_WEBUI_EXTENSIONS_EXTENSION_ICON_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698