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

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

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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"
(...skipping 10 matching lines...) Expand all
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "skia/ext/image_operations.h" 22 #include "skia/ext/image_operations.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
26 #include "ui/gfx/image/image_skia_rep.h" 26 #include "ui/gfx/image/image_skia_rep.h"
27 #include "webkit/glue/image_decoder.h" 27 #include "webkit/glue/image_decoder.h"
28 28
29 using content::BrowserThread; 29 using content::BrowserThread;
30 using extensions::Extension; 30 using extensions::Extension;
31 using extensions::Manifest;
31 32
32 namespace { 33 namespace {
33 34
34 bool ShouldResizeImageRepresentation( 35 bool ShouldResizeImageRepresentation(
35 ImageLoadingTracker::ImageRepresentation::ResizeCondition resize_method, 36 ImageLoadingTracker::ImageRepresentation::ResizeCondition resize_method,
36 const gfx::Size& decoded_size, 37 const gfx::Size& decoded_size,
37 const gfx::Size& desired_size) { 38 const gfx::Size& desired_size) {
38 switch (resize_method) { 39 switch (resize_method) {
39 case ImageLoadingTracker::ImageRepresentation::ALWAYS_RESIZE: 40 case ImageLoadingTracker::ImageRepresentation::ALWAYS_RESIZE:
40 return decoded_size != desired_size; 41 return decoded_size != desired_size;
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 OnBitmapLoaded(&bitmap, *it, it->desired_size, id, false); 300 OnBitmapLoaded(&bitmap, *it, it->desired_size, id, false);
300 continue; 301 continue;
301 } 302 }
302 303
303 // Instruct the ImageLoader to load this on the File thread. LoadImage and 304 // Instruct the ImageLoader to load this on the File thread. LoadImage and
304 // LoadResource do not block. 305 // LoadResource do not block.
305 if (!loader_) 306 if (!loader_)
306 loader_ = new ImageLoader(this); 307 loader_ = new ImageLoader(this);
307 308
308 int resource_id = -1; 309 int resource_id = -1;
309 if (extension->location() == Extension::COMPONENT && 310 if (extension->location() == Manifest::COMPONENT &&
310 extensions::ImageLoader::IsComponentExtensionResource( 311 extensions::ImageLoader::IsComponentExtensionResource(
311 extension->path(), it->resource.relative_path(), &resource_id)) { 312 extension->path(), it->resource.relative_path(), &resource_id)) {
312 loader_->LoadResource(*it, id, resource_id); 313 loader_->LoadResource(*it, id, resource_id);
313 } else { 314 } else {
314 loader_->LoadImage(*it, id); 315 loader_->LoadImage(*it, id);
315 } 316 }
316 } 317 }
317 } 318 }
318 319
319 void ImageLoadingTracker::OnBitmapLoaded( 320 void ImageLoadingTracker::OnBitmapLoaded(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 // Remove reference to this extension from all pending load entries. This 373 // Remove reference to this extension from all pending load entries. This
373 // ensures we don't attempt to cache the bitmap when the load completes. 374 // ensures we don't attempt to cache the bitmap when the load completes.
374 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { 375 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) {
375 PendingLoadInfo* info = &i->second; 376 PendingLoadInfo* info = &i->second;
376 if (info->extension == extension) { 377 if (info->extension == extension) {
377 info->extension = NULL; 378 info->extension = NULL;
378 info->cache = DONT_CACHE; 379 info->cache = DONT_CACHE;
379 } 380 }
380 } 381 }
381 } 382 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/image_loader_unittest.cc ('k') | chrome/browser/extensions/image_loading_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698