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

Unified Diff: chrome/common/extensions/extension_file_util.cc

Issue 10985028: Give Chrome Web Store app an icon in its manifest file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't install extra files, also make chrome_app app have an icon Created 8 years, 3 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/common/extensions/extension_file_util.cc
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index fce46ddb369d7646c1402e0b4c13ee543dad278a..a82d9811f49a11279500d17e5a1608ad5e021b17 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -26,7 +26,9 @@
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/extension_resource.h"
#include "chrome/common/extensions/message_bundle.h"
+#include "grit/component_extension_resources_map.h"
#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
#include "net/base/escape.h"
#include "net/base/file_stream.h"
#include "ui/base/l10n/l10n_util.h"
@@ -791,4 +793,49 @@ void DeleteFile(const FilePath& path, bool recursive) {
file_util::Delete(path, recursive);
}
+bool IsComponentExtensionResource(const Extension* extension,
+ const FilePath& resource_path,
+ int& resource_id) {
+ LOG(INFO) << resource_path.AsUTF8Unsafe();
+ static const GritResourceMap kExtraComponentExtensionResources[] = {
+ {"web_store/webstore_icon_128.png", IDR_WEBSTORE_ICON},
+ {"web_store/webstore_icon_16.png", IDR_WEBSTORE_ICON_16},
+ {"chrome_app/product_logo_128.png", IDR_PRODUCT_LOGO_128},
+ {"chrome_app/product_logo_16.png", IDR_PRODUCT_LOGO_16},
+ };
+ static const size_t kExtraComponentExtensionResourcesSize =
+ arraysize(kExtraComponentExtensionResources);
+
+ if (extension->location() != Extension::COMPONENT)
+ return false;
+
+ FilePath directory_path = extension->path();
+ FilePath relative_path = directory_path.BaseName().Append(resource_path);
+
+ // TODO(tc): Make a map of FilePath -> resource ids so we don't have to
+ // covert to FilePaths all the time. This will be more useful as we add
+ // more resources.
+ for (size_t i = 0; i < kComponentExtensionResourcesSize; ++i) {
+ FilePath resource_path =
+ FilePath().AppendASCII(kComponentExtensionResources[i].name);
+ resource_path = resource_path.NormalizePathSeparators();
+
+ if (relative_path == resource_path) {
+ resource_id = kComponentExtensionResources[i].value;
+ return true;
+ }
+ }
+ for (size_t i = 0; i < kExtraComponentExtensionResourcesSize; ++i) {
+ FilePath resource_path =
+ FilePath().AppendASCII(kExtraComponentExtensionResources[i].name);
+ resource_path = resource_path.NormalizePathSeparators();
+
+ if (relative_path == resource_path) {
+ resource_id = kExtraComponentExtensionResources[i].value;
+ return true;
+ }
+ }
+ return false;
+}
+
} // namespace extension_file_util

Powered by Google App Engine
This is Rietveld 408576698