summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 06:21:08 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-23 06:21:08 +0000
commit36a784c511d467509d9a70a76b0865f60380ec37 (patch)
treeb07995a90e876a6ff10ae2965c25bc190ae75072 /chrome
parentf338a0ed8c0490fad58fa47799c98909e8750978 (diff)
downloadchromium_src-36a784c511d467509d9a70a76b0865f60380ec37.zip
chromium_src-36a784c511d467509d9a70a76b0865f60380ec37.tar.gz
chromium_src-36a784c511d467509d9a70a76b0865f60380ec37.tar.bz2
Re-enable the --enable-extensions flag. Fix a bug where the extensions.enable pref was not being honored. Add tests.
This is intended to be submitted after: http://codereview.chromium.org/132003 BUG=13467 TEST=Added unit tests Review URL: http://codereview.chromium.org/132045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_uitest.cc6
-rw-r--r--chrome/browser/extensions/extensions_service.cc15
-rw-r--r--chrome/browser/extensions/extensions_service.h2
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc32
-rw-r--r--chrome/browser/profile.cc2
5 files changed, 50 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc
index 7d63356..359ba9a 100644
--- a/chrome/browser/extensions/extension_uitest.cc
+++ b/chrome/browser/extensions/extension_uitest.cc
@@ -101,7 +101,7 @@ class SimpleApiCallExtensionTest : public SingleMessageExtensionUITest {
};
// TODO(port) Should become portable once ExternalTabMessageLoop is ported.
-#if 0
+#if defined(OS_WIN)
TEST_F(SimpleApiCallExtensionTest, RunTest) {
namespace keys = extension_automation_constants;
@@ -270,7 +270,7 @@ class RoundtripApiCallExtensionTest
// TODO(port) Should become portable once
// ExternalTabMessageLoop is ported.
-#if 0
+#if defined(OS_WIN)
TEST_F(RoundtripApiCallExtensionTest, RunTest) {
TestWithURL(GURL(
"chrome-extension://ofoknjclcmghjfmbncljcnpjmfmldhno/test.html"));
@@ -435,7 +435,7 @@ class BrowserEventExtensionTest
// TODO(port) Should become portable once
// ExternalTabMessageLoop is ported.
-#if 0
+#if defined(OS_WIN)
TEST_F(BrowserEventExtensionTest, RunTest) {
// The extension for this test does not specify a "key" property in its
// manifest file. Therefore, the extension system will automatically assign
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 7960664..4ef4d08 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -211,6 +211,7 @@ class ExtensionsServiceBackend::UnpackerClient
};
ExtensionsService::ExtensionsService(Profile* profile,
+ const CommandLine* command_line,
MessageLoop* frontend_loop,
MessageLoop* backend_loop)
: extension_prefs_(new ExtensionPrefs(profile->GetPrefs())),
@@ -219,6 +220,12 @@ ExtensionsService::ExtensionsService(Profile* profile,
extensions_enabled_(false),
show_extensions_prompts_(true),
ready_(false) {
+ // Figure out if extension installation should be enabled.
+ if (command_line->HasSwitch(switches::kEnableExtensions))
+ extensions_enabled_ = true;
+ else if (profile->GetPrefs()->GetBoolean(prefs::kEnableExtensions))
+ extensions_enabled_ = true;
+
// We pass ownership of this object to the Backend.
DictionaryValue* extensions = extension_prefs_->CopyCurrentExtensions();
backend_ = new ExtensionsServiceBackend(
@@ -463,7 +470,7 @@ ExtensionsServiceBackend::ExtensionsServiceBackend(
resource_dispatcher_host_(rdh),
alert_on_error_(false),
frontend_loop_(frontend_loop),
- extensions_enabled_(false) {
+ extensions_enabled_(extensions_enabled) {
external_extension_providers_[Extension::EXTERNAL_PREF] =
linked_ptr<ExternalExtensionProvider>(
new ExternalPrefExtensionProvider(extension_prefs));
@@ -972,11 +979,15 @@ void ExtensionsServiceBackend::OnExtensionUnpacked(
!extension.IsTheme() &&
location != Extension::EXTERNAL_REGISTRY) {
ReportExtensionInstallError(extension_path,
- "Extensions are not enabled (yet!)");
+ "Extensions are not enabled. Add --enable-extensions to the "
+ "command-line to enable extensions.\n\n"
+ "This is a temporary message and it will be removed when extensions "
+ "UI is finalized.");
return;
}
#if defined(OS_WIN)
+ // We don't show the install dialog for themes or external extensions.
if (!extension.IsTheme() &&
!Extension::IsExternalLocation(location) &&
frontend_->show_extensions_prompts() &&
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 87c387f..f4be29b 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -10,6 +10,7 @@
#include <string>
#include <vector>
+#include "base/command_line.h"
#include "base/file_path.h"
#include "base/linked_ptr.h"
#include "base/ref_counted.h"
@@ -72,6 +73,7 @@ class ExtensionsService
};
ExtensionsService(Profile* profile,
+ const CommandLine* command_line,
MessageLoop* frontend_loop,
MessageLoop* backend_loop);
~ExtensionsService();
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index e41a84a..06d343c 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -5,6 +5,7 @@
#include <algorithm>
#include <vector>
+#include "base/command_line.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/json_reader.h"
@@ -24,6 +25,7 @@
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
+#include "chrome/common/pref_names.h"
#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -130,7 +132,8 @@ class ExtensionsServiceTest
NotificationService::AllSources());
profile_.reset(new TestingProfile());
- service_ = new ExtensionsService(profile_.get(), &loop_, &loop_);
+ service_ = new ExtensionsService(
+ profile_.get(), CommandLine::ForCurrentProcess(), &loop_, &loop_);
service_->SetExtensionsEnabled(true);
service_->set_show_extensions_prompts(false);
@@ -1023,3 +1026,30 @@ TEST_F(ExtensionsServiceTest, ExternalInstallPref) {
ASSERT_EQ(0u, loaded_.size());
ASSERT_EQ(1u, GetErrors().size());
}
+
+// Test that we get enabled/disabled correctly for all the pref/command-line
+// combinations.
+TEST(ExtensionsServiceTest2, Enabledness) {
+ TestingProfile profile;
+ MessageLoop loop;
+ scoped_ptr<CommandLine> command_line;
+ scoped_refptr<ExtensionsService> service;
+
+ // By default, we are disabled.
+ command_line.reset(new CommandLine(L""));
+ service = new ExtensionsService(&profile, command_line.get(), &loop, &loop);
+ EXPECT_FALSE(service->extensions_enabled());
+
+ // If either the command line or pref is set, we are enabled.
+ command_line->AppendSwitch(switches::kEnableExtensions);
+ service = new ExtensionsService(&profile, command_line.get(), &loop, &loop);
+ EXPECT_TRUE(service->extensions_enabled());
+
+ profile.GetPrefs()->SetBoolean(prefs::kEnableExtensions, true);
+ service = new ExtensionsService(&profile, command_line.get(), &loop, &loop);
+ EXPECT_TRUE(service->extensions_enabled());
+
+ command_line.reset(new CommandLine(L""));
+ service = new ExtensionsService(&profile, command_line.get(), &loop, &loop);
+ EXPECT_TRUE(service->extensions_enabled());
+}
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 179f506..67e9810 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -478,7 +478,7 @@ void ProfileImpl::InitExtensions() {
g_browser_process->file_thread()->message_loop(),
script_dir);
extensions_service_ = new ExtensionsService(
- this, MessageLoop::current(),
+ this, CommandLine::ForCurrentProcess(), MessageLoop::current(),
g_browser_process->file_thread()->message_loop());
extensions_service_->Init();