| 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();
|
|
|