summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_startup_browsertest.cc13
-rw-r--r--chrome/browser/extensions/extension_ui_unittest.cc2
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc66
-rw-r--r--chrome/browser/sync/glue/extension_util_unittest.cc7
-rw-r--r--chrome/common/extensions/extension.cc7
-rw-r--r--chrome/common/extensions/extension_constants.cc4
-rw-r--r--chrome/common/extensions/extension_constants.h3
-rw-r--r--chrome/common/extensions/extension_unittest.cc4
-rw-r--r--chrome/test/data/extensions/permissions-high-v2.crxbin914 -> 639 bytes
9 files changed, 92 insertions, 14 deletions
diff --git a/chrome/browser/extensions/extension_startup_browsertest.cc b/chrome/browser/extensions/extension_startup_browsertest.cc
index 165054d..9ca4d081 100644
--- a/chrome/browser/extensions/extension_startup_browsertest.cc
+++ b/chrome/browser/extensions/extension_startup_browsertest.cc
@@ -31,6 +31,11 @@
class ExtensionStartupTestBase : public InProcessBrowserTest {
public:
ExtensionStartupTestBase() : enable_extensions_(false) {
+#if defined(OS_CHROMEOS)
+ num_expected_extensions_ = 3;
+#else
+ num_expected_extensions_ = 4;
+#endif
}
protected:
@@ -124,6 +129,8 @@ class ExtensionStartupTestBase : public InProcessBrowserTest {
FilePath user_scripts_dir_;
bool enable_extensions_;
FilePath load_extension_;
+
+ int num_expected_extensions_;
};
@@ -139,7 +146,8 @@ class ExtensionsStartupTest : public ExtensionStartupTestBase {
};
IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, Test) {
- WaitForServicesToStart(4, true); // 1 component extension and 3 others.
+ // 1 component extension and 2 or 3 others, depending on the platform.
+ WaitForServicesToStart(num_expected_extensions_, true);
TestInjection(true, true);
}
@@ -152,7 +160,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, Test) {
// Tests that disallowing file access on an extension prevents it from injecting
// script into a page with a file URL.
IN_PROC_BROWSER_TEST_F(ExtensionsStartupTest, MAYBE_NoFileAccess) {
- WaitForServicesToStart(4, true); // 1 component extension and 3 others.
+ // 1 component extension and 2 or 3 others, depending on the platform.
+ WaitForServicesToStart(num_expected_extensions_, true);
ExtensionsService* service = browser()->profile()->GetExtensionsService();
for (size_t i = 0; i < service->extensions()->size(); ++i) {
diff --git a/chrome/browser/extensions/extension_ui_unittest.cc b/chrome/browser/extensions/extension_ui_unittest.cc
index 96af1c8..f4075b6 100644
--- a/chrome/browser/extensions/extension_ui_unittest.cc
+++ b/chrome/browser/extensions/extension_ui_unittest.cc
@@ -85,6 +85,7 @@ TEST(ExtensionUITest, GenerateExtensionsJSONData) {
EXPECT_TRUE(CompareExpectedAndActualOutput(extension_path, pages,
expected_output_path)) << extension_path.value();
+#if !defined(OS_CHROMEOS)
// Test Extension2
extension_path = data_test_dir_path.AppendASCII("extensions")
.AppendASCII("good")
@@ -102,6 +103,7 @@ TEST(ExtensionUITest, GenerateExtensionsJSONData) {
EXPECT_TRUE(CompareExpectedAndActualOutput(extension_path, pages,
expected_output_path)) << extension_path.value();
+#endif
// Test Extension3
extension_path = data_test_dir_path.AppendASCII("extensions")
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index 1319da9..b8c176b 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -681,7 +681,13 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
service_->Init();
loop_.RunAllPending();
- ASSERT_EQ(3u, loaded_.size());
+ // On Chrome OS, we disallow extensions with plugins. "good1" has plugins,
+ // so we need to edit it out here.
+ uint32 expected_num_extensions = 3u;
+#if defined(OS_CHROMEOS)
+ --expected_num_extensions;
+#endif
+ ASSERT_EQ(expected_num_extensions, loaded_.size());
EXPECT_EQ(std::string(good0), loaded_[0]->id());
EXPECT_EQ(std::string("My extension 1"),
@@ -690,7 +696,7 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
loaded_[0]->description());
EXPECT_EQ(Extension::INTERNAL, loaded_[0]->location());
EXPECT_TRUE(service_->GetExtensionById(loaded_[0]->id(), false));
- EXPECT_EQ(3u, service_->extensions()->size());
+ EXPECT_EQ(expected_num_extensions, service_->extensions()->size());
ValidatePrefKeyCount(3);
ValidateIntegerPref(good0, "state", Extension::ENABLED);
@@ -738,6 +744,7 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
EXPECT_EQ("http://*.google.com/*", permissions[0].GetAsString());
EXPECT_EQ("https://*.google.com/*", permissions[1].GetAsString());
+#if !defined(OS_CHROMEOS)
EXPECT_EQ(std::string(good1), loaded_[1]->id());
EXPECT_EQ(std::string("My extension 2"), loaded_[1]->name());
EXPECT_EQ(std::string(""), loaded_[1]->description());
@@ -752,12 +759,14 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
loaded_[1]->plugins()[1].path.value());
EXPECT_FALSE(loaded_[1]->plugins()[1].is_public);
EXPECT_EQ(Extension::INTERNAL, loaded_[1]->location());
+#endif
- EXPECT_EQ(std::string(good2), loaded_[2]->id());
- EXPECT_EQ(std::string("My extension 3"), loaded_[2]->name());
- EXPECT_EQ(std::string(""), loaded_[2]->description());
- EXPECT_EQ(0u, loaded_[2]->content_scripts().size());
- EXPECT_EQ(Extension::INTERNAL, loaded_[2]->location());
+ int index = expected_num_extensions - 1;
+ EXPECT_EQ(std::string(good2), loaded_[index]->id());
+ EXPECT_EQ(std::string("My extension 3"), loaded_[index]->name());
+ EXPECT_EQ(std::string(""), loaded_[index]->description());
+ EXPECT_EQ(0u, loaded_[index]->content_scripts().size());
+ EXPECT_EQ(Extension::INTERNAL, loaded_[index]->location());
};
// Test loading bad extensions from the profile directory.
@@ -1677,15 +1686,47 @@ TEST_F(ExtensionsServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
.AppendASCII("Preferences");
InitializeInstalledExtensionsService(pref_path, source_install_dir);
- // Blacklist good0.
+ // Blacklist good1.
std::vector<std::string> blacklist;
- blacklist.push_back(good0);
+ blacklist.push_back(good1);
service_->UpdateExtensionBlacklist(blacklist);
// Make sure pref is updated
loop_.RunAllPending();
- ValidateBooleanPref(good0, "blacklist", true);
+ ValidateBooleanPref(good1, "blacklist", true);
+
+ // Load extensions.
+ service_->Init();
+ loop_.RunAllPending();
+
+ std::vector<std::string> errors = GetErrors();
+ for (std::vector<std::string>::iterator err = errors.begin();
+ err != errors.end(); ++err) {
+ LOG(ERROR) << *err;
+ }
+ ASSERT_EQ(2u, loaded_.size());
+
+ EXPECT_NE(std::string(good1), loaded_[0]->id());
+ EXPECT_NE(std::string(good1), loaded_[1]->id());
+}
+#if defined(OS_CHROMEOS)
+// Test loading extensions from the profile directory, except
+// ones with a plugin.
+TEST_F(ExtensionsServiceTest, WillNotLoadPluginExtensionsFromDirectory) {
+ // Initialize the test dir with a good Preferences/extensions.
+ FilePath source_install_dir;
+ ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_install_dir));
+ source_install_dir = source_install_dir
+ .AppendASCII("extensions")
+ .AppendASCII("good")
+ .AppendASCII("Extensions");
+ FilePath pref_path = source_install_dir
+ .DirName()
+ .AppendASCII("Preferences");
+ InitializeInstalledExtensionsService(pref_path, source_install_dir);
+
+ // good1 contains a plugin.
// Load extensions.
service_->Init();
loop_.RunAllPending();
@@ -1697,9 +1738,10 @@ TEST_F(ExtensionsServiceTest, WillNotLoadBlacklistedExtensionsFromDirectory) {
}
ASSERT_EQ(2u, loaded_.size());
- EXPECT_NE(std::string(good0), loaded_[0]->id());
- EXPECT_NE(std::string(good0), loaded_[1]->id());
+ EXPECT_NE(std::string(good1), loaded_[0]->id());
+ EXPECT_NE(std::string(good1), loaded_[1]->id());
}
+#endif
// Will not install extension blacklisted by policy.
TEST_F(ExtensionsServiceTest, BlacklistedByPolicyWillNotInstall) {
diff --git a/chrome/browser/sync/glue/extension_util_unittest.cc b/chrome/browser/sync/glue/extension_util_unittest.cc
index ba87b8d..6a3aacc 100644
--- a/chrome/browser/sync/glue/extension_util_unittest.cc
+++ b/chrome/browser/sync/glue/extension_util_unittest.cc
@@ -66,7 +66,14 @@ void MakeExtension(bool is_theme, const GURL& update_url,
}
source.Set(extension_manifest_keys::kPlugins, plugins);
}
+
std::string error;
+#if defined(OS_CHROMEOS)
+ if (num_plugins > 0) { // plugins are illegal in extensions on chrome os.
+ EXPECT_FALSE(extension->InitFromValue(source, false, &error));
+ return;
+ }
+#endif
EXPECT_TRUE(extension->InitFromValue(source, false, &error));
EXPECT_EQ("", error);
extension->set_location(location);
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 24b05de..aad0d4a 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1208,6 +1208,13 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
return false;
}
+#if defined(OS_CHROMEOS)
+ if (list_value->GetSize() > 0) {
+ *error = errors::kIllegalPlugins;
+ return false;
+ }
+#endif
+
for (size_t i = 0; i < list_value->GetSize(); ++i) {
DictionaryValue* plugin_value;
std::string path;
diff --git a/chrome/common/extensions/extension_constants.cc b/chrome/common/extensions/extension_constants.cc
index a14b244..7467185 100644
--- a/chrome/common/extensions/extension_constants.cc
+++ b/chrome/common/extensions/extension_constants.cc
@@ -268,6 +268,10 @@ const char* kReservedMessageFound =
"Reserved key * found in message catalog.";
const char* kThemesCannotContainExtensions =
"A theme cannot contain extensions code.";
+#if defined(OS_CHROMEOS)
+const char* kIllegalPlugins =
+ "Extensions cannot install plugins on Chrome OS";
+#endif
} // namespace extension_manifest_errors
namespace extension_urls {
diff --git a/chrome/common/extensions/extension_constants.h b/chrome/common/extensions/extension_constants.h
index 83817b8..b95887f 100644
--- a/chrome/common/extensions/extension_constants.h
+++ b/chrome/common/extensions/extension_constants.h
@@ -173,6 +173,9 @@ namespace extension_manifest_errors {
extern const char* kReservedMessageFound;
extern const char* kThemesCannotContainExtensions;
extern const char* kWebContentMustBeEnabled;
+#if defined(OS_CHROMEOS)
+ extern const char* kIllegalPlugins;
+#endif
} // namespace extension_manifest_errors
namespace extension_urls {
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 0f8e201..aef1797 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -835,7 +835,11 @@ TEST(ExtensionTest, IsPrivilegeIncrease) {
{ "permissions4", false }, // plugin -> plugin,tabs
{ "plugin1", false }, // plugin -> plugin
{ "plugin2", false }, // plugin -> none
+#if defined(OS_CHROMEOS)
+ { "plugin3", false }, // none -> plugin (illegal on Chrome OS)
+#else
{ "plugin3", true }, // none -> plugin
+#endif
{ "storage", false }, // none -> storage
{ "notifications", false } // none -> notifications
};
diff --git a/chrome/test/data/extensions/permissions-high-v2.crx b/chrome/test/data/extensions/permissions-high-v2.crx
index 3dd4959..e328dc7 100644
--- a/chrome/test/data/extensions/permissions-high-v2.crx
+++ b/chrome/test/data/extensions/permissions-high-v2.crx
Binary files differ