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