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

Unified Diff: chrome/browser/themes/theme_service.cc

Issue 14895016: Make ThemeService use the ExtensionSystem's AsyncEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/ThenRun/Post/ Created 7 years, 7 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
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/themes/theme_service.cc
diff --git a/chrome/browser/themes/theme_service.cc b/chrome/browser/themes/theme_service.cc
index 5b8fa92d442938010d78b2162a86462221943a80..7408bbeb12476c63225d6a08a7bf3336712d8849 100644
--- a/chrome/browser/themes/theme_service.cc
+++ b/chrome/browser/themes/theme_service.cc
@@ -79,7 +79,8 @@ ThemeService::ThemeService()
: rb_(ResourceBundle::GetSharedInstance()),
profile_(NULL),
ready_(false),
- number_of_infobars_(0) {
+ number_of_infobars_(0),
+ weak_ptr_factory_(this) {
}
ThemeService::~ThemeService() {
@@ -92,12 +93,6 @@ void ThemeService::Init(Profile* profile) {
LoadThemePrefs();
- if (!ready_) {
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSIONS_READY,
- content::Source<Profile>(profile_));
- }
-
theme_syncable_service_.reset(new ThemeSyncableService(profile_, this));
}
@@ -205,21 +200,6 @@ base::RefCountedMemory* ThemeService::GetRawData(
return data;
}
-void ThemeService::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(type == chrome::NOTIFICATION_EXTENSIONS_READY);
- registrar_.Remove(this, chrome::NOTIFICATION_EXTENSIONS_READY,
- content::Source<Profile>(profile_));
-
- MigrateTheme();
- set_ready();
-
- // Send notification in case anyone requested data and cached it when the
- // theme service was not ready yet.
- NotifyThemeChanged();
-}
-
void ThemeService::SetTheme(const Extension* extension) {
// Clear our image cache.
FreePlatformCaches();
@@ -328,12 +308,10 @@ void ThemeService::LoadThemePrefs() {
} else {
// TODO(erg): We need to pop up a dialog informing the user that their
// theme is being migrated.
- ExtensionService* service =
- extensions::ExtensionSystem::Get(profile_)->extension_service();
- if (service && service->is_ready()) {
- MigrateTheme();
- set_ready();
- }
+ extensions::ExtensionSystem::Get(profile_)->ready()
+ .Post(FROM_HERE,
+ base::Bind(&ThemeService::FinishLoadingAfterExtensionsReady,
+ weak_ptr_factory_.GetWeakPtr()));
}
}
@@ -361,6 +339,15 @@ void ThemeService::FreePlatformCaches() {
}
#endif
+void ThemeService::FinishLoadingAfterExtensionsReady() {
+ MigrateTheme();
+ set_ready();
+
+ // Send notification in case anyone requested data and cached it when the
+ // theme service was not ready yet.
+ NotifyThemeChanged();
+}
+
void ThemeService::MigrateTheme() {
ExtensionService* service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
« no previous file with comments | « chrome/browser/themes/theme_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698