| 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> |
| 8 #include <vector> |
| 9 |
| 7 #include "base/bind.h" | 10 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 9 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 12 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 12 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
| 13 #include "chrome/common/extensions/extension_resource.h" | 16 #include "chrome/common/extensions/extension_resource.h" |
| 14 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 16 #include "grit/component_extension_resources_map.h" | 19 #include "grit/component_extension_resources_map.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 PendingLoadInfo load_info; | 210 PendingLoadInfo load_info; |
| 208 load_info.extension = extension; | 211 load_info.extension = extension; |
| 209 load_info.cache = cache; | 212 load_info.cache = cache; |
| 210 load_info.extension_id = extension->id(); | 213 load_info.extension_id = extension->id(); |
| 211 load_info.pending_count = info_list.size(); | 214 load_info.pending_count = info_list.size(); |
| 212 int id = next_id_++; | 215 int id = next_id_++; |
| 213 load_map_[id] = load_info; | 216 load_map_[id] = load_info; |
| 214 | 217 |
| 215 for (std::vector<ImageInfo>::const_iterator it = info_list.begin(); | 218 for (std::vector<ImageInfo>::const_iterator it = info_list.begin(); |
| 216 it != info_list.end(); ++it) { | 219 it != info_list.end(); ++it) { |
| 217 // Load resources for WebStore component extension. | 220 // Load resources for special component extensions. |
| 218 if (load_info.extension_id == extension_misc::kWebStoreAppId) { | 221 if (load_info.extension_id == extension_misc::kWebStoreAppId) { |
| 219 if (!loader_) | 222 if (!loader_) |
| 220 loader_ = new ImageLoader(this); | 223 loader_ = new ImageLoader(this); |
| 221 loader_->LoadResource(it->resource, it->max_size, id, IDR_WEBSTORE_ICON); | 224 loader_->LoadResource(it->resource, it->max_size, id, IDR_WEBSTORE_ICON); |
| 222 continue; | 225 continue; |
| 226 } else if (load_info.extension_id == extension_misc::kChromeAppId) { |
| 227 if (!loader_) |
| 228 loader_ = new ImageLoader(this); |
| 229 loader_->LoadResource(it->resource, |
| 230 it->max_size, |
| 231 id, |
| 232 IDR_PRODUCT_LOGO_128); |
| 233 continue; |
| 223 } | 234 } |
| 224 | 235 |
| 225 // If we don't have a path we don't need to do any further work, just | 236 // If we don't have a path we don't need to do any further work, just |
| 226 // respond back. | 237 // respond back. |
| 227 if (it->resource.relative_path().empty()) { | 238 if (it->resource.relative_path().empty()) { |
| 228 OnImageLoaded(NULL, it->resource, it->max_size, id, false); | 239 OnImageLoaded(NULL, it->resource, it->max_size, id, false); |
| 229 continue; | 240 continue; |
| 230 } | 241 } |
| 231 | 242 |
| 232 DCHECK(extension->path() == it->resource.extension_root()); | 243 DCHECK(extension->path() == it->resource.extension_root()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // Remove reference to this extension from all pending load entries. This | 344 // Remove reference to this extension from all pending load entries. This |
| 334 // ensures we don't attempt to cache the image when the load completes. | 345 // ensures we don't attempt to cache the image when the load completes. |
| 335 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { | 346 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { |
| 336 PendingLoadInfo* info = &i->second; | 347 PendingLoadInfo* info = &i->second; |
| 337 if (info->extension == extension) { | 348 if (info->extension == extension) { |
| 338 info->extension = NULL; | 349 info->extension = NULL; |
| 339 info->cache = DONT_CACHE; | 350 info->cache = DONT_CACHE; |
| 340 } | 351 } |
| 341 } | 352 } |
| 342 } | 353 } |
| OLD | NEW |