summaryrefslogtreecommitdiffstats
path: root/extensions/common/manifest_handler_helpers.cc
diff options
context:
space:
mode:
authorestade <estade@chromium.org>2015-12-18 18:39:37 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-19 02:40:36 +0000
commit6e8e7d1c49657e82d0e8f2518ad463794346321b (patch)
tree516b2ba9491ad1c0097dcb766b411bb82a809641 /extensions/common/manifest_handler_helpers.cc
parentf45be477c7c9913086ac2ba256dfeafac6fcc45a (diff)
downloadchromium_src-6e8e7d1c49657e82d0e8f2518ad463794346321b.zip
chromium_src-6e8e7d1c49657e82d0e8f2518ad463794346321b.tar.gz
chromium_src-6e8e7d1c49657e82d0e8f2518ad463794346321b.tar.bz2
Change extension icon load errors to warnings
During the Extension parsing step, check if the icon file exists and if not, remove that entry from the dictionary. Keep the same check during the validation phase and don't apply the workaround to unpacked extensions. This will more strongly discourage new extensions from making this mistake. BUG=570249 Review URL: https://codereview.chromium.org/1537473003 Cr-Commit-Position: refs/heads/master@{#366253}
Diffstat (limited to 'extensions/common/manifest_handler_helpers.cc')
-rw-r--r--extensions/common/manifest_handler_helpers.cc25
1 files changed, 22 insertions, 3 deletions
diff --git a/extensions/common/manifest_handler_helpers.cc b/extensions/common/manifest_handler_helpers.cc
index 4dc2f6b..f04d0f8 100644
--- a/extensions/common/manifest_handler_helpers.cc
+++ b/extensions/common/manifest_handler_helpers.cc
@@ -11,8 +11,10 @@
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_icon_set.h"
+#include "extensions/common/file_util.h"
#include "extensions/common/manifest_constants.h"
-
+#include "grit/extensions_strings.h"
+#include "ui/base/l10n/l10n_util.h"
namespace extensions {
@@ -31,7 +33,8 @@ bool NormalizeAndValidatePath(std::string* path) {
return true;
}
-bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value,
+bool LoadIconsFromDictionary(Extension* extension,
+ const base::DictionaryValue* icons_value,
ExtensionIconSet* icons,
base::string16* error) {
DCHECK(icons);
@@ -48,7 +51,23 @@ bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value,
return false;
}
- icons->Add(size, icon_path);
+ // For backwards compatibility, only warn (don't error out) if an icon is
+ // missing. Component extensions can skip this check as their icons are not
+ // located on disk. Unpacked extensions skip this check and fail later
+ // during validation if the file isn't present. See crbug.com/570249
+ // TODO(estade|devlin): remove this workaround and let install fail in the
+ // validate step a few releases after M49. See http://crbug.com/571193
+ if (Manifest::IsComponentLocation(extension->location()) ||
+ Manifest::IsUnpackedLocation(extension->location()) ||
+ file_util::ValidateFilePath(
+ extension->GetResource(icon_path).GetFilePath())) {
+ icons->Add(size, icon_path);
+ } else {
+ extension->AddInstallWarning(InstallWarning(
+ l10n_util::GetStringFUTF8(IDS_EXTENSION_LOAD_ICON_FAILED,
+ base::UTF8ToUTF16(icon_path)),
+ std::string()));
+ }
}
return true;
}