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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 make_scoped_refptr( | 350 make_scoped_refptr( |
351 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); | 351 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); |
352 factory->set_read_error_callback(base::Bind(&HandleReadError)); | 352 factory->set_read_error_callback(base::Bind(&HandleReadError)); |
353 factory->set_user_prefs(user_pref_store); | 353 factory->set_user_prefs(user_pref_store); |
354 } | 354 } |
355 | 355 |
356 // Initialize/update preference hash stores for all profiles but the one whose | 356 // Initialize/update preference hash stores for all profiles but the one whose |
357 // path matches |ignored_profile_path|. | 357 // path matches |ignored_profile_path|. |
358 void UpdateAllPrefHashStoresIfRequired( | 358 void UpdateAllPrefHashStoresIfRequired( |
359 const base::FilePath& ignored_profile_path) { | 359 const base::FilePath& ignored_profile_path) { |
360 if (GetSettingsEnforcementGroup() >= GROUP_ENFORCE_ALWAYS) | |
361 return; | |
362 const ProfileInfoCache& profile_info_cache = | 360 const ProfileInfoCache& profile_info_cache = |
363 g_browser_process->profile_manager()->GetProfileInfoCache(); | 361 g_browser_process->profile_manager()->GetProfileInfoCache(); |
364 const size_t n_profiles = profile_info_cache.GetNumberOfProfiles(); | 362 const size_t n_profiles = profile_info_cache.GetNumberOfProfiles(); |
365 for (size_t i = 0; i < n_profiles; ++i) { | 363 for (size_t i = 0; i < n_profiles; ++i) { |
366 const base::FilePath profile_path = | 364 const base::FilePath profile_path = |
367 profile_info_cache.GetPathOfProfileAtIndex(i); | 365 profile_info_cache.GetPathOfProfileAtIndex(i); |
368 if (profile_path != ignored_profile_path) { | 366 if (profile_path != ignored_profile_path) { |
369 CreateProfilePrefStoreManager(profile_path) | 367 CreateProfilePrefStoreManager(profile_path) |
370 ->UpdateProfileHashStoreIfRequired( | 368 ->UpdateProfileHashStoreIfRequired( |
371 JsonPrefStore::GetTaskRunnerForFile( | 369 JsonPrefStore::GetTaskRunnerForFile( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 } | 446 } |
449 | 447 |
450 void SchedulePrefHashStoresUpdateCheck( | 448 void SchedulePrefHashStoresUpdateCheck( |
451 const base::FilePath& initial_profile_path) { | 449 const base::FilePath& initial_profile_path) { |
452 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) { | 450 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) { |
453 ProfilePrefStoreManager::ResetAllPrefHashStores( | 451 ProfilePrefStoreManager::ResetAllPrefHashStores( |
454 g_browser_process->local_state()); | 452 g_browser_process->local_state()); |
455 return; | 453 return; |
456 } | 454 } |
457 | 455 |
| 456 if (GetSettingsEnforcementGroup() >= GROUP_ENFORCE_ALWAYS) |
| 457 return; |
| 458 |
458 const int kDefaultPrefHashStoresUpdateCheckDelaySeconds = 55; | 459 const int kDefaultPrefHashStoresUpdateCheckDelaySeconds = 55; |
459 BrowserThread::PostDelayedTask( | 460 BrowserThread::PostDelayedTask( |
460 BrowserThread::UI, | 461 BrowserThread::UI, |
461 FROM_HERE, | 462 FROM_HERE, |
462 base::Bind(&UpdateAllPrefHashStoresIfRequired, | 463 base::Bind(&UpdateAllPrefHashStoresIfRequired, |
463 initial_profile_path), | 464 initial_profile_path), |
464 base::TimeDelta::FromSeconds( | 465 base::TimeDelta::FromSeconds( |
465 g_disable_delays_and_domain_check_for_testing ? | 466 g_disable_delays_and_domain_check_for_testing ? |
466 0 : kDefaultPrefHashStoresUpdateCheckDelaySeconds)); | 467 0 : kDefaultPrefHashStoresUpdateCheckDelaySeconds)); |
467 } | 468 } |
(...skipping 19 matching lines...) Expand all Loading... |
487 | 488 |
488 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 489 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
489 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 490 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
490 } | 491 } |
491 | 492 |
492 void RegisterPrefs(PrefRegistrySimple* registry) { | 493 void RegisterPrefs(PrefRegistrySimple* registry) { |
493 ProfilePrefStoreManager::RegisterPrefs(registry); | 494 ProfilePrefStoreManager::RegisterPrefs(registry); |
494 } | 495 } |
495 | 496 |
496 } // namespace chrome_prefs | 497 } // namespace chrome_prefs |
OLD | NEW |