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

Side by Side Diff: chrome/browser/extensions/external_pref_loader.cc

Issue 2459823002: [Sync] Rename syncable_prefs to sync_preferences. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/external_pref_loader.h" 5 #include "chrome/browser/extensions/external_pref_loader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/json/json_file_value_serializer.h" 13 #include "base/json/json_file_value_serializer.h"
14 #include "base/json/json_string_value_serializer.h" 14 #include "base/json/json_string_value_serializer.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
17 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "chrome/browser/defaults.h" 22 #include "chrome/browser/defaults.h"
23 #include "chrome/browser/prefs/pref_service_syncable_util.h" 23 #include "chrome/browser/prefs/pref_service_syncable_util.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/sync/profile_sync_service_factory.h" 25 #include "chrome/browser/sync/profile_sync_service_factory.h"
26 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
27 #include "components/syncable_prefs/pref_service_syncable.h" 27 #include "components/sync_preferences/pref_service_syncable.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 29
30 using content::BrowserThread; 30 using content::BrowserThread;
31 31
32 namespace { 32 namespace {
33 33
34 base::FilePath::CharType kExternalExtensionJson[] = 34 base::FilePath::CharType kExternalExtensionJson[] =
35 FILE_PATH_LITERAL("external_extensions.json"); 35 FILE_PATH_LITERAL("external_extensions.json");
36 36
37 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder( 37 std::set<base::FilePath> GetPrefsCandidateFilesFromFolder(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // |base_path_| was set in LoadOnFileThread(). 122 // |base_path_| was set in LoadOnFileThread().
123 return base_path_; 123 return base_path_;
124 } 124 }
125 125
126 void ExternalPrefLoader::StartLoading() { 126 void ExternalPrefLoader::StartLoading() {
127 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 127 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
128 if ((options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC) && 128 if ((options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC) &&
129 (profile_ && profile_->IsSyncAllowed())) { 129 (profile_ && profile_->IsSyncAllowed())) {
130 if (!PostLoadIfPrioritySyncReady()) { 130 if (!PostLoadIfPrioritySyncReady()) {
131 DCHECK(profile_); 131 DCHECK(profile_);
132 syncable_prefs::PrefServiceSyncable* prefs = 132 sync_preferences::PrefServiceSyncable* prefs =
133 PrefServiceSyncableFromProfile(profile_); 133 PrefServiceSyncableFromProfile(profile_);
134 DCHECK(prefs); 134 DCHECK(prefs);
135 syncable_pref_observer_.Add(prefs); 135 syncable_pref_observer_.Add(prefs);
136 browser_sync::ProfileSyncService* service = 136 browser_sync::ProfileSyncService* service =
137 ProfileSyncServiceFactory::GetForProfile(profile_); 137 ProfileSyncServiceFactory::GetForProfile(profile_);
138 DCHECK(service); 138 DCHECK(service);
139 if (service->CanSyncStart() && (service->IsFirstSetupComplete() || 139 if (service->CanSyncStart() && (service->IsFirstSetupComplete() ||
140 browser_defaults::kSyncAutoStarts)) { 140 browser_defaults::kSyncAutoStarts)) {
141 service->AddObserver(this); 141 service->AddObserver(this);
142 } else { 142 } else {
(...skipping 17 matching lines...) Expand all
160 DCHECK(service); 160 DCHECK(service);
161 if (!service->CanSyncStart()) { 161 if (!service->CanSyncStart()) {
162 PostLoadAndRemoveObservers(); 162 PostLoadAndRemoveObservers();
163 } 163 }
164 } 164 }
165 165
166 bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() { 166 bool ExternalPrefLoader::PostLoadIfPrioritySyncReady() {
167 DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC); 167 DCHECK(options_ & DELAY_LOAD_UNTIL_PRIORITY_SYNC);
168 DCHECK(profile_); 168 DCHECK(profile_);
169 169
170 syncable_prefs::PrefServiceSyncable* prefs = 170 sync_preferences::PrefServiceSyncable* prefs =
171 PrefServiceSyncableFromProfile(profile_); 171 PrefServiceSyncableFromProfile(profile_);
172 DCHECK(prefs); 172 DCHECK(prefs);
173 if (prefs->IsPrioritySyncing()) { 173 if (prefs->IsPrioritySyncing()) {
174 PostLoadAndRemoveObservers(); 174 PostLoadAndRemoveObservers();
175 return true; 175 return true;
176 } 176 }
177 177
178 return false; 178 return false;
179 } 179 }
180 180
181 void ExternalPrefLoader::PostLoadAndRemoveObservers() { 181 void ExternalPrefLoader::PostLoadAndRemoveObservers() {
182 syncable_prefs::PrefServiceSyncable* prefs = 182 sync_preferences::PrefServiceSyncable* prefs =
183 PrefServiceSyncableFromProfile(profile_); 183 PrefServiceSyncableFromProfile(profile_);
184 DCHECK(prefs); 184 DCHECK(prefs);
185 syncable_pref_observer_.Remove(prefs); 185 syncable_pref_observer_.Remove(prefs);
186 186
187 browser_sync::ProfileSyncService* service = 187 browser_sync::ProfileSyncService* service =
188 ProfileSyncServiceFactory::GetForProfile(profile_); 188 ProfileSyncServiceFactory::GetForProfile(profile_);
189 DCHECK(service); 189 DCHECK(service);
190 service->RemoveObserver(this); 190 service->RemoveObserver(this);
191 191
192 BrowserThread::PostTask( 192 BrowserThread::PostTask(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 LoadFinished(); 330 LoadFinished();
331 } 331 }
332 332
333 ExternalTestingLoader::~ExternalTestingLoader() {} 333 ExternalTestingLoader::~ExternalTestingLoader() {}
334 334
335 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { 335 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() {
336 return fake_base_path_; 336 return fake_base_path_;
337 } 337 }
338 338
339 } // namespace extensions 339 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698