Index: chrome/test/testing_profile.cc |
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc |
index 6fd04fc0466bbfbc1c2861a7f759689a907b5b2e..359f64d07f4bf4a075b3ad9d54eb46264d5bea5f 100644 |
--- a/chrome/test/testing_profile.cc |
+++ b/chrome/test/testing_profile.cc |
@@ -16,6 +16,7 @@ |
#include "chrome/browser/bookmarks/bookmark_model.h" |
#include "chrome/browser/chrome_thread.h" |
#include "chrome/browser/dom_ui/ntp_resource_cache.h" |
+#include "chrome/browser/extensions/extensions_service.h" |
#include "chrome/browser/favicon_service.h" |
#include "chrome/browser/find_bar_state.h" |
#include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
@@ -166,6 +167,7 @@ class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { |
TestingProfile::TestingProfile() |
: start_time_(Time::Now()), |
+ testing_prefs_(NULL), |
created_theme_provider_(false), |
has_history_service_(false), |
off_the_record_(false), |
@@ -207,6 +209,10 @@ TestingProfile::~TestingProfile() { |
if (top_sites_.get()) |
top_sites_->ClearProfile(); |
history::TopSites::DeleteTopSites(top_sites_); |
+ if (extensions_service_.get()) { |
+ extensions_service_->DestroyingProfile(); |
+ extensions_service_ = NULL; |
+ } |
} |
void TestingProfile::CreateFaviconService() { |
@@ -315,13 +321,26 @@ void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { |
theme_provider_.reset(theme_provider); |
} |
+scoped_refptr<ExtensionsService> TestingProfile::CreateExtensionsService( |
+ const CommandLine* command_line, |
+ const FilePath& install_directory) { |
+ extensions_service_ = new ExtensionsService(this, |
+ command_line, |
+ install_directory, |
+ false); |
+ return extensions_service_; |
+} |
+ |
FilePath TestingProfile::GetPath() { |
DCHECK(temp_dir_.IsValid()); // TODO(phajdan.jr): do it better. |
return temp_dir_.path(); |
} |
TestingPrefService* TestingProfile::GetTestingPrefService() { |
- return static_cast<TestingPrefService*>(GetPrefs()); |
+ if (!prefs_.get()) |
+ CreateTestingPrefService(); |
+ DCHECK(testing_prefs_); |
+ return testing_prefs_; |
} |
webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() { |
@@ -330,6 +349,10 @@ webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() { |
return db_tracker_; |
} |
+ExtensionsService* TestingProfile::GetExtensionsService() { |
+ return extensions_service_.get(); |
+} |
+ |
net::CookieMonster* TestingProfile::GetCookieMonster() { |
if (!GetRequestContext()) |
return NULL; |
@@ -348,11 +371,22 @@ void TestingProfile::InitThemes() { |
} |
} |
+void TestingProfile::SetPrefService(PrefService* prefs) { |
+ DCHECK(!prefs_.get()); |
+ prefs_.reset(prefs); |
+} |
+ |
+void TestingProfile::CreateTestingPrefService() { |
+ DCHECK(!prefs_.get()); |
+ testing_prefs_ = new TestingPrefService(); |
+ prefs_.reset(testing_prefs_); |
+ Profile::RegisterUserPrefs(prefs_.get()); |
+ browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); |
+} |
+ |
PrefService* TestingProfile::GetPrefs() { |
if (!prefs_.get()) { |
- prefs_.reset(new TestingPrefService()); |
- Profile::RegisterUserPrefs(prefs_.get()); |
- browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); |
+ CreateTestingPrefService(); |
} |
return prefs_.get(); |
} |