Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1672)

Unified Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 9369013: Take extensions out of Profile into a profile-keyed service, ExtensionSystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no crashy Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service_unittest.cc
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 37187c24282655020d445e2716f8a33e76c83b15..1a4f66e22a637ea88d35ce26df24c63fc66fbcee 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -33,6 +33,8 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/extensions/extension_sync_data.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/extension_updater.h"
#include "chrome/browser/extensions/external_extension_provider_impl.h"
#include "chrome/browser/extensions/external_extension_provider_interface.h"
@@ -42,6 +44,7 @@
#include "chrome/browser/extensions/pack_extension_job.cc"
#include "chrome/browser/extensions/pending_extension_info.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
+#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/plugin_prefs_factory.h"
#include "chrome/browser/prefs/browser_prefs.h"
@@ -49,6 +52,7 @@
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/browser/sync/protocol/app_specifics.pb.h"
#include "chrome/browser/sync/protocol/extension_specifics.pb.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -365,20 +369,6 @@ class MockProviderVisitor
DISALLOW_COPY_AND_ASSIGN(MockProviderVisitor);
};
-class ExtensionTestingProfile : public TestingProfile {
- public:
- ExtensionTestingProfile() : service_(NULL) {
- }
-
- void set_extensions_service(ExtensionService* service) {
- service_ = service;
- }
- virtual ExtensionService* GetExtensionService() { return service_; }
-
- private:
- ExtensionService* service_;
-};
-
// Our message loop may be used in tests which require it to be an IO loop.
ExtensionServiceTestBase::ExtensionServiceTestBase()
: loop_(MessageLoop::TYPE_IO),
@@ -411,7 +401,7 @@ ExtensionServiceTestBase::~ExtensionServiceTestBase() {
void ExtensionServiceTestBase::InitializeExtensionService(
const FilePath& pref_file, const FilePath& extensions_install_dir,
bool autoupdate_enabled) {
- ExtensionTestingProfile* profile = new ExtensionTestingProfile();
+ TestingProfile* profile = new TestingProfile();
// Create a PrefService that only contains user defined preference values.
PrefService* prefs =
PrefServiceMockBuilder().WithUserFilePrefs(pref_file).Create();
@@ -423,13 +413,13 @@ void ExtensionServiceTestBase::InitializeExtensionService(
profile_.reset(profile);
- service_ = profile->CreateExtensionService(
- CommandLine::ForCurrentProcess(),
- extensions_install_dir,
- autoupdate_enabled);
+ service_ = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile))->CreateExtensionService(
+ CommandLine::ForCurrentProcess(),
+ extensions_install_dir,
+ autoupdate_enabled);
service_->set_extensions_enabled(true);
service_->set_show_extensions_prompts(false);
- profile->set_extensions_service(service_);
// When we start up, we want to make sure there is no external provider,
// since the ExtensionService on Windows will use the Registry as a default
@@ -463,7 +453,9 @@ void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
}
void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
- profile_->CreateExtensionProcessManager();
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile_.get()))->
+ CreateExtensionProcessManager();
}
void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
@@ -490,8 +482,8 @@ void ExtensionServiceTestBase::InitializeExtensionServiceHelper(
void ExtensionServiceTestBase::InitializeRequestContext() {
ASSERT_TRUE(profile_.get());
- ExtensionTestingProfile* profile =
- static_cast<ExtensionTestingProfile*>(profile_.get());
+ TestingProfile* profile =
+ static_cast<TestingProfile*>(profile_.get());
profile->CreateRequestContext();
}
@@ -738,7 +730,7 @@ class ExtensionServiceTest
enabled_extension_count);
}
- // Update() should delete the temporary input file.
+ // Update() should the temporary input file.
EXPECT_FALSE(file_util::PathExists(path));
}
@@ -3820,11 +3812,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
// By default, we are enabled.
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- // Owned by |profile|.
- ExtensionService* service =
- profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ ExtensionService* service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_TRUE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3834,9 +3827,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
recorder.set_ready(false);
profile.reset(new TestingProfile());
command_line->AppendSwitch(switches::kDisableExtensions);
- service = profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3845,9 +3841,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
recorder.set_ready(false);
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
- service = profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3857,9 +3856,12 @@ TEST(ExtensionServiceTestSimple, Enabledness) {
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- service = profile->CreateExtensionService(command_line.get(),
- install_dir,
- false);
+ service = static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile.get()))->
+ CreateExtensionService(
+ command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();

Powered by Google App Engine
This is Rietveld 408576698