summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/background_application_list_model_unittest.cc4
-rw-r--r--chrome/browser/extensions/convert_user_script.cc3
-rw-r--r--chrome/browser/extensions/convert_web_app.cc3
-rw-r--r--chrome/browser/extensions/crx_installer.cc3
-rw-r--r--chrome/browser/extensions/extension_creator.cc3
-rw-r--r--chrome/browser/extensions/extension_icon_manager_unittest.cc4
-rw-r--r--chrome/browser/extensions/extension_info_map_unittest.cc8
-rw-r--r--chrome/browser/extensions/extension_prefs_unittest.cc6
-rw-r--r--chrome/browser/extensions/extension_service.cc27
-rw-r--r--chrome/browser/extensions/extension_special_storage_policy_unittest.cc6
-rw-r--r--chrome/browser/extensions/extension_ui_unittest.cc5
-rw-r--r--chrome/browser/extensions/image_loading_tracker_unittest.cc4
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.cc3
-rw-r--r--chrome/browser/extensions/test_extension_prefs.cc2
-rw-r--r--chrome/browser/sync/glue/extension_util_unittest.cc7
-rw-r--r--chrome/browser/sync/glue/theme_util_unittest.cc3
-rw-r--r--chrome/browser/sync/util/extensions_activity_monitor_unittest.cc8
-rw-r--r--chrome/browser/themes/browser_theme_pack_unittest.cc4
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_install_prompt_controller_unittest.mm6
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm4
-rw-r--r--chrome/common/extensions/extension.cc15
-rw-r--r--chrome/common/extensions/extension.h41
-rw-r--r--chrome/common/extensions/extension_file_util.cc6
-rw-r--r--chrome/common/extensions/extension_file_util.h3
-rw-r--r--chrome/common/extensions/extension_file_util_unittest.cc10
-rw-r--r--chrome/common/extensions/extension_manifests_unittest.cc6
-rw-r--r--chrome/common/extensions/extension_messages.cc10
-rw-r--r--chrome/common/extensions/extension_set_unittest.cc6
-rw-r--r--chrome/common/extensions/extension_unittest.cc141
-rw-r--r--chrome/common/extensions/extension_unpacker.cc3
-rw-r--r--chrome/test/live_sync/live_extensions_sync_test_base.cc4
31 files changed, 204 insertions, 154 deletions
diff --git a/chrome/browser/background_application_list_model_unittest.cc b/chrome/browser/background_application_list_model_unittest.cc
index b994189..a552bcc 100644
--- a/chrome/browser/background_application_list_model_unittest.cc
+++ b/chrome/browser/background_application_list_model_unittest.cc
@@ -89,8 +89,8 @@ static scoped_refptr<Extension> CreateExtension(const std::string& name,
}
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
- bogus_file_path().AppendASCII(name), Extension::INVALID, manifest, false,
- true, &error);
+ bogus_file_path().AppendASCII(name), Extension::INVALID, manifest,
+ Extension::STRICT_ERROR_CHECKS, &error);
// Cannot ASSERT_* here because that attempts an illegitimate return.
// Cannot EXPECT_NE here because that assumes non-pointers unlike EXPECT_EQ
EXPECT_TRUE(extension.get() != NULL) << error;
diff --git a/chrome/browser/extensions/convert_user_script.cc b/chrome/browser/extensions/convert_user_script.cc
index a09134b..3f89b74 100644
--- a/chrome/browser/extensions/convert_user_script.cc
+++ b/chrome/browser/extensions/convert_user_script.cc
@@ -150,8 +150,7 @@ scoped_refptr<Extension> ConvertUserScriptToExtension(
temp_dir.path(),
Extension::INTERNAL,
*root,
- false, // Do not require key
- false, // Disable strict checks
+ Extension::NO_FLAGS,
error);
if (!extension) {
NOTREACHED() << "Could not init extension " << *error;
diff --git a/chrome/browser/extensions/convert_web_app.cc b/chrome/browser/extensions/convert_web_app.cc
index f3277f8..27a0fc9 100644
--- a/chrome/browser/extensions/convert_web_app.cc
+++ b/chrome/browser/extensions/convert_web_app.cc
@@ -171,8 +171,7 @@ scoped_refptr<Extension> ConvertWebAppToExtension(
temp_dir.path(),
Extension::INTERNAL,
*root,
- false, // Don't require a key.
- true, // Enable strict error checks.
+ Extension::STRICT_ERROR_CHECKS,
&error);
if (!extension) {
LOG(ERROR) << error;
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index 3876dc5..affc4d0 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -386,8 +386,7 @@ void CrxInstaller::CompleteInstall() {
extension_ = extension_file_util::LoadExtension(
version_dir,
install_source_,
- true, // Require key
- false, // Disable strict error checks
+ Extension::REQUIRE_KEY,
&error);
CHECK(error.empty()) << error;
diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc
index d7d56c9..4aa7d8c 100644
--- a/chrome/browser/extensions/extension_creator.cc
+++ b/chrome/browser/extensions/extension_creator.cc
@@ -66,8 +66,7 @@ bool ExtensionCreator::InitializeInput(
scoped_refptr<Extension> extension(
extension_file_util::LoadExtension(absolute_extension_dir,
Extension::INTERNAL,
- false, // key not required
- true, // enable strict error checks
+ Extension::STRICT_ERROR_CHECKS,
&error_message_));
if (!extension.get())
return false; // LoadExtension already set error_message_.
diff --git a/chrome/browser/extensions/extension_icon_manager_unittest.cc b/chrome/browser/extensions/extension_icon_manager_unittest.cc
index 490eebc..9793131 100644
--- a/chrome/browser/extensions/extension_icon_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_icon_manager_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -111,7 +111,7 @@ TEST_F(ExtensionIconManagerTest, LoadRemoveLoad) {
scoped_refptr<Extension> extension(Extension::Create(
manifest_path.DirName(), Extension::INVALID, *manifest.get(),
- false, true, NULL));
+ Extension::STRICT_ERROR_CHECKS, NULL));
ASSERT_TRUE(extension.get());
TestIconManager icon_manager(this);
diff --git a/chrome/browser/extensions/extension_info_map_unittest.cc b/chrome/browser/extensions/extension_info_map_unittest.cc
index dd814d1..d8909e6 100644
--- a/chrome/browser/extensions/extension_info_map_unittest.cc
+++ b/chrome/browser/extensions/extension_info_map_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -42,8 +42,8 @@ static scoped_refptr<Extension> CreateExtension(const std::string& name) {
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
- path.AppendASCII(name), Extension::INVALID, manifest, false, true,
- &error);
+ path.AppendASCII(name), Extension::INVALID, manifest,
+ Extension::STRICT_ERROR_CHECKS, &error);
EXPECT_TRUE(extension) << error;
return extension;
@@ -65,7 +65,7 @@ static scoped_refptr<Extension> LoadManifest(const std::string& dir,
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
path, Extension::INVALID, *static_cast<DictionaryValue*>(result.get()),
- false, true, &error);
+ Extension::STRICT_ERROR_CHECKS, &error);
EXPECT_TRUE(extension) << error;
return extension;
diff --git a/chrome/browser/extensions/extension_prefs_unittest.cc b/chrome/browser/extensions/extension_prefs_unittest.cc
index 40e3036..551146b 100644
--- a/chrome/browser/extensions/extension_prefs_unittest.cc
+++ b/chrome/browser/extensions/extension_prefs_unittest.cc
@@ -627,13 +627,13 @@ class ExtensionPrefsPreferencesBase : public ExtensionPrefsTest {
ext1_scoped_ = Extension::Create(
prefs_.temp_dir().AppendASCII("ext1_"), Extension::EXTERNAL_PREF,
- simple_dict, false, true, &error);
+ simple_dict, Extension::STRICT_ERROR_CHECKS, &error);
ext2_scoped_ = Extension::Create(
prefs_.temp_dir().AppendASCII("ext2_"), Extension::EXTERNAL_PREF,
- simple_dict, false, true, &error);
+ simple_dict, Extension::STRICT_ERROR_CHECKS, &error);
ext3_scoped_ = Extension::Create(
prefs_.temp_dir().AppendASCII("ext3_"), Extension::EXTERNAL_PREF,
- simple_dict, false, true, &error);
+ simple_dict, Extension::STRICT_ERROR_CHECKS, &error);
ext1_ = ext1_scoped_.get();
ext2_ = ext2_scoped_.get();
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index ed0d286..cb99385 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -199,12 +199,14 @@ void ExtensionServiceBackend::LoadSingleExtension(
FilePath extension_path = path_in;
file_util::AbsolutePath(&extension_path);
+ int flags = Extension::NO_FLAGS;
+ if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD))
+ flags |= Extension::STRICT_ERROR_CHECKS;
std::string error;
scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
extension_path,
Extension::LOAD,
- false, // Don't require id
- Extension::ShouldDoStrictErrorChecking(Extension::LOAD),
+ flags,
&error));
if (!extension) {
@@ -744,13 +746,15 @@ void ExtensionService::LoadComponentExtension(
return;
}
+ int flags = Extension::REQUIRE_KEY;
+ if (Extension::ShouldDoStrictErrorChecking(Extension::COMPONENT))
+ flags |= Extension::STRICT_ERROR_CHECKS;
std::string error;
scoped_refptr<const Extension> extension(Extension::Create(
info.root_directory,
Extension::COMPONENT,
*static_cast<DictionaryValue*>(manifest.get()),
- true, // Require key
- Extension::ShouldDoStrictErrorChecking(Extension::COMPONENT),
+ flags,
&error));
if (!extension.get()) {
NOTREACHED() << error;
@@ -791,13 +795,15 @@ void ExtensionService::LoadAllExtensions() {
// thread.
base::ThreadRestrictions::ScopedAllowIO allow_io;
+ int flags = Extension::NO_FLAGS;
+ if (Extension::ShouldDoStrictErrorChecking(info->extension_location))
+ flags |= Extension::STRICT_ERROR_CHECKS;
std::string error;
scoped_refptr<const Extension> extension(
extension_file_util::LoadExtension(
info->extension_path,
info->extension_location,
- false, // Don't require key
- Extension::ShouldDoStrictErrorChecking(info->extension_location),
+ flags,
&error));
if (extension.get()) {
@@ -911,13 +917,16 @@ void ExtensionService::LoadInstalledExtension(const ExtensionInfo& info,
if (!extension_prefs_->IsExtensionAllowedByPolicy(info.extension_id)) {
error = errors::kDisabledByPolicy;
} else if (info.extension_manifest.get()) {
- bool require_key = info.extension_location != Extension::LOAD;
+ int flags = Extension::NO_FLAGS;
+ if (info.extension_location != Extension::LOAD)
+ flags |= Extension::REQUIRE_KEY;
+ if (Extension::ShouldDoStrictErrorChecking(info.extension_location))
+ flags |= Extension::STRICT_ERROR_CHECKS;
extension = Extension::Create(
info.extension_path,
info.extension_location,
*info.extension_manifest,
- require_key,
- Extension::ShouldDoStrictErrorChecking(info.extension_location),
+ flags,
&error);
} else {
error = errors::kManifestUnreadable;
diff --git a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
index 3a77b25..3f34ccf 100644
--- a/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
+++ b/chrome/browser/extensions/extension_special_storage_policy_unittest.cc
@@ -28,7 +28,8 @@ class ExtensionSpecialStoragePolicyTest : public testing::Test {
manifest.Set(keys::kWebURLs, list);
std::string error;
scoped_refptr<Extension> protected_app = Extension::Create(
- path, Extension::INVALID, manifest, false, true, &error);
+ path, Extension::INVALID, manifest, Extension::STRICT_ERROR_CHECKS,
+ &error);
EXPECT_TRUE(protected_app.get()) << error;
return protected_app;
}
@@ -52,7 +53,8 @@ class ExtensionSpecialStoragePolicyTest : public testing::Test {
manifest.Set(keys::kWebURLs, list);
std::string error;
scoped_refptr<Extension> unlimited_app = Extension::Create(
- path, Extension::INVALID, manifest, false, true, &error);
+ path, Extension::INVALID, manifest, Extension::STRICT_ERROR_CHECKS,
+ &error);
EXPECT_TRUE(unlimited_app.get()) << error;
return unlimited_app;
}
diff --git a/chrome/browser/extensions/extension_ui_unittest.cc b/chrome/browser/extensions/extension_ui_unittest.cc
index b2ae1c5..a9b65ce 100644
--- a/chrome/browser/extensions/extension_ui_unittest.cc
+++ b/chrome/browser/extensions/extension_ui_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -42,7 +42,8 @@ namespace {
EXPECT_EQ("", error);
scoped_refptr<Extension> extension(Extension::Create(
- path, Extension::INVALID, *extension_data, true, true, &error));
+ path, Extension::INVALID, *extension_data,
+ Extension::REQUIRE_KEY | Extension::STRICT_ERROR_CHECKS, &error));
EXPECT_TRUE(extension.get());
EXPECT_EQ("", error);
diff --git a/chrome/browser/extensions/image_loading_tracker_unittest.cc b/chrome/browser/extensions/image_loading_tracker_unittest.cc
index ed20d00..25d2f6d 100644
--- a/chrome/browser/extensions/image_loading_tracker_unittest.cc
+++ b/chrome/browser/extensions/image_loading_tracker_unittest.cc
@@ -74,8 +74,8 @@ class ImageLoadingTrackerTest : public testing::Test,
if (!valid_value.get())
return NULL;
- return Extension::Create(
- test_file, Extension::INVALID, *valid_value, false, true, &error);
+ return Extension::Create(test_file, Extension::INVALID, *valid_value,
+ Extension::STRICT_ERROR_CHECKS, &error);
}
SkBitmap image_;
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
index 739eb79..8b42d5e 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
@@ -184,8 +184,7 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
extension_root_,
Extension::INTERNAL,
*final_manifest,
- true, // Require key
- false, // Disable strict error checks
+ Extension::REQUIRE_KEY,
&error);
if (!extension_.get()) {
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index 4acac36..7b454f1 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -108,7 +108,7 @@ scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifest(
FilePath path = extensions_dir_.AppendASCII(name);
std::string errors;
scoped_refptr<Extension> extension = Extension::Create(
- path, location, manifest, false, true, &errors);
+ path, location, manifest, Extension::STRICT_ERROR_CHECKS, &errors);
EXPECT_TRUE(extension);
if (!extension)
return NULL;
diff --git a/chrome/browser/sync/glue/extension_util_unittest.cc b/chrome/browser/sync/glue/extension_util_unittest.cc
index 2ca92dd..b72b7a8 100644
--- a/chrome/browser/sync/glue/extension_util_unittest.cc
+++ b/chrome/browser/sync/glue/extension_util_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -71,7 +71,7 @@ scoped_refptr<Extension> MakeExtension(
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
- extension_path, location, source, false, true, &error);
+ extension_path, location, source, Extension::STRICT_ERROR_CHECKS, &error);
#if defined(OS_CHROMEOS)
if (num_plugins > 0) { // plugins are illegal in extensions on chrome os.
EXPECT_FALSE(extension);
@@ -386,7 +386,8 @@ scoped_refptr<Extension> MakeSyncableExtension(
source.SetString(extension_manifest_keys::kName, name);
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
- extension_path, Extension::INTERNAL, source, false, true, &error);
+ extension_path, Extension::INTERNAL, source,
+ Extension::STRICT_ERROR_CHECKS, &error);
EXPECT_TRUE(extension);
EXPECT_EQ("", error);
return extension;
diff --git a/chrome/browser/sync/glue/theme_util_unittest.cc b/chrome/browser/sync/glue/theme_util_unittest.cc
index f9548ce..5c83117 100644
--- a/chrome/browser/sync/glue/theme_util_unittest.cc
+++ b/chrome/browser/sync/glue/theme_util_unittest.cc
@@ -35,7 +35,8 @@ scoped_refptr<Extension> MakeThemeExtension(const FilePath& extension_path,
source.SetString(extension_manifest_keys::kVersion, "0.0.0.0");
std::string error;
scoped_refptr<Extension> extension = Extension::Create(
- extension_path, Extension::INTERNAL, source, false, true, &error);
+ extension_path, Extension::INTERNAL, source,
+ Extension::STRICT_ERROR_CHECKS, &error);
EXPECT_TRUE(extension);
EXPECT_EQ("", error);
return extension;
diff --git a/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc b/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc
index 67585ae..b7e8e7c2 100644
--- a/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc
+++ b/chrome/browser/sync/util/extensions_activity_monitor_unittest.cc
@@ -73,8 +73,8 @@ class BookmarkAPIEventGenerator {
input.SetString(keys::kVersion, kTestExtensionVersion);
input.SetString(keys::kName, kTestExtensionName);
scoped_refptr<Extension> extension(Extension::Create(
- FilePath(extension_path), Extension::INVALID, input, false, true,
- &error));
+ FilePath(extension_path), Extension::INVALID, input,
+ Extension::STRICT_ERROR_CHECKS, &error));
bookmarks_function->set_name(T::function_name());
base::WaitableEvent done_event(false, false);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
@@ -132,8 +132,8 @@ class ExtensionsActivityMonitorTest : public testing::Test {
input.SetString(keys::kVersion, kTestExtensionVersion);
input.SetString(keys::kName, kTestExtensionName);
scoped_refptr<Extension> extension(Extension::Create(
- FilePath(extension_path), Extension::INVALID, input, false, true,
- &error));
+ FilePath(extension_path), Extension::INVALID, input,
+ Extension::STRICT_ERROR_CHECKS, &error));
EXPECT_EQ("", error);
return extension->id();
}
diff --git a/chrome/browser/themes/browser_theme_pack_unittest.cc b/chrome/browser/themes/browser_theme_pack_unittest.cc
index 492cf06..842833b 100644
--- a/chrome/browser/themes/browser_theme_pack_unittest.cc
+++ b/chrome/browser/themes/browser_theme_pack_unittest.cc
@@ -406,8 +406,8 @@ TEST_F(BrowserThemePackTest, CanBuildAndReadPack) {
EXPECT_EQ("", error);
ASSERT_TRUE(valid_value.get());
scoped_refptr<Extension> extension(Extension::Create(
- star_gazing_path, Extension::INVALID, *valid_value, true, true,
- &error));
+ star_gazing_path, Extension::INVALID, *valid_value,
+ Extension::REQUIRE_KEY | Extension::STRICT_ERROR_CHECKS, &error));
ASSERT_TRUE(extension.get());
ASSERT_EQ("", error);
diff --git a/chrome/browser/ui/cocoa/extensions/extension_install_prompt_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_install_prompt_controller_unittest.mm
index f11aeb4..aaa9aa3 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_install_prompt_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_install_prompt_controller_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -60,8 +60,8 @@ public:
return;
}
- extension_ = Extension::Create(
- path.DirName(), Extension::INVALID, *value, false, true, &error);
+ extension_ = Extension::Create(path.DirName(), Extension::INVALID, *value,
+ Extension::STRICT_ERROR_CHECKS, &error);
if (!extension_.get()) {
LOG(ERROR) << error;
return;
diff --git a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm
index 9242796..1205c58 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_installed_bubble_controller_unittest.mm
@@ -100,8 +100,8 @@ class ExtensionInstalledBubbleControllerTest : public CocoaTest {
}
std::string error;
- return Extension::Create(
- path, Extension::INVALID, extension_input_value, false, true, &error);
+ return Extension::Create(path, Extension::INVALID, extension_input_value,
+ Extension::STRICT_ERROR_CHECKS, &error);
}
// Allows us to create the window and browser for testing.
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 2c57937..d6e0305 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -275,12 +275,11 @@ const int Extension::kValidHostPermissionSchemes =
scoped_refptr<Extension> Extension::Create(const FilePath& path,
Location location,
const DictionaryValue& value,
- bool require_key,
- bool strict_error_checks,
+ int flags,
std::string* error) {
scoped_refptr<Extension> extension = new Extension(path, location);
- if (!extension->InitFromValue(value, require_key, strict_error_checks, error))
+ if (!extension->InitFromValue(value, flags, error))
return NULL;
return extension;
}
@@ -1402,12 +1401,12 @@ GURL Extension::GetBaseURLFromExtensionId(const std::string& extension_id) {
chrome::kStandardSchemeSeparator + extension_id + "/");
}
-bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
- bool strict_error_checks, std::string* error) {
+bool Extension::InitFromValue(const DictionaryValue& source, int flags,
+ std::string* error) {
// When strict error checks are enabled, make URL pattern parsing strict.
URLPattern::ParseOption parse_strictness =
- (strict_error_checks ? URLPattern::PARSE_STRICT
- : URLPattern::PARSE_LENIENT);
+ (flags & STRICT_ERROR_CHECKS ? URLPattern::PARSE_STRICT
+ : URLPattern::PARSE_LENIENT);
if (source.HasKey(keys::kPublicKey)) {
std::string public_key_bytes;
@@ -1419,7 +1418,7 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
*error = errors::kInvalidKey;
return false;
}
- } else if (require_key) {
+ } else if (flags & REQUIRE_KEY) {
*error = errors::kInvalidKey;
return false;
} else {
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index e029c7a..6b40f15 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -114,21 +114,31 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
const int message_id;
};
- // |strict_error_checks| enables extra error checking, such as
- // checks that URL patterns do not contain ports. This error
- // checking may find an error that a previous version of
- // chrome did not flag. To avoid errors in installed extensions
- // when chrome is upgraded, strict error checking is only enabled
- // when loading extensions as a developer would (such as loading
- // an unpacked extension), or when loading an extension that is
- // tied to a specific version of chrome (such as a component
- // extension). Most callers will set |strict_error_checks| to
- // Extension::ShouldDoStrictErrorChecking(location).
+ enum InitFromValueFlags {
+ NO_FLAGS = 0,
+
+ // Usually, the id of an extension is generated by the "key" property of
+ // its manifest, but if |REQUIRE_KEY| is not set, a temporary ID will be
+ // generated based on the path.
+ REQUIRE_KEY = 1 << 0,
+
+ // |STRICT_ERROR_CHECKS| enables extra error checking, such as
+ // checks that URL patterns do not contain ports. This error
+ // checking may find an error that a previous version of
+ // Chrome did not flag. To avoid errors in installed extensions
+ // when Chrome is upgraded, strict error checking is only enabled
+ // when loading extensions as a developer would (such as loading
+ // an unpacked extension), or when loading an extension that is
+ // tied to a specific version of Chrome (such as a component
+ // extension). Most callers will set the |STRICT_ERROR_CHECKS| bit when
+ // Extension::ShouldDoStrictErrorChecking(location) returns true.
+ STRICT_ERROR_CHECKS = 1 << 1,
+ };
+
static scoped_refptr<Extension> Create(const FilePath& path,
Location location,
const DictionaryValue& value,
- bool require_key,
- bool strict_error_checks,
+ int flags,
std::string* error);
// Return the update url used by gallery/webstore extensions.
@@ -539,11 +549,8 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
~Extension();
// Initialize the extension from a parsed manifest.
- // Usually, the id of an extension is generated by the "key" property of
- // its manifest, but if |require_key| is |false|, a temporary ID will be
- // generated based on the path.
- bool InitFromValue(const DictionaryValue& value, bool require_key,
- bool strict_error_checks, std::string* error);
+ bool InitFromValue(const DictionaryValue& value, int flags,
+ std::string* error);
// Helper function for implementing HasCachedImage/GetCachedImage. A return
// value of NULL means there is no matching image cached (we allow caching an
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index 5d52026..1c4ec8c 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -88,8 +88,7 @@ void UninstallExtension(const FilePath& extensions_dir,
scoped_refptr<Extension> LoadExtension(const FilePath& extension_path,
Extension::Location location,
- bool require_key,
- bool strict_error_checks,
+ int flags,
std::string* error) {
FilePath manifest_path =
extension_path.Append(Extension::kManifestFilename);
@@ -128,8 +127,7 @@ scoped_refptr<Extension> LoadExtension(const FilePath& extension_path,
extension_path,
location,
*manifest,
- require_key,
- strict_error_checks,
+ flags,
error));
if (!extension.get())
return NULL;
diff --git a/chrome/common/extensions/extension_file_util.h b/chrome/common/extensions/extension_file_util.h
index 066ee80..114549f 100644
--- a/chrome/common/extensions/extension_file_util.h
+++ b/chrome/common/extensions/extension_file_util.h
@@ -39,8 +39,7 @@ void UninstallExtension(const FilePath& extensions_dir,
// on failure, with a description of the error in |error|.
scoped_refptr<Extension> LoadExtension(const FilePath& extension_root,
Extension::Location location,
- bool require_key,
- bool strict_error_checks,
+ int flags,
std::string* error);
// Returns true if the given extension object is valid and consistent.
diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc
index 8735f73..5a6f782 100644
--- a/chrome/common/extensions/extension_file_util_unittest.cc
+++ b/chrome/common/extensions/extension_file_util_unittest.cc
@@ -79,7 +79,7 @@ TEST(ExtensionFileUtil, LoadExtensionWithValidLocales) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
- install_dir, Extension::LOAD, false, true, &error));
+ install_dir, Extension::LOAD, Extension::STRICT_ERROR_CHECKS, &error));
ASSERT_TRUE(extension != NULL);
EXPECT_EQ("The first extension that I made.", extension->description());
}
@@ -95,7 +95,7 @@ TEST(ExtensionFileUtil, LoadExtensionWithoutLocalesFolder) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
- install_dir, Extension::LOAD, false, true, &error));
+ install_dir, Extension::LOAD, Extension::STRICT_ERROR_CHECKS, &error));
ASSERT_FALSE(extension == NULL);
EXPECT_TRUE(error.empty());
}
@@ -153,7 +153,7 @@ TEST(ExtensionFileUtil, LoadExtensionGivesHelpfullErrorOnMissingManifest) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
- install_dir, Extension::LOAD, false, true, &error));
+ install_dir, Extension::LOAD, Extension::STRICT_ERROR_CHECKS, &error));
ASSERT_TRUE(extension == NULL);
ASSERT_FALSE(error.empty());
ASSERT_STREQ("Manifest file is missing or unreadable.", error.c_str());
@@ -170,7 +170,7 @@ TEST(ExtensionFileUtil, LoadExtensionGivesHelpfullErrorOnBadManifest) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
- install_dir, Extension::LOAD, false, true, &error));
+ install_dir, Extension::LOAD, Extension::STRICT_ERROR_CHECKS, &error));
ASSERT_TRUE(extension == NULL);
ASSERT_FALSE(error.empty());
ASSERT_STREQ("Manifest is not valid JSON. "
@@ -186,7 +186,7 @@ TEST(ExtensionFileUtil, FailLoadingNonUTF8Scripts) {
std::string error;
scoped_refptr<Extension> extension(extension_file_util::LoadExtension(
- install_dir, Extension::LOAD, false, true, &error));
+ install_dir, Extension::LOAD, Extension::STRICT_ERROR_CHECKS, &error));
ASSERT_TRUE(extension == NULL);
ASSERT_STREQ("Could not load file 'bad_encoding.js' for content script. "
"It isn't UTF-8 encoded.", error.c_str());
diff --git a/chrome/common/extensions/extension_manifests_unittest.cc b/chrome/common/extensions/extension_manifests_unittest.cc
index cb5996e..d1a15af 100644
--- a/chrome/common/extensions/extension_manifests_unittest.cc
+++ b/chrome/common/extensions/extension_manifests_unittest.cc
@@ -48,8 +48,10 @@ class ExtensionManifestTest : public testing::Test {
FilePath path;
PathService::Get(chrome::DIR_TEST_DATA, &path);
path = path.AppendASCII("extensions").AppendASCII("manifest_tests");
- return Extension::Create(path.DirName(), location, *value, false,
- strict_error_checks, error);
+ int flags = Extension::NO_FLAGS;
+ if (strict_error_checks)
+ flags |= Extension::STRICT_ERROR_CHECKS;
+ return Extension::Create(path.DirName(), location, *value, flags, error);
}
scoped_refptr<Extension> LoadExtension(const std::string& name,
diff --git a/chrome/common/extensions/extension_messages.cc b/chrome/common/extensions/extension_messages.cc
index b9ba244..88c94926 100644
--- a/chrome/common/extensions/extension_messages.cc
+++ b/chrome/common/extensions/extension_messages.cc
@@ -49,17 +49,11 @@ ExtensionMsg_Loaded_Params::ExtensionMsg_Loaded_Params(
scoped_refptr<Extension>
ExtensionMsg_Loaded_Params::ConvertToExtension() const {
- // Extensions that are loaded unpacked won't have a key.
- const bool kRequireKey = false;
-
- // The extension may have been loaded in a way that does not require
- // strict error checks to pass. Do not do strict checks here.
- const bool kStrictErrorChecks = false;
std::string error;
scoped_refptr<Extension> extension(
- Extension::Create(path, location, *manifest, kRequireKey,
- kStrictErrorChecks, &error));
+ Extension::Create(path, location, *manifest, Extension::NO_FLAGS,
+ &error));
if (!extension.get())
LOG(ERROR) << "Error deserializing extension: " << error;
diff --git a/chrome/common/extensions/extension_set_unittest.cc b/chrome/common/extensions/extension_set_unittest.cc
index 1b9eba0..e51d5718 100644
--- a/chrome/common/extensions/extension_set_unittest.cc
+++ b/chrome/common/extensions/extension_set_unittest.cc
@@ -36,12 +36,10 @@ scoped_refptr<Extension> CreateTestExtension(const std::string& name,
urls->Append(Value::CreateStringValue(extent));
}
- const bool kRequireKey = false;
- const bool kStrictErrorChecks = true;
std::string error;
scoped_refptr<Extension> extension(
- Extension::Create(path, Extension::INTERNAL, manifest, kRequireKey,
- kStrictErrorChecks, &error));
+ Extension::Create(path, Extension::INTERNAL, manifest,
+ Extension::STRICT_ERROR_CHECKS, &error));
EXPECT_TRUE(extension.get()) << error;
return extension;
}
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index f1dc9ed..e3d2d4f 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -105,7 +105,8 @@ TEST(ExtensionTest, InitFromValueInvalid) {
EXPECT_EQ("", error);
EXPECT_EQ(0, error_code);
ASSERT_TRUE(valid_value.get());
- ASSERT_TRUE(extension.InitFromValue(*valid_value, true, false, &error));
+ ASSERT_TRUE(extension.InitFromValue(*valid_value, Extension::REQUIRE_KEY,
+ &error));
ASSERT_EQ("", error);
EXPECT_EQ("en_US", extension.default_locale());
@@ -114,33 +115,39 @@ TEST(ExtensionTest, InitFromValueInvalid) {
// Test missing and invalid versions
input_value.reset(valid_value->DeepCopy());
input_value->Remove(keys::kVersion, NULL);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidVersion, error);
input_value->SetInteger(keys::kVersion, 42);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidVersion, error);
// Test missing and invalid names.
input_value.reset(valid_value->DeepCopy());
input_value->Remove(keys::kName, NULL);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidName, error);
input_value->SetInteger(keys::kName, 42);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidName, error);
// Test invalid description
input_value.reset(valid_value->DeepCopy());
input_value->SetInteger(keys::kDescription, 42);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidDescription, error);
// Test invalid icons
input_value.reset(valid_value->DeepCopy());
input_value->SetInteger(keys::kIcons, 42);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidIcons, error);
// Test invalid icon paths
@@ -149,13 +156,15 @@ TEST(ExtensionTest, InitFromValueInvalid) {
input_value->GetDictionary(keys::kIcons, &icons);
ASSERT_FALSE(NULL == icons);
icons->SetInteger(base::IntToString(128), 42);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidIconPath));
// Test invalid user scripts list
input_value.reset(valid_value->DeepCopy());
input_value->SetInteger(keys::kContentScripts, 42);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_EQ(errors::kInvalidContentScriptsList, error);
// Test invalid user script item
@@ -164,7 +173,8 @@ TEST(ExtensionTest, InitFromValueInvalid) {
input_value->GetList(keys::kContentScripts, &content_scripts);
ASSERT_FALSE(NULL == content_scripts);
content_scripts->Set(0, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidContentScript));
// Test missing and invalid matches array
@@ -173,25 +183,30 @@ TEST(ExtensionTest, InitFromValueInvalid) {
DictionaryValue* user_script = NULL;
content_scripts->GetDictionary(0, &user_script);
user_script->Remove(keys::kMatches, NULL);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatches));
user_script->Set(keys::kMatches, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatches));
ListValue* matches = new ListValue;
user_script->Set(keys::kMatches, matches);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatchCount));
// Test invalid match element
matches->Set(0, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatch));
matches->Set(0, Value::CreateStringValue("chrome://*/*"));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidMatch));
// Test missing and invalid files array
@@ -200,45 +215,53 @@ TEST(ExtensionTest, InitFromValueInvalid) {
content_scripts->GetDictionary(0, &user_script);
user_script->Remove(keys::kJs, NULL);
user_script->Remove(keys::kCss, NULL);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kMissingFile));
user_script->Set(keys::kJs, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidJsList));
user_script->Set(keys::kCss, new ListValue);
user_script->Set(keys::kJs, new ListValue);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kMissingFile));
user_script->Remove(keys::kCss, NULL);
ListValue* files = new ListValue;
user_script->Set(keys::kJs, files);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kMissingFile));
// Test invalid file element
files->Set(0, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidJs));
user_script->Remove(keys::kJs, NULL);
// Test the css element
user_script->Set(keys::kCss, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidCssList));
// Test invalid file element
ListValue* css_files = new ListValue;
user_script->Set(keys::kCss, css_files);
css_files->Set(0, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidCss));
// Test missing and invalid permissions array
input_value.reset(valid_value->DeepCopy());
- EXPECT_TRUE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
ListValue* permissions = NULL;
input_value->GetList(keys::kPermissions, &permissions);
@@ -246,22 +269,26 @@ TEST(ExtensionTest, InitFromValueInvalid) {
permissions = new ListValue;
input_value->Set(keys::kPermissions, permissions);
- EXPECT_TRUE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
input_value->Set(keys::kPermissions, Value::CreateIntegerValue(9));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermissions));
input_value.reset(valid_value->DeepCopy());
input_value->GetList(keys::kPermissions, &permissions);
permissions->Set(0, Value::CreateIntegerValue(24));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidPermission));
// We allow unknown API permissions, so this will be valid until we better
// distinguish between API and host permissions.
permissions->Set(0, Value::CreateStringValue("www.google.com"));
- EXPECT_TRUE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
// Multiple page actions are not allowed.
input_value.reset(valid_value->DeepCopy());
@@ -272,36 +299,42 @@ TEST(ExtensionTest, InitFromValueInvalid) {
action_list->Append(action->DeepCopy());
action_list->Append(action);
input_value->Set(keys::kPageActions, action_list);
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_STREQ(errors::kInvalidPageActionsListSize, error.c_str());
// Test invalid options page url.
input_value.reset(valid_value->DeepCopy());
input_value->Set(keys::kOptionsPage, Value::CreateNullValue());
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidOptionsPage));
// Test invalid/empty default locale.
input_value.reset(valid_value->DeepCopy());
input_value->Set(keys::kDefaultLocale, Value::CreateIntegerValue(5));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidDefaultLocale));
input_value->Set(keys::kDefaultLocale, Value::CreateStringValue(""));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidDefaultLocale));
// Test invalid minimum_chrome_version.
input_value.reset(valid_value->DeepCopy());
input_value->Set(keys::kMinimumChromeVersion, Value::CreateIntegerValue(42));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kInvalidMinimumChromeVersion));
#if !defined(OS_MACOSX)
// TODO(aa): The version isn't stamped into the unit test binary on mac.
input_value->Set(keys::kMinimumChromeVersion,
Value::CreateStringValue("88.8"));
- EXPECT_FALSE(extension.InitFromValue(*input_value, true, false, &error));
+ EXPECT_FALSE(extension.InitFromValue(*input_value, Extension::REQUIRE_KEY,
+ &error));
EXPECT_TRUE(MatchPattern(error, errors::kChromeVersionTooLow));
#endif
}
@@ -322,7 +355,8 @@ TEST(ExtensionTest, InitFromValueValid) {
input_value.SetString(keys::kVersion, "1.0.0.0");
input_value.SetString(keys::kName, "my extension");
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
EXPECT_EQ("", error);
EXPECT_TRUE(Extension::IdIsValid(extension.id()));
EXPECT_EQ("1.0.0.0", extension.VersionString());
@@ -337,12 +371,14 @@ TEST(ExtensionTest, InitFromValueValid) {
// We allow unknown API permissions, so this will be valid until we better
// distinguish between API and host permissions.
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
input_value.Remove(keys::kPermissions, NULL);
// Test with an options page.
input_value.SetString(keys::kOptionsPage, "options.html");
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
EXPECT_EQ("", error);
EXPECT_EQ("chrome-extension", extension.options_url().scheme());
EXPECT_EQ("/options.html", extension.options_url().path());
@@ -351,14 +387,16 @@ TEST(ExtensionTest, InitFromValueValid) {
// from being loaded.
ListValue* empty_list = new ListValue;
input_value.Set(keys::kPageActions, empty_list);
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
EXPECT_EQ("", error);
#if !defined(OS_MACOSX)
// TODO(aa): The version isn't stamped into the unit test binary on mac.
// Test with a minimum_chrome_version.
input_value.SetString(keys::kMinimumChromeVersion, "1.0");
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
EXPECT_EQ("", error);
// The minimum chrome version is not stored in the Extension object.
#endif
@@ -388,7 +426,8 @@ TEST(ExtensionTest, InitFromValueValidNameInRTL) {
// No strong RTL characters in name.
std::wstring name(L"Dictionary (by Google)");
input_value.SetString(keys::kName, WideToUTF16Hack(name));
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
EXPECT_EQ("", error);
std::wstring localized_name(name);
base::i18n::AdjustStringForLocaleDirection(&localized_name);
@@ -397,7 +436,8 @@ TEST(ExtensionTest, InitFromValueValidNameInRTL) {
// Strong RTL characters in name.
name = L"Dictionary (\x05D1\x05D2"L" Google)";
input_value.SetString(keys::kName, WideToUTF16Hack(name));
- EXPECT_TRUE(extension.InitFromValue(input_value, false, false, &error));
+ EXPECT_TRUE(extension.InitFromValue(input_value, Extension::NO_FLAGS,
+ &error));
EXPECT_EQ("", error);
localized_name = name;
base::i18n::AdjustStringForLocaleDirection(&localized_name);
@@ -420,8 +460,8 @@ TEST(ExtensionTest, GetResourceURLAndPath) {
DictionaryValue input_value;
input_value.SetString(keys::kVersion, "1.0.0.0");
input_value.SetString(keys::kName, "my extension");
- scoped_refptr<Extension> extension(Extension::Create(
- path, Extension::INVALID, input_value, false, true, NULL));
+ scoped_refptr<Extension> extension(Extension::Create(path,
+ Extension::INVALID, input_value, Extension::STRICT_ERROR_CHECKS, NULL));
EXPECT_TRUE(extension.get());
EXPECT_EQ(extension->url().spec() + "bar/baz.js",
@@ -680,7 +720,8 @@ TEST(ExtensionTest, UpdateUrls) {
input_value.SetString(keys::kUpdateURL, url.spec());
scoped_refptr<Extension> extension(Extension::Create(
- path, Extension::INVALID, input_value, false, true, &error));
+ path, Extension::INVALID, input_value, Extension::STRICT_ERROR_CHECKS,
+ &error));
EXPECT_TRUE(extension.get()) << error;
}
@@ -704,7 +745,8 @@ TEST(ExtensionTest, UpdateUrls) {
input_value.SetString(keys::kUpdateURL, invalid[i]);
scoped_refptr<Extension> extension(Extension::Create(
- path, Extension::INVALID, input_value, false, true, &error));
+ path, Extension::INVALID, input_value, Extension::STRICT_ERROR_CHECKS,
+ &error));
EXPECT_FALSE(extension.get());
EXPECT_TRUE(MatchPattern(error, errors::kInvalidUpdateURL));
}
@@ -752,7 +794,8 @@ static scoped_refptr<Extension> LoadManifest(const std::string& dir,
scoped_refptr<Extension> extension = Extension::Create(
path.DirName(), Extension::INVALID,
- *static_cast<DictionaryValue*>(result.get()), false, true, &error);
+ *static_cast<DictionaryValue*>(result.get()),
+ Extension::STRICT_ERROR_CHECKS, &error);
EXPECT_TRUE(extension) << error;
return extension;
}
@@ -979,7 +1022,8 @@ TEST(ExtensionTest, ImageCaching) {
values.SetString(keys::kName, "test");
values.SetString(keys::kVersion, "0.1");
scoped_refptr<Extension> extension(Extension::Create(
- path, Extension::INVALID, values, false, true, &errors));
+ path, Extension::INVALID, values, Extension::STRICT_ERROR_CHECKS,
+ &errors));
ASSERT_TRUE(extension.get());
// Create an ExtensionResource pointing at an icon.
@@ -1063,7 +1107,8 @@ TEST(ExtensionTest, OldUnlimitedStoragePermission) {
// is present.
std::string errors;
scoped_refptr<Extension> extension(Extension::Create(
- extension_path, Extension::INVALID, dictionary, false, true, &errors));
+ extension_path, Extension::INVALID, dictionary,
+ Extension::STRICT_ERROR_CHECKS, &errors));
EXPECT_TRUE(extension.get());
EXPECT_TRUE(extension->HasApiPermission(
Extension::kUnlimitedStoragePermission));
diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc
index 39ea38d..3561b6a 100644
--- a/chrome/common/extensions/extension_unpacker.cc
+++ b/chrome/common/extensions/extension_unpacker.cc
@@ -180,8 +180,7 @@ bool ExtensionUnpacker::Run() {
temp_install_dir_,
Extension::INVALID,
*parsed_manifest_,
- false, // Do not require a key
- false, // Do not enable strict error checks
+ Extension::NO_FLAGS,
&error));
if (!extension.get()) {
SetError(error);
diff --git a/chrome/test/live_sync/live_extensions_sync_test_base.cc b/chrome/test/live_sync/live_extensions_sync_test_base.cc
index 26aa257..691330e 100644
--- a/chrome/test/live_sync/live_extensions_sync_test_base.cc
+++ b/chrome/test/live_sync/live_extensions_sync_test_base.cc
@@ -47,8 +47,8 @@ scoped_refptr<Extension> CreateExtension(
}
std::string error;
scoped_refptr<Extension> extension =
- Extension::Create(extension_dir,
- Extension::INTERNAL, source, false, true, &error);
+ Extension::Create(extension_dir, Extension::INTERNAL,
+ source, Extension::STRICT_ERROR_CHECKS, &error);
if (!error.empty()) {
LOG(WARNING) << error;
return NULL;