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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 9 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 #include "chrome/common/extensions/extension_constants.h" | 12 #include "chrome/common/extensions/extension_constants.h" |
13 #include "chrome/common/extensions/extension_resource.h" | 13 #include "chrome/common/extensions/extension_resource.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "grit/component_extension_resources_map.h" | 16 #include "grit/component_extension_resources_map.h" |
17 #include "grit/theme_resources.h" | 17 #include "grit/theme_resources.h" |
18 #include "skia/ext/image_operations.h" | 18 #include "skia/ext/image_operations.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
21 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
22 #include "webkit/glue/image_decoder.h" | 22 #include "webkit/glue/image_decoder.h" |
23 | 23 |
24 using content::BrowserThread; | 24 using content::BrowserThread; |
| 25 using extensions::Extension; |
25 | 26 |
26 //////////////////////////////////////////////////////////////////////////////// | 27 //////////////////////////////////////////////////////////////////////////////// |
27 // ImageLoadingTracker::Observer | 28 // ImageLoadingTracker::Observer |
28 | 29 |
29 ImageLoadingTracker::Observer::~Observer() {} | 30 ImageLoadingTracker::Observer::~Observer() {} |
30 | 31 |
31 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
32 // ImageLoadingTracker::ImageInfo | 33 // ImageLoadingTracker::ImageInfo |
33 | 34 |
34 ImageLoadingTracker::ImageInfo::ImageInfo( | 35 ImageLoadingTracker::ImageInfo::ImageInfo( |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 observer_->OnImageLoaded(image, extension_id, id); | 321 observer_->OnImageLoaded(image, extension_id, id); |
321 } | 322 } |
322 } | 323 } |
323 | 324 |
324 void ImageLoadingTracker::Observe(int type, | 325 void ImageLoadingTracker::Observe(int type, |
325 const content::NotificationSource& source, | 326 const content::NotificationSource& source, |
326 const content::NotificationDetails& details) { | 327 const content::NotificationDetails& details) { |
327 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); | 328 DCHECK(type == chrome::NOTIFICATION_EXTENSION_UNLOADED); |
328 | 329 |
329 const Extension* extension = | 330 const Extension* extension = |
330 content::Details<UnloadedExtensionInfo>(details)->extension; | 331 content::Details<extensions::UnloadedExtensionInfo>(details)->extension; |
331 | 332 |
332 // Remove reference to this extension from all pending load entries. This | 333 // Remove reference to this extension from all pending load entries. This |
333 // ensures we don't attempt to cache the image when the load completes. | 334 // ensures we don't attempt to cache the image when the load completes. |
334 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { | 335 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end(); ++i) { |
335 PendingLoadInfo* info = &i->second; | 336 PendingLoadInfo* info = &i->second; |
336 if (info->extension == extension) { | 337 if (info->extension == extension) { |
337 info->extension = NULL; | 338 info->extension = NULL; |
338 info->cache = DONT_CACHE; | 339 info->cache = DONT_CACHE; |
339 } | 340 } |
340 } | 341 } |
341 } | 342 } |
OLD | NEW |