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

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

Issue 9583036: Revert 124817 - 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
===================================================================
--- chrome/browser/extensions/extension_service_unittest.cc (revision 124830)
+++ chrome/browser/extensions/extension_service_unittest.cc (working copy)
@@ -35,8 +35,6 @@
#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"
@@ -46,7 +44,6 @@
#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"
@@ -54,7 +51,6 @@
#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"
@@ -374,6 +370,20 @@
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),
@@ -406,7 +416,7 @@
void ExtensionServiceTestBase::InitializeExtensionService(
const FilePath& pref_file, const FilePath& extensions_install_dir,
bool autoupdate_enabled) {
- TestingProfile* profile = new TestingProfile();
+ ExtensionTestingProfile* profile = new ExtensionTestingProfile();
// Create a PrefService that only contains user defined preference values.
PrefService* prefs =
PrefServiceMockBuilder().WithUserFilePrefs(pref_file).Create();
@@ -418,13 +428,13 @@
profile_.reset(profile);
- service_ = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile))->CreateExtensionService(
- CommandLine::ForCurrentProcess(),
- extensions_install_dir,
- autoupdate_enabled);
+ service_ = 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
@@ -458,9 +468,7 @@
}
void ExtensionServiceTestBase::InitializeExtensionProcessManager() {
- static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile_.get()))->
- CreateExtensionProcessManager();
+ profile_->CreateExtensionProcessManager();
}
void ExtensionServiceTestBase::InitializeExtensionServiceWithUpdater() {
@@ -487,8 +495,8 @@
void ExtensionServiceTestBase::InitializeRequestContext() {
ASSERT_TRUE(profile_.get());
- TestingProfile* profile =
- static_cast<TestingProfile*>(profile_.get());
+ ExtensionTestingProfile* profile =
+ static_cast<ExtensionTestingProfile*>(profile_.get());
profile->CreateRequestContext();
}
@@ -735,7 +743,7 @@
enabled_extension_count);
}
- // Update() should the temporary input file.
+ // Update() should delete the temporary input file.
EXPECT_FALSE(file_util::PathExists(path));
}
@@ -3849,12 +3857,11 @@
// By default, we are enabled.
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- ExtensionService* service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ // Owned by |profile|.
+ ExtensionService* service =
+ profile->CreateExtensionService(command_line.get(),
+ install_dir,
+ false);
EXPECT_TRUE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3864,12 +3871,9 @@
recorder.set_ready(false);
profile.reset(new TestingProfile());
command_line->AppendSwitch(switches::kDisableExtensions);
- service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ service = profile->CreateExtensionService(command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3878,12 +3882,9 @@
recorder.set_ready(false);
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
- service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ service = profile->CreateExtensionService(command_line.get(),
+ install_dir,
+ false);
EXPECT_FALSE(service->extensions_enabled());
service->Init();
loop.RunAllPending();
@@ -3893,12 +3894,9 @@
profile.reset(new TestingProfile());
profile->GetPrefs()->SetBoolean(prefs::kDisableExtensions, true);
command_line.reset(new CommandLine(CommandLine::NO_PROGRAM));
- service = static_cast<TestExtensionSystem*>(
- ExtensionSystemFactory::GetForProfile(profile.get()))->
- CreateExtensionService(
- command_line.get(),
- install_dir,
- false);
+ service = profile->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