summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-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
4 files changed, 47 insertions, 4 deletions
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();