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

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: rerebase 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 0880121a1644e663dda4bd4390f424032e6529f5..e10c89c3e70f49c5c80862460f19357ce8d4df27 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -35,6 +35,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"
@@ -44,6 +46,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"
@@ -51,6 +54,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"
@@ -370,20 +374,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),
@@ -416,7 +406,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();
@@ -428,13 +418,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
@@ -468,7 +458,9 @@ void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
}
void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
- profile_->CreateExtensionProcessManager();
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile_.get()))->
+ CreateExtensionProcessManager();
}
void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
@@ -495,8 +487,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();
}
@@ -743,7 +735,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));
}
@@ -3857,11 +3849,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();
@@ -3871,9 +3864,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();
@@ -3882,9 +3878,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();
@@ -3894,9 +3893,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();
« no previous file with comments | « chrome/browser/extensions/extension_service_unittest.h ('k') | chrome/browser/extensions/extension_system.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698