Index: chrome/browser/extensions/image_loading_tracker.cc |
=================================================================== |
--- chrome/browser/extensions/image_loading_tracker.cc (revision 130900) |
+++ chrome/browser/extensions/image_loading_tracker.cc (working copy) |
@@ -6,11 +6,15 @@ |
#include "base/bind.h" |
#include "base/file_util.h" |
+#include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/extension.h" |
+#include "chrome/common/extensions/extension_constants.h" |
#include "chrome/common/extensions/extension_resource.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/notification_service.h" |
+#include "grit/component_extension_resources_map.h" |
+#include "grit/theme_resources.h" |
#include "skia/ext/image_operations.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "ui/gfx/image/image.h" |
@@ -184,6 +188,14 @@ |
for (std::vector<ImageInfo>::const_iterator it = info_list.begin(); |
it != info_list.end(); ++it) { |
+ // Load resources for component extensions. |
+ if (load_info.extension_id == extension_misc::kWebStoreAppId) { |
+ OnImageLoaded( |
+ ExtensionIconSource::LoadImageByResourceId(IDR_WEBSTORE_ICON), |
+ it->resource, it->max_size, id, false); |
+ continue; |
+ } |
+ |
// If we don't have a path we don't need to do any further work, just |
// respond back. |
if (it->resource.relative_path().empty()) { |
@@ -191,6 +203,13 @@ |
continue; |
} |
+ SkBitmap* from_resources = TryLoadingComponentExtensionImage(extension, |
+ it->resource); |
+ if (from_resources) { |
+ OnImageLoaded(from_resources, it->resource, it->max_size, id, false); |
Finnur
2012/04/10 13:46:39
You've selected in both cases to not honor the |ca
dgozman
2012/04/10 14:19:48
Why do we cache icon available locally and waste s
Finnur
2012/04/10 14:32:21
All the files this class deals with are local, so
dgozman
2012/04/10 16:59:51
Oh, now I see. Changed so the |CacheParam| decides
|
+ continue; |
+ } |
+ |
DCHECK(extension->path() == it->resource.extension_root()); |
// See if the extension has the image already. |
@@ -208,6 +227,29 @@ |
} |
} |
+SkBitmap* ImageLoadingTracker::TryLoadingComponentExtensionImage( |
+ const Extension* extension, |
+ const ExtensionResource& resource) { |
+ if (extension->location() != Extension::COMPONENT) |
+ return NULL; |
+ |
+ FilePath directory_path = extension->path(); |
+ FilePath relative_path = directory_path.BaseName().Append( |
+ resource.relative_path()); |
+ |
+ for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) { |
+ FilePath bm_resource_path = |
+ FilePath().AppendASCII(kComponentExtensionResources[i].name); |
+ bm_resource_path = bm_resource_path.NormalizePathSeparators(); |
+ |
+ if (relative_path == bm_resource_path) { |
+ return ExtensionIconSource::LoadImageByResourceId( |
+ kComponentExtensionResources[i].value); |
Finnur
2012/04/10 14:32:21
Wait, we're on the UI thread here so we should not
dgozman
2012/04/10 16:59:51
Done.
|
+ } |
+ } |
+ return NULL; |
+} |
+ |
void ImageLoadingTracker::OnImageLoaded( |
SkBitmap* image, |
const ExtensionResource& resource, |