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

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

Issue 10905005: Change browser/page action default icon defined in manifest to support hidpi. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: disable unittest on android 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
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2b94f67bd953f19917635eab0b988ae2bcaa1ed3..fce46ddb369d7646c1402e0b4c13ee543dad278a 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -35,6 +35,27 @@ using extensions::Extension;
namespace errors = extension_manifest_errors;
+namespace {
+
+bool ValidateExtensionIconSet(const ExtensionIconSet* icon_set,
+ const Extension* extension,
+ int error_message_id,
+ std::string* error) {
+ for (ExtensionIconSet::IconMap::const_iterator iter = icon_set->map().begin();
+ iter != icon_set->map().end();
+ ++iter) {
+ const FilePath path = extension->GetResource(iter->second).GetFilePath();
+ if (!extension_file_util::ValidateFilePath(path)) {
+ *error = l10n_util::GetStringFUTF8(error_message_id,
+ UTF8ToUTF16(iter->second));
+ return false;
+ }
+ }
+ return true;
+}
+
+} // namespace
+
namespace extension_file_util {
// Validates locale info. Doesn't check if messages.json files are valid.
@@ -320,36 +341,18 @@ bool ValidateExtension(const Extension* extension,
}
}
- // Validate icon location and icon file size for page actions.
- ExtensionAction* page_action = extension->page_action();
- if (page_action) {
- std::string path = page_action->default_icon_path();
- if (!path.empty()) {
- const FilePath file_path = extension->GetResource(path).GetFilePath();
- if (!ValidateFilePath(file_path)) {
- *error =
- l10n_util::GetStringFUTF8(
- IDS_EXTENSION_LOAD_ICON_FOR_PAGE_ACTION_FAILED,
- UTF8ToUTF16(path));
- return false;
- }
- }
+ const ExtensionAction* action = extension->page_action();
+ if (action && action->default_icon() &&
+ !ValidateExtensionIconSet(action->default_icon(), extension,
+ IDS_EXTENSION_LOAD_ICON_FOR_PAGE_ACTION_FAILED, error)) {
+ return false;
}
- // Validate icon location and icon file size for browser actions.
- ExtensionAction* browser_action = extension->browser_action();
- if (browser_action) {
- std::string path = browser_action->default_icon_path();
- if (!path.empty()) {
- const FilePath file_path = extension->GetResource(path).GetFilePath();
- if (!ValidateFilePath(file_path)) {
- *error =
- l10n_util::GetStringFUTF8(
- IDS_EXTENSION_LOAD_ICON_FOR_BROWSER_ACTION_FAILED,
- UTF8ToUTF16(path));
- return false;
- }
- }
+ action = extension->browser_action();
+ if (action && action->default_icon() &&
+ !ValidateExtensionIconSet(action->default_icon(), extension,
+ IDS_EXTENSION_LOAD_ICON_FOR_BROWSER_ACTION_FAILED, error)) {
+ return false;
}
// Validate that background scripts exist.
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698