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