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

Unified Diff: chrome/browser/extensions/external_pref_loader.cc

Issue 957753002: Install default apps if sync is disabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
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..47ce5dad8c1f32512ef178dd7d2f42c5975a792d 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,10 @@ void ExternalPrefLoader::StartLoading() {
PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_);
DCHECK(prefs);
syncable_pref_observer_.Add(prefs);
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetForProfile(profile_);
+ DCHECK(service);
+ service->AddObserver(this);
}
} else {
BrowserThread::PostTask(
@@ -131,6 +136,17 @@ void ExternalPrefLoader::OnIsSyncingChanged() {
PostLoadIfPrioritySyncReady();
}
+void ExternalPrefLoader::OnStateChanged() {
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetForProfile(profile_);
+ DCHECK(service);
+
+ if (service->QuerySyncStatusSummary() ==
+ ProfileSyncService::SyncStatusSummary::NOT_ENABLED) {
Dmitry Polukhin 2015/02/25 13:39:11 I would also do the same in case of unrecoverable
Ivan Podogov 2015/02/25 13:45:58 Done.
+ PostLoadAndRemoveObservers();
+ }
+}
+
bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() {
DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC);
DCHECK(profile_);
@@ -138,16 +154,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_);
+ DCHECK(service);
+ service->RemoveObserver(this);
+}
+
void ExternalPrefLoader::LoadOnFileThread() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
« no previous file with comments | « chrome/browser/extensions/external_pref_loader.h ('k') | chrome/browser/extensions/external_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698