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

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

Issue 650763003: Delay default apps installation on Chrome OS for first time sign-in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use ScopedObserver Created 6 years, 2 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 9a32ac34426b0a623573cd45e60c32fe043eccbf..57b06c927c734e41db27c9112fe63f8cc97787a0 100644
--- a/chrome/browser/extensions/external_pref_loader.cc
+++ b/chrome/browser/extensions/external_pref_loader.cc
@@ -15,6 +15,7 @@
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/browser_thread.h"
@@ -90,11 +91,19 @@ base::DictionaryValue* ExtractExtensionPrefs(base::ValueSerializer* serializer,
namespace extensions {
-ExternalPrefLoader::ExternalPrefLoader(int base_path_id, Options options)
- : base_path_id_(base_path_id), options_(options) {
+ExternalPrefLoader::ExternalPrefLoader(int base_path_id,
+ Options options,
+ Profile* profile)
+ : base_path_id_(base_path_id),
+ options_(options),
+ profile_(profile),
+ syncable_pref_observer_(this) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
}
+ExternalPrefLoader::~ExternalPrefLoader() {
+}
+
const base::FilePath ExternalPrefLoader::GetBaseCrxFilePath() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -104,9 +113,39 @@ const base::FilePath ExternalPrefLoader::GetBaseCrxFilePath() {
void ExternalPrefLoader::StartLoading() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- base::Bind(&ExternalPrefLoader::LoadOnFileThread, this));
+ if (options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC) {
+ if (!PostLoadIfPrioritySyncReady()) {
+ DCHECK(profile_);
+ PrefServiceSyncable* prefs = PrefServiceSyncable::FromProfile(profile_);
+ DCHECK(prefs);
+ syncable_pref_observer_.Add(prefs);
+ }
+ } else {
+ BrowserThread::PostTask(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(&ExternalPrefLoader::LoadOnFileThread, this));
+ }
+}
+
+void ExternalPrefLoader::OnIsSyncingChanged() {
+ PostLoadIfPrioritySyncReady();
+}
+
+bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() {
+ DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC);
+ DCHECK(profile_);
+
+ 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);
+ return true;
+ }
+
+ return false;
}
void ExternalPrefLoader::LoadOnFileThread() {
« 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