Chromium Code Reviews| Index: chrome/browser/extensions/external_pref_loader.cc |
| diff --git a/chrome/browser/extensions/external_pref_loader.cc b/chrome/browser/extensions/external_pref_loader.cc |
| index 61be1597a954c58f24198a971bfc220a8f3c3cf8..4c1ce8dac429a02ce448170aa1b1f0f2c470374b 100644 |
| --- a/chrome/browser/extensions/external_pref_loader.cc |
| +++ b/chrome/browser/extensions/external_pref_loader.cc |
| @@ -16,6 +16,7 @@ |
| #include "base/strings/string_util.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "chrome/browser/prefs/pref_service_syncable.h" |
| +#include "chrome/browser/sync/profile_sync_service_factory.h" |
| #include "chrome/common/chrome_paths.h" |
| #include "content/public/browser/browser_thread.h" |
| @@ -119,6 +120,12 @@ void ExternalPrefLoader::StartLoading() { |
| PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| DCHECK(prefs); |
| syncable_pref_observer_.Add(prefs); |
| + ProfileSyncService* service = |
| + ProfileSyncServiceFactory::GetForProfile(profile_); |
| + if (service) |
|
Nicolas Zea
2015/02/26 21:46:47
I don't think this will catch the case where sync
|
| + service->AddObserver(this); |
| + else |
| + PostLoadAndRemoveObservers(); |
| } |
| } else { |
| BrowserThread::PostTask( |
| @@ -131,6 +138,19 @@ void ExternalPrefLoader::OnIsSyncingChanged() { |
| PostLoadIfPrioritySyncReady(); |
| } |
| +void ExternalPrefLoader::OnStateChanged() { |
| + ProfileSyncService* service = |
| + ProfileSyncServiceFactory::GetForProfile(profile_); |
| + DCHECK(service); |
| + |
| + ProfileSyncService::SyncStatusSummary status = |
| + service->QuerySyncStatusSummary(); |
| + if (status == ProfileSyncService::SyncStatusSummary::NOT_ENABLED || |
|
Nicolas Zea
2015/02/25 18:26:14
Do you have logic elsewhere to do the load when sy
Ivan Podogov
2015/02/26 12:50:15
The main idea is: if sync is enabled (and we don't
Nicolas Zea
2015/02/26 21:46:47
I'm a bit confused by this; I think we might be th
Ivan Podogov
2015/02/26 21:59:06
Um... These comments are for the old patchset, tak
|
| + status == ProfileSyncService::SyncStatusSummary::UNRECOVERABLE_ERROR) { |
| + PostLoadAndRemoveObservers(); |
| + } |
| +} |
| + |
| bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() { |
| DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC); |
| DCHECK(profile_); |
| @@ -138,16 +158,28 @@ bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() { |
| PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| DCHECK(prefs); |
| if (prefs->IsPrioritySyncing()) { |
| - BrowserThread::PostTask( |
| - BrowserThread::FILE, FROM_HERE, |
| - base::Bind(&ExternalPrefLoader::LoadOnFileThread, this)); |
| - syncable_pref_observer_.Remove(prefs); |
| + PostLoadAndRemoveObservers(); |
| return true; |
| } |
| return false; |
| } |
| +void ExternalPrefLoader::PostLoadAndRemoveObservers() { |
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&ExternalPrefLoader::LoadOnFileThread, this)); |
| + |
| + PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_); |
| + DCHECK(prefs); |
| + syncable_pref_observer_.Remove(prefs); |
| + |
| + ProfileSyncService* service = |
| + ProfileSyncServiceFactory::GetForProfile(profile_); |
| + if (service) |
| + service->RemoveObserver(this); |
| +} |
| + |
| void ExternalPrefLoader::LoadOnFileThread() { |
| CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |