summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authordanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-22 12:43:14 +0000
committerdanno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-22 12:43:14 +0000
commit37d5293518a8657af4d79035f7ef2e8c3a8d6b9a (patch)
tree9897f36b9f09457d3a5fbb002abc4e081e79ae56 /chrome/test
parent37c3dacaa38fddba1c53d9b3f3f0514933d3dd45 (diff)
downloadchromium_src-37d5293518a8657af4d79035f7ef2e8c3a8d6b9a.zip
chromium_src-37d5293518a8657af4d79035f7ef2e8c3a8d6b9a.tar.gz
chromium_src-37d5293518a8657af4d79035f7ef2e8c3a8d6b9a.tar.bz2
Use PrefChangeRegistrar everywhere
BUG=54955 TEST=PrefChangeRegistrarTest.* Review URL: http://codereview.chromium.org/3304015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60169 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/testing_profile.cc18
-rw-r--r--chrome/test/testing_profile.h15
2 files changed, 32 insertions, 1 deletions
diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc
index 6fd04fc..d9acdd7 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"
@@ -207,6 +208,8 @@ TestingProfile::~TestingProfile() {
if (top_sites_.get())
top_sites_->ClearProfile();
history::TopSites::DeleteTopSites(top_sites_);
+ if (extensions_service_.get())
+ extensions_service_->DestroyingProfile();
}
void TestingProfile::CreateFaviconService() {
@@ -315,6 +318,17 @@ 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,
+ GetPrefs(),
+ install_directory,
+ false);
+ return extensions_service_;
+}
+
FilePath TestingProfile::GetPath() {
DCHECK(temp_dir_.IsValid()); // TODO(phajdan.jr): do it better.
return temp_dir_.path();
@@ -330,6 +344,10 @@ webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() {
return db_tracker_;
}
+ExtensionsService* TestingProfile::GetExtensionsService() {
+ return extensions_service_.get();
+}
+
net::CookieMonster* TestingProfile::GetCookieMonster() {
if (!GetRequestContext())
return NULL;
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index d75b7c1..819fa03 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -23,6 +23,7 @@ class CookieMonster;
class AutocompleteClassifier;
class BookmarkModel;
class BrowserThemeProvider;
+class CommandLine;
class DesktopNotificationService;
class FaviconService;
class FindBarState;
@@ -86,6 +87,14 @@ class TestingProfile : public Profile {
// ownership of |theme_provider|.
void UseThemeProvider(BrowserThemeProvider* theme_provider);
+ // Creates an ExtensionsService initialized with the testing profile and
+ // returns it. The profile keeps its own copy of a scoped_refptr to the
+ // ExtensionsService to make sure that is still alive to be notified when the
+ // profile is destroyed.
+ scoped_refptr<ExtensionsService> CreateExtensionsService(
+ const CommandLine* command_line,
+ const FilePath& install_directory);
+
TestingPrefService* GetTestingPrefService();
virtual ProfileId GetRuntimeId() {
@@ -109,7 +118,7 @@ class TestingProfile : public Profile {
virtual ChromeAppCacheService* GetAppCacheService() { return NULL; }
virtual webkit_database::DatabaseTracker* GetDatabaseTracker();
virtual VisitedLinkMaster* GetVisitedLinkMaster() { return NULL; }
- virtual ExtensionsService* GetExtensionsService() { return NULL; }
+ virtual ExtensionsService* GetExtensionsService();
virtual UserScriptMaster* GetUserScriptMaster() { return NULL; }
virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() {
return NULL;
@@ -346,6 +355,10 @@ class TestingProfile : public Profile {
FilePath last_selected_directory_;
scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails.
+ // For properly notifying the ExtensionsService when the profile
+ // is disposed.
+ scoped_refptr<ExtensionsService> extensions_service_;
+
// We use a temporary directory to store testing profile data.
ScopedTempDir temp_dir_;
};