diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 20:33:39 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 20:33:39 +0000 |
commit | 9ba6f3883088413828b348730d3a003d77627e76 (patch) | |
tree | 992d3238ca25355432e15852bf1aad94794aabe9 /chrome/browser | |
parent | aec1cf180cfc3797c05c526656052f73d7d60408 (diff) | |
download | chromium_src-9ba6f3883088413828b348730d3a003d77627e76.zip chromium_src-9ba6f3883088413828b348730d3a003d77627e76.tar.gz chromium_src-9ba6f3883088413828b348730d3a003d77627e76.tar.bz2 |
Explicitly disallow user scripts from extensions sync.
BUG=46654
TEST=ExtensionUtilTest.IsSyncableExtension
Review URL: http://codereview.chromium.org/2803022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50762 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/sync/glue/extension_util.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sync/glue/extension_util_unittest.cc | 24 |
2 files changed, 23 insertions, 8 deletions
diff --git a/chrome/browser/sync/glue/extension_util.cc b/chrome/browser/sync/glue/extension_util.cc index 9cc8f7f..0ff226c 100644 --- a/chrome/browser/sync/glue/extension_util.cc +++ b/chrome/browser/sync/glue/extension_util.cc @@ -22,13 +22,16 @@ bool IsExtensionSyncable(const Extension& extension) { } // TODO(akalin): Add Extensions::is_app(). - // TODO(akalin): Figure out if we want to treat extensions and apps - // identically after all. if (!extension.GetFullLaunchURL().is_empty()) { // We have an app. return false; } + if (extension.converted_from_user_script()) { + // User scripts currently don't have auto-update URLs. + return false; + } + // TODO(akalin): Figure out if we need to allow some other types. if (extension.location() != Extension::INTERNAL) { // We have a non-standard location. diff --git a/chrome/browser/sync/glue/extension_util_unittest.cc b/chrome/browser/sync/glue/extension_util_unittest.cc index 9094838..17305acd 100644 --- a/chrome/browser/sync/glue/extension_util_unittest.cc +++ b/chrome/browser/sync/glue/extension_util_unittest.cc @@ -37,6 +37,7 @@ class ExtensionUtilTest : public testing::Test { void MakePossiblySyncableExtension(bool is_theme, const GURL& launch_url, + bool converted_from_user_script, Extension::Location location, Extension* extension) { DictionaryValue source; @@ -50,6 +51,10 @@ void MakePossiblySyncableExtension(bool is_theme, source.SetString(extension_manifest_keys::kLaunchWebURL, launch_url.spec()); } + if (!is_theme) { + source.SetBoolean(extension_manifest_keys::kConvertedFromUserScript, + converted_from_user_script); + } std::string error; EXPECT_TRUE(extension->InitFromValue(source, false, &error)); EXPECT_EQ("", error); @@ -60,15 +65,22 @@ TEST_F(ExtensionUtilTest, IsSyncableExtension) { { FilePath file_path(kExtensionFilePath); Extension extension(file_path); - MakePossiblySyncableExtension(false, GURL(), Extension::INTERNAL, - &extension); + MakePossiblySyncableExtension(false, GURL(), false, + Extension::INTERNAL, &extension); EXPECT_TRUE(IsExtensionSyncable(extension)); } { FilePath file_path(kExtensionFilePath); Extension extension(file_path); - MakePossiblySyncableExtension(true, GURL(), Extension::INTERNAL, - &extension); + MakePossiblySyncableExtension(true, GURL(), false, + Extension::INTERNAL, &extension); + EXPECT_FALSE(IsExtensionSyncable(extension)); + } + { + FilePath file_path(kExtensionFilePath); + Extension extension(file_path); + MakePossiblySyncableExtension(false, GURL(), true, + Extension::INTERNAL, &extension); EXPECT_FALSE(IsExtensionSyncable(extension)); } // TODO(akalin): Test with a non-empty launch_url once apps are @@ -76,8 +88,8 @@ TEST_F(ExtensionUtilTest, IsSyncableExtension) { { FilePath file_path(kExtensionFilePath); Extension extension(file_path); - MakePossiblySyncableExtension(false, GURL(), Extension::EXTERNAL_PREF, - &extension); + MakePossiblySyncableExtension(false, GURL(), false, + Extension::EXTERNAL_PREF, &extension); EXPECT_FALSE(IsExtensionSyncable(extension)); } } |