Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 #include "base/threading/sequenced_worker_pool.h" | 25 #include "base/threading/sequenced_worker_pool.h" |
| 26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
| 27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
| 28 #include "chrome/browser/prefs/command_line_pref_store.h" | 28 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 29 #include "chrome/browser/prefs/pref_hash_filter.h" | 29 #include "chrome/browser/prefs/pref_hash_filter.h" |
| 30 #include "chrome/browser/prefs/pref_model_associator.h" | 30 #include "chrome/browser/prefs/pref_model_associator.h" |
| 31 #include "chrome/browser/prefs/pref_service_syncable.h" | 31 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 32 #include "chrome/browser/prefs/pref_service_syncable_factory.h" | 32 #include "chrome/browser/prefs/pref_service_syncable_factory.h" |
| 33 #include "chrome/browser/prefs/profile_pref_store_manager.h" | 33 #include "chrome/browser/prefs/profile_pref_store_manager.h" |
| 34 #include "chrome/browser/profiles/file_path_verifier_win.h" | 34 #include "chrome/browser/profiles/file_path_verifier_win.h" |
| 35 #include "chrome/browser/profiles/profile_info_cache.h" | 35 #include "chrome/browser/profiles/profile_info_cache.h" |
|
gab
2014/06/11 19:25:41
rm this include
erikwright (departed)
2014/06/11 21:08:36
Done.
| |
| 36 #include "chrome/browser/profiles/profile_manager.h" | 36 #include "chrome/browser/profiles/profile_manager.h" |
|
gab
2014/06/11 19:25:41
and this one
erikwright (departed)
2014/06/11 21:08:35
Done.
| |
| 37 #include "chrome/browser/search_engines/default_search_manager.h" | 37 #include "chrome/browser/search_engines/default_search_manager.h" |
| 38 #include "chrome/browser/search_engines/default_search_pref_migration.h" | 38 #include "chrome/browser/search_engines/default_search_pref_migration.h" |
| 39 #include "chrome/browser/ui/profile_error_dialog.h" | 39 #include "chrome/browser/ui/profile_error_dialog.h" |
| 40 #include "chrome/common/chrome_constants.h" | 40 #include "chrome/common/chrome_constants.h" |
| 41 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| 42 #include "components/pref_registry/pref_registry_syncable.h" | 42 #include "components/pref_registry/pref_registry_syncable.h" |
| 43 #include "content/public/browser/browser_context.h" | 43 #include "content/public/browser/browser_context.h" |
| 44 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
| 45 #include "extensions/browser/pref_names.h" | 45 #include "extensions/browser/pref_names.h" |
| 46 #include "grit/browser_resources.h" | 46 #include "grit/browser_resources.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 { chrome_prefs::internals:: | 225 { chrome_prefs::internals:: |
| 226 kSettingsEnforcementGroupEnforceAlwaysWithExtensions, | 226 kSettingsEnforcementGroupEnforceAlwaysWithExtensions, |
| 227 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS }, | 227 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS }, |
| 228 { chrome_prefs::internals:: | 228 { chrome_prefs::internals:: |
| 229 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE, | 229 kSettingsEnforcementGroupEnforceAlwaysWithExtensionsAndDSE, |
| 230 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE }, | 230 GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE }, |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 // Use the no enforcement setting in the absence of a field trial | 233 // Use the no enforcement setting in the absence of a field trial |
| 234 // config. Remember to update the OFFICIAL_BUILD sections of | 234 // config. Remember to update the OFFICIAL_BUILD sections of |
| 235 // pref_hash_browsertest.cc and extension_startup_browsertest.cc when updating | 235 // pref_hash_browsertest.cc and extension_startup_browsertest.cc when updating |
|
gab
2014/06/11 19:25:41
Remove mention of "pref_hash_browsertest.cc" from
erikwright (departed)
2014/06/11 21:08:36
Done.
| |
| 236 // the default value below. | 236 // the default value below. |
| 237 // TODO(gab): Change this to the strongest enforcement on all platforms. | 237 // TODO(gab): Change this to the strongest enforcement on all platforms. |
| 238 SettingsEnforcementGroup enforcement_group = GROUP_NO_ENFORCEMENT; | 238 SettingsEnforcementGroup enforcement_group = GROUP_NO_ENFORCEMENT; |
| 239 bool group_determined_from_trial = false; | 239 bool group_determined_from_trial = false; |
| 240 base::FieldTrial* trial = | 240 base::FieldTrial* trial = |
| 241 base::FieldTrialList::Find( | 241 base::FieldTrialList::Find( |
| 242 chrome_prefs::internals::kSettingsEnforcementTrialName); | 242 chrome_prefs::internals::kSettingsEnforcementTrialName); |
| 243 if (trial) { | 243 if (trial) { |
| 244 const std::string& group_name = trial->group_name(); | 244 const std::string& group_name = trial->group_name(); |
| 245 // ARRAYSIZE_UNSAFE must be used since the array is declared locally; it is | 245 // ARRAYSIZE_UNSAFE must be used since the array is declared locally; it is |
| (...skipping 135 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) | |
|
gab
2014/06/11 19:25:42
Also remove GROUP_ENFORCE_ON_LOAD which was the sa
erikwright (departed)
2014/06/11 21:08:36
Done. Are any experiment configuration changes req
gab
2014/06/11 21:39:29
Not immediately, we can remove enforce_on_load ent
| |
| 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 |