diff options
author | estade <estade@chromium.org> | 2016-01-05 14:14:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-05 22:16:20 +0000 |
commit | 612db46613451f3c0d2ab5a3b0be373f6550d968 (patch) | |
tree | 3c3df137187698332ca1c2e1f02e490be928de54 /extensions/common | |
parent | d71ea5987a457e8d08b9d722c3022d47c965159f (diff) | |
download | chromium_src-612db46613451f3c0d2ab5a3b0be373f6550d968.zip chromium_src-612db46613451f3c0d2ab5a3b0be373f6550d968.tar.gz chromium_src-612db46613451f3c0d2ab5a3b0be373f6550d968.tar.bz2 |
Manual revert of "Change extension icon load errors to warnings"
This salvages a couple minor changes (tests, mostly), but is largely a
revert of 6e8e7d1c49657e82d0e8f25
BUG=570249
Review URL: https://codereview.chromium.org/1552323002
Cr-Commit-Position: refs/heads/master@{#367667}
Diffstat (limited to 'extensions/common')
-rw-r--r-- | extensions/common/file_util.cc | 11 | ||||
-rw-r--r-- | extensions/common/file_util.h | 3 | ||||
-rw-r--r-- | extensions/common/file_util_unittest.cc | 8 | ||||
-rw-r--r-- | extensions/common/manifest_handler_helpers.cc | 24 | ||||
-rw-r--r-- | extensions/common/manifest_handler_helpers.h | 11 | ||||
-rw-r--r-- | extensions/common/manifest_handlers/icons_handler.cc | 2 |
6 files changed, 12 insertions, 47 deletions
diff --git a/extensions/common/file_util.cc b/extensions/common/file_util.cc index 3ddf6d0..ae12f2c 100644 --- a/extensions/common/file_util.cc +++ b/extensions/common/file_util.cc @@ -56,6 +56,12 @@ enum SafeInstallationFlag { }; SafeInstallationFlag g_use_safe_installation = DEFAULT; +// Returns true if the given file path exists and is not zero-length. +bool ValidateFilePath(const base::FilePath& path) { + int64_t size = 0; + return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0; +} + // Returns true if the extension installation should flush all files and the // directory. bool UseSafeInstallation() { @@ -263,11 +269,6 @@ scoped_ptr<base::DictionaryValue> LoadManifest( return base::DictionaryValue::From(std::move(root)); } -bool ValidateFilePath(const base::FilePath& path) { - int64_t size = 0; - return base::PathExists(path) && base::GetFileSize(path, &size) && size != 0; -} - bool ValidateExtension(const Extension* extension, std::string* error, std::vector<InstallWarning>* warnings) { diff --git a/extensions/common/file_util.h b/extensions/common/file_util.h index 609b27c..3fda56a 100644 --- a/extensions/common/file_util.h +++ b/extensions/common/file_util.h @@ -72,9 +72,6 @@ scoped_ptr<base::DictionaryValue> LoadManifest( const base::FilePath::CharType* manifest_filename, std::string* error); -// Returns true if the given file path exists and is not zero-length. -bool ValidateFilePath(const base::FilePath& path); - // Returns true if the given extension object is valid and consistent. // May also append a series of warning messages to |warnings|, but they // should not prevent the extension from running. diff --git a/extensions/common/file_util_unittest.cc b/extensions/common/file_util_unittest.cc index afbcf3c..c058400 100644 --- a/extensions/common/file_util_unittest.cc +++ b/extensions/common/file_util_unittest.cc @@ -430,13 +430,7 @@ TEST_F(FileUtilTest, CheckZeroLengthAndMissingIconFile) { std::string error; scoped_refptr<Extension> extension(file_util::LoadExtension( ext_dir, Manifest::INTERNAL, Extension::NO_FLAGS, &error)); - EXPECT_TRUE(extension); - ASSERT_EQ(2U, extension->install_warnings().size()); - - EXPECT_EQ("Could not load extension icon 'missing-icon.png'.", - extension->install_warnings()[0].message); - EXPECT_EQ("Could not load extension icon 'icon.png'.", - extension->install_warnings()[1].message); + ASSERT_FALSE(extension); } // Try to install an unpacked extension with a zero-length icon file. diff --git a/extensions/common/manifest_handler_helpers.cc b/extensions/common/manifest_handler_helpers.cc index 36af224d..bfc9e33 100644 --- a/extensions/common/manifest_handler_helpers.cc +++ b/extensions/common/manifest_handler_helpers.cc @@ -13,10 +13,7 @@ #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 { @@ -35,8 +32,7 @@ bool NormalizeAndValidatePath(std::string* path) { return true; } -bool LoadIconsFromDictionary(Extension* extension, - const base::DictionaryValue* icons_value, +bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, ExtensionIconSet* icons, base::string16* error) { DCHECK(icons); @@ -53,23 +49,7 @@ bool LoadIconsFromDictionary(Extension* extension, return false; } - // 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())); - } + icons->Add(size, icon_path); } return true; } diff --git a/extensions/common/manifest_handler_helpers.h b/extensions/common/manifest_handler_helpers.h index e1f901a..b0249c3 100644 --- a/extensions/common/manifest_handler_helpers.h +++ b/extensions/common/manifest_handler_helpers.h @@ -6,11 +6,9 @@ #define EXTENSIONS_COMMON_MANIFEST_HANDLER_HELPERS_H_ #include <string> -#include <vector> #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" -#include "extensions/common/install_warning.h" class ExtensionIconSet; @@ -19,9 +17,6 @@ class DictionaryValue; } namespace extensions { - -class Extension; - namespace manifest_handler_helpers { // Strips leading slashes from the file path. Returns true iff the final path is @@ -30,10 +25,8 @@ bool NormalizeAndValidatePath(std::string* path); // Loads icon paths defined in dictionary |icons_value| into ExtensionIconSet // |icons|. |icons_value| is a dictionary value {icon size -> icon path}. -// Returns success. If load fails, |error| will be set. Non-failure warnings may -// be added to |extension|. -bool LoadIconsFromDictionary(Extension* extension, - const base::DictionaryValue* icons_value, +// Returns success. If load fails, |error| will be set. +bool LoadIconsFromDictionary(const base::DictionaryValue* icons_value, ExtensionIconSet* icons, base::string16* error); diff --git a/extensions/common/manifest_handlers/icons_handler.cc b/extensions/common/manifest_handlers/icons_handler.cc index 52597e5..20ad025 100644 --- a/extensions/common/manifest_handlers/icons_handler.cc +++ b/extensions/common/manifest_handlers/icons_handler.cc @@ -64,7 +64,7 @@ bool IconsHandler::Parse(Extension* extension, base::string16* error) { } if (!manifest_handler_helpers::LoadIconsFromDictionary( - extension, icons_dict, &icons_info->icons, error)) { + icons_dict, &icons_info->icons, error)) { return false; } |