OLD | NEW |
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/prefs/chrome_pref_service_factory.h" | 5 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 make_scoped_refptr( | 326 make_scoped_refptr( |
327 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); | 327 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); |
328 factory->set_read_error_callback(base::Bind(&HandleReadError)); | 328 factory->set_read_error_callback(base::Bind(&HandleReadError)); |
329 factory->set_user_prefs(user_pref_store); | 329 factory->set_user_prefs(user_pref_store); |
330 } | 330 } |
331 | 331 |
332 // Initialize/update preference hash stores for all profiles but the one whose | 332 // Initialize/update preference hash stores for all profiles but the one whose |
333 // path matches |ignored_profile_path|. | 333 // path matches |ignored_profile_path|. |
334 void UpdateAllPrefHashStoresIfRequired( | 334 void UpdateAllPrefHashStoresIfRequired( |
335 const base::FilePath& ignored_profile_path) { | 335 const base::FilePath& ignored_profile_path) { |
336 if (GetSettingsEnforcementGroup() >= GROUP_ENFORCE_ALWAYS) | |
337 return; | |
338 const ProfileInfoCache& profile_info_cache = | 336 const ProfileInfoCache& profile_info_cache = |
339 g_browser_process->profile_manager()->GetProfileInfoCache(); | 337 g_browser_process->profile_manager()->GetProfileInfoCache(); |
340 const size_t n_profiles = profile_info_cache.GetNumberOfProfiles(); | 338 const size_t n_profiles = profile_info_cache.GetNumberOfProfiles(); |
341 for (size_t i = 0; i < n_profiles; ++i) { | 339 for (size_t i = 0; i < n_profiles; ++i) { |
342 const base::FilePath profile_path = | 340 const base::FilePath profile_path = |
343 profile_info_cache.GetPathOfProfileAtIndex(i); | 341 profile_info_cache.GetPathOfProfileAtIndex(i); |
344 if (profile_path != ignored_profile_path) { | 342 if (profile_path != ignored_profile_path) { |
345 CreateProfilePrefStoreManager(profile_path) | 343 CreateProfilePrefStoreManager(profile_path) |
346 ->UpdateProfileHashStoreIfRequired( | 344 ->UpdateProfileHashStoreIfRequired( |
347 JsonPrefStore::GetTaskRunnerForFile( | 345 JsonPrefStore::GetTaskRunnerForFile( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 420 } |
423 | 421 |
424 void SchedulePrefHashStoresUpdateCheck( | 422 void SchedulePrefHashStoresUpdateCheck( |
425 const base::FilePath& initial_profile_path) { | 423 const base::FilePath& initial_profile_path) { |
426 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) { | 424 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) { |
427 ProfilePrefStoreManager::ResetAllPrefHashStores( | 425 ProfilePrefStoreManager::ResetAllPrefHashStores( |
428 g_browser_process->local_state()); | 426 g_browser_process->local_state()); |
429 return; | 427 return; |
430 } | 428 } |
431 | 429 |
| 430 if (GetSettingsEnforcementGroup() >= GROUP_ENFORCE_ALWAYS) |
| 431 return; |
| 432 |
432 const int kDefaultPrefHashStoresUpdateCheckDelaySeconds = 55; | 433 const int kDefaultPrefHashStoresUpdateCheckDelaySeconds = 55; |
433 BrowserThread::PostDelayedTask( | 434 BrowserThread::PostDelayedTask( |
434 BrowserThread::UI, | 435 BrowserThread::UI, |
435 FROM_HERE, | 436 FROM_HERE, |
436 base::Bind(&UpdateAllPrefHashStoresIfRequired, | 437 base::Bind(&UpdateAllPrefHashStoresIfRequired, |
437 initial_profile_path), | 438 initial_profile_path), |
438 base::TimeDelta::FromSeconds( | 439 base::TimeDelta::FromSeconds( |
439 g_disable_delays_and_domain_check_for_testing ? | 440 g_disable_delays_and_domain_check_for_testing ? |
440 0 : kDefaultPrefHashStoresUpdateCheckDelaySeconds)); | 441 0 : kDefaultPrefHashStoresUpdateCheckDelaySeconds)); |
441 } | 442 } |
(...skipping 19 matching lines...) Expand all Loading... |
461 | 462 |
462 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 463 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
463 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 464 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
464 } | 465 } |
465 | 466 |
466 void RegisterPrefs(PrefRegistrySimple* registry) { | 467 void RegisterPrefs(PrefRegistrySimple* registry) { |
467 ProfilePrefStoreManager::RegisterPrefs(registry); | 468 ProfilePrefStoreManager::RegisterPrefs(registry); |
468 } | 469 } |
469 | 470 |
470 } // namespace chrome_prefs | 471 } // namespace chrome_prefs |
OLD | NEW |