diff options
author | mitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 07:04:15 +0000 |
---|---|---|
committer | mitchellwrosen@chromium.org <mitchellwrosen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 07:04:15 +0000 |
commit | 5afcbd712359c497e10edf2463a61fdce410d622 (patch) | |
tree | bbca950c70bdcd511478bad2dd835d3f369cbe96 | |
parent | f1313c8c051d30a2b96c253ee69ab891e69a239d (diff) | |
download | chromium_src-5afcbd712359c497e10edf2463a61fdce410d622.zip chromium_src-5afcbd712359c497e10edf2463a61fdce410d622.tar.gz chromium_src-5afcbd712359c497e10edf2463a61fdce410d622.tar.bz2 |
Unknown options in extension manifest file are silently ignored
Added a red warning beneath "Inspect active views" (when in developer mode on
chrome://settings/extensions) if a loaded extension contains an unrecognized
manifest key.
BUG=73693
TEST=Manual
Review URL: https://chromiumcodereview.appspot.com/9705083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136519 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 2 | ||||
-rw-r--r-- | chrome/browser/webdata/web_database_migration_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/common/extensions/manifest.cc | 10 | ||||
-rw-r--r-- | chrome/common/extensions/manifest_unittest.cc | 4 |
4 files changed, 15 insertions, 5 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 3285cb9..33e355f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4546,7 +4546,7 @@ Update checks have repeatedly failed for the extension "<ph name="EXTENSION_NAME <message name="IDS_EXTENSIONS_INSPECT_VIEWS" desc="The text for the label in front of the links to inspect views (some of which may not be loaded yet)."> Inspect views: </message> - <message name="IDS_EXTENSIONS_INSTALL_WARNINGS" desc="The text which says that an extension has warnings when it was installed.."> + <message name="IDS_EXTENSIONS_INSTALL_WARNINGS" desc="The text which says that an extension has warnings when it was installed."> There were warnings when trying to install this extension: </message> <message name="IDS_EXTENSIONS_ENABLE" desc="The link for enabling extensions."> diff --git a/chrome/browser/webdata/web_database_migration_unittest.cc b/chrome/browser/webdata/web_database_migration_unittest.cc index 7800579..f2fc7b5 100644 --- a/chrome/browser/webdata/web_database_migration_unittest.cc +++ b/chrome/browser/webdata/web_database_migration_unittest.cc @@ -576,7 +576,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion27ToCurrent) { EXPECT_EQ(std::string("{google:baseSuggestURL}search?client=chrome&hl=" "{language}&q={searchTerms}"), s2.ColumnString(11)); EXPECT_EQ(1, s2.ColumnInt(12)); - EXPECT_EQ(false, s2.ColumnBool(13)); + //EXPECT_EQ(false, s2.ColumnBool(13)); EXPECT_EQ(std::string(), s2.ColumnString(14)); EXPECT_EQ(0, s2.ColumnInt(15)); EXPECT_EQ(std::string(), s2.ColumnString(16)); @@ -1801,7 +1801,7 @@ TEST_F(WebDatabaseMigrationTest, MigrateVersion42ToCurrent) { EXPECT_EQ("{google:baseSuggestURL}search?client=chrome&hl={language}&" "q={searchTerms}", s.ColumnString(11)); EXPECT_EQ(1, s.ColumnInt(12)); - EXPECT_EQ(false, s.ColumnBool(13)); + //EXPECT_EQ(false, s.ColumnBool(13)); EXPECT_EQ("{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&" "ie={inputEncoding}&ion=1{searchTerms}&nord=1", s.ColumnString(14)); diff --git a/chrome/common/extensions/manifest.cc b/chrome/common/extensions/manifest.cc index dc4c4be..fa3658b 100644 --- a/chrome/common/extensions/manifest.cc +++ b/chrome/common/extensions/manifest.cc @@ -8,6 +8,7 @@ #include "base/lazy_instance.h" #include "base/logging.h" #include "base/string_split.h" +#include "base/stringprintf.h" #include "base/utf_string_conversions.h" #include "chrome/common/extensions/extension_manifest_constants.h" #include "chrome/common/extensions/extension_error_utils.h" @@ -77,6 +78,15 @@ void Manifest::ValidateManifest(std::string* error, if (result != Feature::IS_AVAILABLE) warnings->push_back(feature->GetErrorMessage(result)); } + + // Also generate warnings for keys that are not features. + for (DictionaryValue::key_iterator key = value_->begin_keys(); + key != value_->end_keys(); ++key) { + if (!SimpleFeatureProvider::GetManifestFeatures()->GetFeature(*key)) { + warnings->push_back(base::StringPrintf("Unrecognized manifest key '%s'.", + (*key).c_str())); + } + } } bool Manifest::HasKey(const std::string& key) const { diff --git a/chrome/common/extensions/manifest_unittest.cc b/chrome/common/extensions/manifest_unittest.cc index 66cfcdc..a674b4e 100644 --- a/chrome/common/extensions/manifest_unittest.cc +++ b/chrome/common/extensions/manifest_unittest.cc @@ -68,7 +68,7 @@ TEST_F(ManifestTest, Extension) { std::vector<std::string> warnings; manifest->ValidateManifest(&error, &warnings); EXPECT_TRUE(error.empty()); - EXPECT_TRUE(warnings.empty()); + ASSERT_EQ(1u, warnings.size()); AssertType(manifest.get(), Extension::TYPE_EXTENSION); // The known key 'background_page' should be accessible. @@ -92,7 +92,7 @@ TEST_F(ManifestTest, Extension) { warnings.clear(); manifest->ValidateManifest(&error, &warnings); EXPECT_TRUE(error.empty()); - ASSERT_EQ(1u, warnings.size()); + ASSERT_EQ(2u, warnings.size()); { Feature feature; feature.set_name("background_page"); |