| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |