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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 386 |
387 factory->set_async(async); | 387 factory->set_async(async); |
388 factory->set_extension_prefs(extension_prefs); | 388 factory->set_extension_prefs(extension_prefs); |
389 factory->set_command_line_prefs( | 389 factory->set_command_line_prefs( |
390 make_scoped_refptr( | 390 make_scoped_refptr( |
391 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); | 391 new CommandLinePrefStore(CommandLine::ForCurrentProcess()))); |
392 factory->set_read_error_callback(base::Bind(&HandleReadError)); | 392 factory->set_read_error_callback(base::Bind(&HandleReadError)); |
393 factory->set_user_prefs(user_pref_store); | 393 factory->set_user_prefs(user_pref_store); |
394 } | 394 } |
395 | 395 |
396 // Initialize/update preference hash stores for all profiles but the one whose | |
397 // path matches |ignored_profile_path|. | |
398 void UpdateAllPrefHashStoresIfRequired( | |
399 const base::FilePath& ignored_profile_path) { | |
400 const ProfileInfoCache& profile_info_cache = | |
401 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
402 const size_t n_profiles = profile_info_cache.GetNumberOfProfiles(); | |
403 for (size_t i = 0; i < n_profiles; ++i) { | |
404 const base::FilePath profile_path = | |
405 profile_info_cache.GetPathOfProfileAtIndex(i); | |
406 if (profile_path != ignored_profile_path) { | |
407 CreateProfilePrefStoreManager(profile_path) | |
408 ->UpdateProfileHashStoreIfRequired( | |
409 JsonPrefStore::GetTaskRunnerForFile( | |
410 profile_path, BrowserThread::GetBlockingPool())); | |
411 } | |
412 } | |
413 } | |
414 | |
415 } // namespace | 396 } // namespace |
416 | 397 |
417 namespace chrome_prefs { | 398 namespace chrome_prefs { |
418 | 399 |
419 namespace internals { | 400 namespace internals { |
420 | 401 |
421 const char kSettingsEnforcementTrialName[] = "SettingsEnforcement"; | 402 const char kSettingsEnforcementTrialName[] = "SettingsEnforcement"; |
422 const char kSettingsEnforcementGroupNoEnforcement[] = "no_enforcement"; | 403 const char kSettingsEnforcementGroupNoEnforcement[] = "no_enforcement"; |
423 const char kSettingsEnforcementGroupEnforceOnload[] = "enforce_on_load"; | 404 const char kSettingsEnforcementGroupEnforceOnload[] = "enforce_on_load"; |
424 const char kSettingsEnforcementGroupEnforceAlways[] = "enforce_always"; | 405 const char kSettingsEnforcementGroupEnforceAlways[] = "enforce_always"; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 base::TimeDelta::FromSeconds(g_disable_delays_and_domain_check_for_testing | 468 base::TimeDelta::FromSeconds(g_disable_delays_and_domain_check_for_testing |
488 ? 0 | 469 ? 0 |
489 : kVerifyPrefsFileDelaySeconds)); | 470 : kVerifyPrefsFileDelaySeconds)); |
490 #endif | 471 #endif |
491 } | 472 } |
492 | 473 |
493 void DisableDelaysAndDomainCheckForTesting() { | 474 void DisableDelaysAndDomainCheckForTesting() { |
494 g_disable_delays_and_domain_check_for_testing = true; | 475 g_disable_delays_and_domain_check_for_testing = true; |
495 } | 476 } |
496 | 477 |
497 void SchedulePrefHashStoresUpdateCheck( | |
498 const base::FilePath& initial_profile_path) { | |
499 if (!ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking) { | |
500 ProfilePrefStoreManager::ResetAllPrefHashStores( | |
501 g_browser_process->local_state()); | |
502 return; | |
503 } | |
504 | |
505 if (GetSettingsEnforcementGroup() >= GROUP_ENFORCE_ALWAYS) | |
506 return; | |
507 | |
508 const int kDefaultPrefHashStoresUpdateCheckDelaySeconds = 55; | |
509 BrowserThread::PostDelayedTask( | |
510 BrowserThread::UI, | |
511 FROM_HERE, | |
512 base::Bind(&UpdateAllPrefHashStoresIfRequired, | |
513 initial_profile_path), | |
514 base::TimeDelta::FromSeconds( | |
515 g_disable_delays_and_domain_check_for_testing ? | |
516 0 : kDefaultPrefHashStoresUpdateCheckDelaySeconds)); | |
517 } | |
518 | |
519 void ResetPrefHashStore(const base::FilePath& profile_path) { | 478 void ResetPrefHashStore(const base::FilePath& profile_path) { |
520 CreateProfilePrefStoreManager(profile_path)->ResetPrefHashStore(); | 479 CreateProfilePrefStoreManager(profile_path)->ResetPrefHashStore(); |
521 } | 480 } |
522 | 481 |
523 bool InitializePrefsFromMasterPrefs( | 482 bool InitializePrefsFromMasterPrefs( |
524 const base::FilePath& profile_path, | 483 const base::FilePath& profile_path, |
525 const base::DictionaryValue& master_prefs) { | 484 const base::DictionaryValue& master_prefs) { |
526 return CreateProfilePrefStoreManager(profile_path) | 485 return CreateProfilePrefStoreManager(profile_path) |
527 ->InitializePrefsFromMasterPrefs(master_prefs); | 486 ->InitializePrefsFromMasterPrefs(master_prefs); |
528 } | 487 } |
529 | 488 |
530 base::Time GetResetTime(Profile* profile) { | 489 base::Time GetResetTime(Profile* profile) { |
531 return ProfilePrefStoreManager::GetResetTime(profile->GetPrefs()); | 490 return ProfilePrefStoreManager::GetResetTime(profile->GetPrefs()); |
532 } | 491 } |
533 | 492 |
534 void ClearResetTime(Profile* profile) { | 493 void ClearResetTime(Profile* profile) { |
535 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); | 494 ProfilePrefStoreManager::ClearResetTime(profile->GetPrefs()); |
536 } | 495 } |
537 | 496 |
538 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 497 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
539 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 498 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
540 } | 499 } |
541 | 500 |
542 void RegisterPrefs(PrefRegistrySimple* registry) { | 501 void RegisterPrefs(PrefRegistrySimple* registry) { |
543 ProfilePrefStoreManager::RegisterPrefs(registry); | 502 ProfilePrefStoreManager::RegisterPrefs(registry); |
544 } | 503 } |
545 | 504 |
546 } // namespace chrome_prefs | 505 } // namespace chrome_prefs |
OLD | NEW |