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

Unified Diff: chrome/browser/extensions/image_loading_tracker.cc

Issue 9979001: Attempt to load component extension favicon from the resources first. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
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,
« no previous file with comments | « chrome/browser/extensions/image_loading_tracker.h ('k') | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698