diff options
author | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-09 01:07:42 +0000 |
---|---|---|
committer | glen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-09 01:07:42 +0000 |
commit | 4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f (patch) | |
tree | 69a1e9f78b3a5fa8b909cfab336826b09c44235f /chrome/browser/profile.cc | |
parent | 5085ee0b4bfbe4625e63ee6975bb95702e13e0aa (diff) | |
download | chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.zip chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.gz chromium_src-4a19063d1459a4c9c8c4c50ed86eb9048f69ea3f.tar.bz2 |
This is the first pass at themes.
This CL is paired with http://codereview.chromium.org/67284
This CL (for commit purposes) includes http://codereview.chromium.org/67284
BUG=4463,11232,11233,11234,11235
Review URL: http://codereview.chromium.org/99030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/profile.cc')
-rw-r--r-- | chrome/browser/profile.cc | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc index 86f32b6..9406216 100644 --- a/chrome/browser/profile.cc +++ b/chrome/browser/profile.cc @@ -28,6 +28,7 @@ #include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/spellchecker.h" #include "chrome/browser/ssl/ssl_host_state.h" +#include "chrome/browser/browser_theme_provider.h" #include "chrome/browser/visitedlink_master.h" #include "chrome/browser/webdata/web_data_service.h" #include "chrome/common/chrome_constants.h" @@ -38,7 +39,6 @@ #include "chrome/common/render_messages.h" #include "grit/locale_settings.h" - using base::Time; using base::TimeDelta; @@ -59,6 +59,10 @@ void Profile::RegisterUserPrefs(PrefService* prefs) { IDS_SPELLCHECK_DICTIONARY); prefs->RegisterBooleanPref(prefs::kEnableSpellCheck, true); prefs->RegisterBooleanPref(prefs::kEnableUserScripts, false); + prefs->RegisterStringPref(prefs::kCurrentThemeID, L""); + prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages); + prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors); + prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints); prefs->RegisterBooleanPref(prefs::kEnableExtensions, false); } @@ -76,7 +80,7 @@ URLRequestContext* Profile::GetDefaultRequestContext() { //////////////////////////////////////////////////////////////////////////////// // // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile -// to make it suitable for the off the record mode. +// to make it suitable for the off the record mode. // //////////////////////////////////////////////////////////////////////////////// class OffTheRecordProfileImpl : public Profile, @@ -204,6 +208,22 @@ class OffTheRecordProfileImpl : public Profile, return (download_manager_.get() != NULL); } + virtual void InitThemes() { + GetOriginalProfile()->InitThemes(); + } + + virtual void SetTheme(Extension* extension) { + GetOriginalProfile()->SetTheme(extension); + } + + virtual void ClearTheme() { + GetOriginalProfile()->ClearTheme(); + } + + virtual ThemeProvider* GetThemeProvider() { + return GetOriginalProfile()->GetThemeProvider(); + } + virtual URLRequestContext* GetRequestContext() { return request_context_; } @@ -341,6 +361,9 @@ class OffTheRecordProfileImpl : public Profile, // The download manager that only stores downloaded items in memory. scoped_refptr<DownloadManager> download_manager_; + // The download manager that only stores downloaded items in memory. + scoped_refptr<BrowserThemeProvider> theme_provider_; + // We don't want SSLHostState from the OTR profile to leak back to the main // profile because then the main profile would learn some of the host names // the user visited while OTR. @@ -362,6 +385,7 @@ ProfileImpl::ProfileImpl(const FilePath& path) history_service_created_(false), created_web_data_service_(false), created_download_manager_(false), + created_theme_provider_(false), start_time_(Time::Now()), spellchecker_(NULL), shutdown_session_service_(false) { @@ -387,6 +411,10 @@ ProfileImpl::ProfileImpl(const FilePath& path) prefs->transient()->SetString(prefs::kHomePage, "about:linux-splash"); prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); #endif + + // Listen for theme installation. + NotificationService::current()->AddObserver(this, + NotificationType::THEME_INSTALLED, NotificationService::AllSources()); } void ProfileImpl::InitExtensions() { @@ -440,6 +468,9 @@ ProfileImpl::~ProfileImpl() { // before the history is shutdown so it can properly cancel all requests. download_manager_ = NULL; + // The theme provider provides bitmaps to whoever wants them. + theme_provider_ = NULL; + // Remove pref observers. PrefService* prefs = GetPrefs(); prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this); @@ -449,6 +480,10 @@ ProfileImpl::~ProfileImpl() { personalization_.reset(); #endif + // Remove theme observer. + NotificationService::current()->RemoveObserver(this, + NotificationType::THEME_INSTALLED, NotificationService::AllSources()); + // Both HistoryService and WebDataService maintain threads for background // processing. Its possible each thread still has tasks on it that have // increased the ref count of the service. In such a situation, when we @@ -731,6 +766,30 @@ bool ProfileImpl::HasCreatedDownloadManager() const { return created_download_manager_; } +void ProfileImpl::InitThemes() { + if (!created_theme_provider_) { + scoped_refptr<BrowserThemeProvider> themes(new BrowserThemeProvider); + themes->Init(this); + created_theme_provider_ = true; + theme_provider_.swap(themes); + } +} + +void ProfileImpl::SetTheme(Extension* extension) { + InitThemes(); + theme_provider_.get()->SetTheme(extension); +} + +void ProfileImpl::ClearTheme() { + InitThemes(); + theme_provider_.get()->UseDefaultTheme(); +} + +ThemeProvider* ProfileImpl::GetThemeProvider() { + InitThemes(); + return theme_provider_.get(); +} + SessionService* ProfileImpl::GetSessionService() { if (!session_service_.get() && !shutdown_session_service_) { session_service_ = new SessionService(this); @@ -911,6 +970,9 @@ void ProfileImpl::Observe(NotificationType type, *pref_name_in == prefs::kEnableSpellCheck) { InitializeSpellChecker(true); } + } else if (NotificationType::THEME_INSTALLED == type) { + Extension* extension = Details<Extension>(details).ptr(); + SetTheme(extension); } } |