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

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: 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 99a89cb1a2a4919ca8f2949fc441922c6a873f91..ef83cb34b2073c6a1e90ab5b88bfdf7bd25336d8 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"
@@ -366,13 +369,12 @@ class MockProviderVisitor
class ExtensionTestingProfile : public TestingProfile {
public:
- ExtensionTestingProfile() : service_(NULL) {
+ ExtensionTestingProfile() {
}
- void set_extensions_service(ExtensionService* service) {
- service_ = service;
+ virtual ExtensionService* GetExtensionService() {
+ return ExtensionSystemFactory::GetForProfile(this)->extension_service();
}
- virtual ExtensionService* GetExtensionService() { return service_; }
virtual ChromeAppCacheService* GetAppCacheService() {
if (!appcache_service_) {
@@ -403,7 +405,6 @@ class ExtensionTestingProfile : public TestingProfile {
}
private:
- ExtensionService* service_;
scoped_refptr<ChromeAppCacheService> appcache_service_;
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
};
@@ -451,13 +452,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
@@ -491,7 +492,9 @@ void ExtensionServiceTestBase::InitializeEmptyExtensionService() {
}
void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
- profile_->CreateExtensionProcessManager();
+ static_cast<TestExtensionSystem*>(
+ ExtensionSystemFactory::GetForProfile(profile_.get()))->
+ CreateExtensionProcessManager();
}
void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
@@ -766,7 +769,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));
}
@@ -3847,11 +3850,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();
@@ -3861,9 +3865,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();
@@ -3872,9 +3879,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();
@@ -3884,9 +3894,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