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

Side by Side Diff: chrome/browser/extensions/image_loading_tracker.cc

Issue 10701087: chromeos: Fix pixelated icons in app list and launcher (part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address oshima's comments from http://codereview.chromium.org/10699065/ Created 8 years, 5 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
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 #include "chrome/browser/extensions/image_loading_tracker.h" 5 #include "chrome/browser/extensions/image_loading_tracker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 12 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
15 #include "chrome/common/extensions/extension_constants.h" 15 #include "chrome/common/extensions/extension_constants.h"
16 #include "chrome/common/extensions/extension_icon_set.h"
16 #include "chrome/common/extensions/extension_resource.h" 17 #include "chrome/common/extensions/extension_resource.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
19 #include "grit/component_extension_resources_map.h" 20 #include "grit/component_extension_resources_map.h"
20 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
21 #include "skia/ext/image_operations.h" 22 #include "skia/ext/image_operations.h"
22 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
23 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
24 #include "ui/gfx/image/image_skia.h"
25 #include "ui/gfx/image/image_skia_rep.h" 25 #include "ui/gfx/image/image_skia_rep.h"
26 #include "ui/gfx/screen.h"
26 #include "webkit/glue/image_decoder.h" 27 #include "webkit/glue/image_decoder.h"
27 28
28 using content::BrowserThread; 29 using content::BrowserThread;
29 using extensions::Extension; 30 using extensions::Extension;
30 31
31 //////////////////////////////////////////////////////////////////////////////// 32 ////////////////////////////////////////////////////////////////////////////////
32 // ImageLoadingTracker::Observer 33 // ImageLoadingTracker::Observer
33 34
34 ImageLoadingTracker::Observer::~Observer() {} 35 ImageLoadingTracker::Observer::~Observer() {}
35 36
36 //////////////////////////////////////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////////////////////////
37 // ImageLoadingTracker::ImageInfo 38 // ImageLoadingTracker::ImageInfo
38 39
39 ImageLoadingTracker::ImageInfo::ImageInfo( 40 ImageLoadingTracker::ImageInfo::ImageInfo(
40 const ExtensionResource& resource, gfx::Size max_size) 41 const ExtensionResource& resource,
41 : resource(resource), max_size(max_size) { 42 const gfx::Size& max_size,
43 ui::ScaleFactor scale_factor)
44 : resource(resource),
45 max_size(max_size),
46 scale_factor(scale_factor) {
42 } 47 }
43 48
44 ImageLoadingTracker::ImageInfo::~ImageInfo() { 49 ImageLoadingTracker::ImageInfo::~ImageInfo() {
45 } 50 }
46 51
47 //////////////////////////////////////////////////////////////////////////////// 52 ////////////////////////////////////////////////////////////////////////////////
48 // ImageLoadingTracker::PendingLoadInfo 53 // ImageLoadingTracker::PendingLoadInfo
49 54
50 ImageLoadingTracker::PendingLoadInfo::PendingLoadInfo() 55 ImageLoadingTracker::PendingLoadInfo::PendingLoadInfo()
51 : extension(NULL), 56 : extension(NULL),
(...skipping 17 matching lines...) Expand all
69 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); 74 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE));
70 } 75 }
71 76
72 // Lets this class know that the tracker is no longer interested in the 77 // Lets this class know that the tracker is no longer interested in the
73 // results. 78 // results.
74 void StopTracking() { 79 void StopTracking() {
75 tracker_ = NULL; 80 tracker_ = NULL;
76 } 81 }
77 82
78 // Instructs the loader to load a task on the File thread. 83 // Instructs the loader to load a task on the File thread.
79 void LoadImage(const ExtensionResource& resource, 84 void LoadImage(const ImageInfo& image_info, int id) {
80 const gfx::Size& max_size,
81 int id) {
82 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); 85 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE));
83 BrowserThread::PostTask( 86 BrowserThread::PostTask(
84 BrowserThread::FILE, FROM_HERE, 87 BrowserThread::FILE, FROM_HERE,
85 base::Bind(&ImageLoader::LoadOnFileThread, this, resource, 88 base::Bind(&ImageLoader::LoadOnFileThread, this, image_info, id));
86 max_size, id));
87 } 89 }
88 90
89 void LoadOnFileThread(const ExtensionResource& resource, 91 void LoadOnFileThread(const ImageInfo& image_info, int id) {
90 const gfx::Size& max_size,
91 int id) {
92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 92 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
93 93
94 // Read the file from disk. 94 // Read the file from disk.
95 std::string file_contents; 95 std::string file_contents;
96 FilePath path = resource.GetFilePath(); 96 FilePath path = image_info.resource.GetFilePath();
97 if (path.empty() || !file_util::ReadFileToString(path, &file_contents)) { 97 if (path.empty() || !file_util::ReadFileToString(path, &file_contents)) {
98 ReportBack(NULL, resource, gfx::Size(), id); 98 ReportBack(NULL, image_info, gfx::Size(), id);
99 return; 99 return;
100 } 100 }
101 101
102 // Decode the image using WebKit's image decoder. 102 // Decode the image using WebKit's image decoder.
103 const unsigned char* data = 103 const unsigned char* data =
104 reinterpret_cast<const unsigned char*>(file_contents.data()); 104 reinterpret_cast<const unsigned char*>(file_contents.data());
105 webkit_glue::ImageDecoder decoder; 105 webkit_glue::ImageDecoder decoder;
106 scoped_ptr<SkBitmap> decoded(new SkBitmap()); 106 scoped_ptr<SkBitmap> decoded(new SkBitmap());
107 // Note: This class only decodes images from extension resources. Chrome 107 // Note: This class only decodes images from extension resources. Chrome
108 // doesn't (for security reasons) directly load extension resources provided 108 // doesn't (for security reasons) directly load extension resources provided
109 // by the extension author, but instead decodes them in a separate 109 // by the extension author, but instead decodes them in a separate
110 // locked-down utility process. Only if the decoding succeeds is the image 110 // locked-down utility process. Only if the decoding succeeds is the image
111 // saved from memory to disk and subsequently used in the Chrome UI. 111 // saved from memory to disk and subsequently used in the Chrome UI.
112 // Chrome is therefore decoding images here that were generated by Chrome. 112 // Chrome is therefore decoding images here that were generated by Chrome.
113 *decoded = decoder.Decode(data, file_contents.length()); 113 *decoded = decoder.Decode(data, file_contents.length());
114 if (decoded->empty()) { 114 if (decoded->empty()) {
115 ReportBack(NULL, resource, gfx::Size(), id); 115 ReportBack(NULL, image_info, gfx::Size(), id);
116 return; // Unable to decode. 116 return; // Unable to decode.
117 } 117 }
118 118
119 gfx::Size original_size(decoded->width(), decoded->height()); 119 gfx::Size original_size(decoded->width(), decoded->height());
120 120
121 if (decoded->width() > max_size.width() || 121 if (decoded->width() > image_info.max_size.width() ||
122 decoded->height() > max_size.height()) { 122 decoded->height() > image_info.max_size.height()) {
123 // The bitmap is too big, re-sample. 123 // The bitmap is too big, re-sample.
124 *decoded = skia::ImageOperations::Resize( 124 *decoded = skia::ImageOperations::Resize(
125 *decoded, skia::ImageOperations::RESIZE_LANCZOS3, 125 *decoded, skia::ImageOperations::RESIZE_LANCZOS3,
126 max_size.width(), max_size.height()); 126 image_info.max_size.width(), image_info.max_size.height());
127 } 127 }
128 128
129 ReportBack(decoded.release(), resource, original_size, id); 129 ReportBack(decoded.release(), image_info, original_size, id);
130 } 130 }
131 131
132 // Instructs the loader to load a resource on the File thread. 132 // Instructs the loader to load a resource on the File thread.
133 void LoadResource(const ExtensionResource& resource, 133 void LoadResource(const ImageInfo& image_info, int id, int resource_id) {
134 const gfx::Size& max_size,
135 int id,
136 int resource_id) {
137 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); 134 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE));
138 BrowserThread::PostTask( 135 BrowserThread::PostTask(
139 BrowserThread::FILE, FROM_HERE, 136 BrowserThread::FILE, FROM_HERE,
140 base::Bind(&ImageLoader::LoadResourceOnFileThread, this, resource, 137 base::Bind(&ImageLoader::LoadResourceOnFileThread, this, image_info,
141 max_size, id, resource_id)); 138 id, resource_id));
142 } 139 }
143 140
144 void LoadResourceOnFileThread(const ExtensionResource& resource, 141 void LoadResourceOnFileThread(const ImageInfo& image_info,
145 const gfx::Size& max_size,
146 int id, 142 int id,
147 int resource_id) { 143 int resource_id) {
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
149 SkBitmap* image = ExtensionIconSource::LoadImageByResourceId( 145 SkBitmap* image = ExtensionIconSource::LoadImageByResourceId(
150 resource_id); 146 resource_id);
151 ReportBack(image, resource, max_size, id); 147 ReportBack(image, image_info, image_info.max_size, id);
152 } 148 }
153 149
154 void ReportBack(SkBitmap* image, const ExtensionResource& resource, 150 void ReportBack(SkBitmap* image, const ImageInfo& image_info,
155 const gfx::Size& original_size, int id) { 151 const gfx::Size& original_size, int id) {
156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 152 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
157 153
158 BrowserThread::PostTask( 154 BrowserThread::PostTask(
159 callback_thread_id_, FROM_HERE, 155 callback_thread_id_, FROM_HERE,
160 base::Bind(&ImageLoader::ReportOnUIThread, this, 156 base::Bind(&ImageLoader::ReportOnUIThread, this,
161 image, resource, original_size, id)); 157 image, image_info, original_size, id));
162 } 158 }
163 159
164 void ReportOnUIThread(SkBitmap* image, const ExtensionResource& resource, 160 void ReportOnUIThread(SkBitmap* image, const ImageInfo& image_info,
165 const gfx::Size& original_size, int id) { 161 const gfx::Size& original_size, int id) {
166 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); 162 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE));
167 163
168 if (tracker_) 164 if (tracker_)
169 tracker_->OnImageLoaded(image, resource, original_size, id, true); 165 tracker_->OnImageLoaded(image, image_info, original_size, id, true);
170 166
171 delete image; 167 delete image;
172 } 168 }
173 169
174 private: 170 private:
175 friend class base::RefCountedThreadSafe<ImageLoader>; 171 friend class base::RefCountedThreadSafe<ImageLoader>;
176 ~ImageLoader() {} 172 ~ImageLoader() {}
177 173
178 // The tracker we are loading the image for. If NULL, it means the tracker is 174 // The tracker we are loading the image for. If NULL, it means the tracker is
179 // no longer interested in the reply. 175 // no longer interested in the reply.
(...skipping 20 matching lines...) Expand all
200 // any valid image load tasks have been posted. 196 // any valid image load tasks have been posted.
201 if (loader_) 197 if (loader_)
202 loader_->StopTracking(); 198 loader_->StopTracking();
203 } 199 }
204 200
205 void ImageLoadingTracker::LoadImage(const Extension* extension, 201 void ImageLoadingTracker::LoadImage(const Extension* extension,
206 const ExtensionResource& resource, 202 const ExtensionResource& resource,
207 const gfx::Size& max_size, 203 const gfx::Size& max_size,
208 CacheParam cache) { 204 CacheParam cache) {
209 std::vector<ImageInfo> info_list; 205 std::vector<ImageInfo> info_list;
210 info_list.push_back(ImageInfo(resource, max_size)); 206 info_list.push_back(ImageInfo(resource, max_size, ui::SCALE_FACTOR_NONE));
211 LoadImages(extension, info_list, cache); 207 LoadImages(extension, info_list, cache);
212 } 208 }
213 209
210 void ImageLoadingTracker::LoadDIPImage(
211 const extensions::Extension* extension,
212 int preferred_dip_size,
213 gfx::Size max_dip_size,
214 CacheParam cache) {
215 if (!gfx::Screen::IsDIPEnabled()) {
216 LoadImage(extension,
217 extension->GetIconResource(preferred_dip_size,
218 ExtensionIconSet::MATCH_BIGGER),
219 max_dip_size,
220 cache);
221 return;
222 }
oshima 2012/07/11 21:09:33 instead of having different code path, won't this
xiyuan 2012/07/13 18:35:46 Done.
223
224 // Always use a hi-res resource when DIP is enabled so that it is safe to
225 // complete hand off the image to the caller.
226 const ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_200P;
227 const float scale = ui::GetScaleFactorScale(scale_factor);
228 std::vector<ImageInfo> info_list;
229 info_list.push_back(ImageInfo(
230 extension->GetIconResource(static_cast<int>(preferred_dip_size * scale),
231 ExtensionIconSet::MATCH_BIGGER),
232 max_dip_size.Scale(scale),
233 scale_factor));
234 LoadImages(extension, info_list, cache);
235 }
236
214 void ImageLoadingTracker::LoadImages(const Extension* extension, 237 void ImageLoadingTracker::LoadImages(const Extension* extension,
215 const std::vector<ImageInfo>& info_list, 238 const std::vector<ImageInfo>& info_list,
216 CacheParam cache) { 239 CacheParam cache) {
217 PendingLoadInfo load_info; 240 PendingLoadInfo load_info;
218 load_info.extension = extension; 241 load_info.extension = extension;
219 load_info.cache = cache; 242 load_info.cache = cache;
220 load_info.extension_id = extension->id(); 243 load_info.extension_id = extension->id();
221 load_info.pending_count = info_list.size(); 244 load_info.pending_count = info_list.size();
222 int id = next_id_++; 245 int id = next_id_++;
223 load_map_[id] = load_info; 246 load_map_[id] = load_info;
224 247
225 for (std::vector<ImageInfo>::const_iterator it = info_list.begin(); 248 for (std::vector<ImageInfo>::const_iterator it = info_list.begin();
226 it != info_list.end(); ++it) { 249 it != info_list.end(); ++it) {
227 // Load resources for special component extensions. 250 // Load resources for special component extensions.
228 if (load_info.extension_id == extension_misc::kWebStoreAppId) { 251 if (load_info.extension_id == extension_misc::kWebStoreAppId) {
229 if (!loader_) 252 if (!loader_)
230 loader_ = new ImageLoader(this); 253 loader_ = new ImageLoader(this);
231 loader_->LoadResource(it->resource, it->max_size, id, IDR_WEBSTORE_ICON); 254 loader_->LoadResource(*it, id, IDR_WEBSTORE_ICON);
232 continue; 255 continue;
233 } else if (load_info.extension_id == extension_misc::kChromeAppId) { 256 } else if (load_info.extension_id == extension_misc::kChromeAppId) {
234 if (!loader_) 257 if (!loader_)
235 loader_ = new ImageLoader(this); 258 loader_ = new ImageLoader(this);
236 loader_->LoadResource(it->resource, 259 loader_->LoadResource(*it, id, IDR_PRODUCT_LOGO_128);
237 it->max_size,
238 id,
239 IDR_PRODUCT_LOGO_128);
240 continue; 260 continue;
241 } 261 }
242 262
243 // If we don't have a path we don't need to do any further work, just 263 // If we don't have a path we don't need to do any further work, just
244 // respond back. 264 // respond back.
245 if (it->resource.relative_path().empty()) { 265 if (it->resource.relative_path().empty()) {
246 OnImageLoaded(NULL, it->resource, it->max_size, id, false); 266 OnImageLoaded(NULL, *it, it->max_size, id, false);
247 continue; 267 continue;
248 } 268 }
249 269
250 DCHECK(extension->path() == it->resource.extension_root()); 270 DCHECK(extension->path() == it->resource.extension_root());
251 271
252 // See if the extension has the image already. 272 // See if the extension has the image already.
253 if (extension->HasCachedImage(it->resource, it->max_size)) { 273 if (extension->HasCachedImage(it->resource, it->max_size)) {
254 SkBitmap image = extension->GetCachedImage(it->resource, it->max_size); 274 SkBitmap image = extension->GetCachedImage(it->resource, it->max_size);
255 OnImageLoaded(&image, it->resource, it->max_size, id, false); 275 OnImageLoaded(&image, *it, it->max_size, id, false);
256 continue; 276 continue;
257 } 277 }
258 278
259 // Instruct the ImageLoader to load this on the File thread. LoadImage and 279 // Instruct the ImageLoader to load this on the File thread. LoadImage and
260 // LoadResource do not block. 280 // LoadResource do not block.
261 if (!loader_) 281 if (!loader_)
262 loader_ = new ImageLoader(this); 282 loader_ = new ImageLoader(this);
263 283
264 int resource_id; 284 int resource_id;
265 if (IsComponentExtensionResource(extension, it->resource, resource_id)) 285 if (IsComponentExtensionResource(extension, it->resource, resource_id))
266 loader_->LoadResource(it->resource, it->max_size, id, resource_id); 286 loader_->LoadResource(*it, id, resource_id);
267 else 287 else
268 loader_->LoadImage(it->resource, it->max_size, id); 288 loader_->LoadImage(*it, id);
269 } 289 }
270 } 290 }
271 291
272 bool ImageLoadingTracker::IsComponentExtensionResource( 292 bool ImageLoadingTracker::IsComponentExtensionResource(
273 const Extension* extension, 293 const Extension* extension,
274 const ExtensionResource& resource, 294 const ExtensionResource& resource,
275 int& resource_id) const { 295 int& resource_id) const {
276 if (extension->location() != Extension::COMPONENT) 296 if (extension->location() != Extension::COMPONENT)
277 return false; 297 return false;
278 298
279 FilePath directory_path = extension->path(); 299 FilePath directory_path = extension->path();
280 FilePath relative_path = directory_path.BaseName().Append( 300 FilePath relative_path = directory_path.BaseName().Append(
281 resource.relative_path()); 301 resource.relative_path());
282 302
283 for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) { 303 for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) {
284 FilePath resource_path = 304 FilePath resource_path =
285 FilePath().AppendASCII(kComponentExtensionResources[i].name); 305 FilePath().AppendASCII(kComponentExtensionResources[i].name);
286 resource_path = resource_path.NormalizePathSeparators(); 306 resource_path = resource_path.NormalizePathSeparators();
287 307
288 if (relative_path == resource_path) { 308 if (relative_path == resource_path) {
289 resource_id = kComponentExtensionResources[i].value; 309 resource_id = kComponentExtensionResources[i].value;
290 return true; 310 return true;
291 } 311 }
292 } 312 }
293 return false; 313 return false;
294 } 314 }
295 315
296 void ImageLoadingTracker::OnImageLoaded( 316 void ImageLoadingTracker::OnImageLoaded(
297 SkBitmap* image, 317 SkBitmap* image,
298 const ExtensionResource& resource, 318 const ImageInfo& image_info,
299 const gfx::Size& original_size, 319 const gfx::Size& original_size,
300 int id, 320 int id,
301 bool should_cache) { 321 bool should_cache) {
302 LoadMap::iterator load_map_it = load_map_.find(id); 322 LoadMap::iterator load_map_it = load_map_.find(id);
303 DCHECK(load_map_it != load_map_.end()); 323 DCHECK(load_map_it != load_map_.end());
304 PendingLoadInfo* info = &load_map_it->second; 324 PendingLoadInfo* info = &load_map_it->second;
305 325
306 // Save the pending results. 326 // Save the pending results.
307 DCHECK(info->pending_count > 0); 327 DCHECK(info->pending_count > 0);
308 info->pending_count--; 328 info->pending_count--;
309 if (image) 329 if (image) {
310 info->bitmaps.push_back(*image); 330 info->images.AddRepresentation(gfx::ImageSkiaRep(*image,
331 image_info.scale_factor));
332 }
311 333
312 // Add to the extension's image cache if requested. 334 // Add to the extension's image cache if requested.
313 DCHECK(info->cache != CACHE || info->extension); 335 DCHECK(info->cache != CACHE || info->extension);
314 if (should_cache && info->cache == CACHE && 336 if (should_cache && info->cache == CACHE &&
315 !info->extension->HasCachedImage(resource, original_size)) { 337 !info->extension->HasCachedImage(image_info.resource, original_size)) {
316 info->extension->SetCachedImage(resource, image ? *image : SkBitmap(), 338 info->extension->SetCachedImage(image_info.resource,
339 image ? *image : SkBitmap(),
317 original_size); 340 original_size);
318 } 341 }
319 342
320 // If all pending images are done then report back. 343 // If all pending images are done then report back.
321 if (info->pending_count == 0) { 344 if (info->pending_count == 0) {
322 gfx::Image image; 345 gfx::Image image(info->images);
323 std::string extension_id = info->extension_id; 346 std::string extension_id = info->extension_id;
324 347
325 if (info->bitmaps.size() > 0) {
326 gfx::ImageSkia image_skia;
327 for (std::vector<SkBitmap>::const_iterator it = info->bitmaps.begin();
328 it != info->bitmaps.end(); ++it) {
329 // TODO(pkotwicz): Do something better but ONLY when DIP is enabled.
330 image_skia.AddRepresentation(
331 gfx::ImageSkiaRep(*it, ui::SCALE_FACTOR_100P));
332 }
333 image = gfx::Image(image_skia);
334 }
335
336 load_map_.erase(load_map_it); 348 load_map_.erase(load_map_it);
337 349
338 // ImageLoadingTracker might be deleted after the callback so don't 350 // ImageLoadingTracker might be deleted after the callback so don't
339 // anything after this statement. 351 // anything after this statement.
340 observer_->OnImageLoaded(image, extension_id, id); 352 observer_->OnImageLoaded(image, extension_id, id);
341 } 353 }
342 } 354 }
343 355
344 void ImageLoadingTracker::Observe(int type, 356 void ImageLoadingTracker::Observe(int type,
345 const content::NotificationSource& source, 357 const content::NotificationSource& source,
346 const content::NotificationDetails& details) { 358 const content::NotificationDetails& details) {
347 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); 359 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED);
348 360
349 const Extension* extension = 361 const Extension* extension =
350 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; 362 content::Details<extensions::UnloadedExtensionInfo>(details)->extension;
351 363
352 // Remove reference to this extension from all pending load entries. This 364 // Remove reference to this extension from all pending load entries. This
353 // ensures we don't attempt to cache the image when the load completes. 365 // ensures we don't attempt to cache the image when the load completes.
354 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { 366 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) {
355 PendingLoadInfo* info = &i->second; 367 PendingLoadInfo* info = &i->second;
356 if (info->extension == extension) { 368 if (info->extension == extension) {
357 info->extension = NULL; 369 info->extension = NULL;
358 info->cache = DONT_CACHE; 370 info->cache = DONT_CACHE;
359 } 371 }
360 } 372 }
361 } 373 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698