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" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/prefs/default_pref_store.h" | 16 #include "base/prefs/default_pref_store.h" |
17 #include "base/prefs/json_pref_store.h" | 17 #include "base/prefs/json_pref_store.h" |
18 #include "base/prefs/pref_filter.h" | 18 #include "base/prefs/pref_filter.h" |
19 #include "base/prefs/pref_notifier_impl.h" | 19 #include "base/prefs/pref_notifier_impl.h" |
20 #include "base/prefs/pref_registry.h" | 20 #include "base/prefs/pref_registry.h" |
21 #include "base/prefs/pref_registry_simple.h" | 21 #include "base/prefs/pref_registry_simple.h" |
22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
23 #include "base/prefs/pref_store.h" | 23 #include "base/prefs/pref_store.h" |
24 #include "base/prefs/pref_value_store.h" | 24 #include "base/prefs/pref_value_store.h" |
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/browser_ui_prefs_migrator.h" |
28 #include "chrome/browser/prefs/command_line_pref_store.h" | 29 #include "chrome/browser/prefs/command_line_pref_store.h" |
29 #include "chrome/browser/prefs/pref_hash_filter.h" | 30 #include "chrome/browser/prefs/pref_hash_filter.h" |
30 #include "chrome/browser/prefs/pref_model_associator.h" | 31 #include "chrome/browser/prefs/pref_model_associator.h" |
31 #include "chrome/browser/prefs/pref_service_syncable.h" | 32 #include "chrome/browser/prefs/pref_service_syncable.h" |
32 #include "chrome/browser/prefs/pref_service_syncable_factory.h" | 33 #include "chrome/browser/prefs/pref_service_syncable_factory.h" |
33 #include "chrome/browser/prefs/profile_pref_store_manager.h" | 34 #include "chrome/browser/prefs/profile_pref_store_manager.h" |
34 #include "chrome/browser/profiles/file_path_verifier_win.h" | 35 #include "chrome/browser/profiles/file_path_verifier_win.h" |
35 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/search_engines/default_search_pref_migration.h" | 37 #include "chrome/browser/search_engines/default_search_pref_migration.h" |
37 #include "chrome/browser/sync/glue/sync_start_util.h" | 38 #include "chrome/browser/sync/glue/sync_start_util.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // done since sync may bring back the user's server value post-reset which | 463 // done since sync may bring back the user's server value post-reset which |
463 // could potentially cause a "settings flash" between the factory default and | 464 // could potentially cause a "settings flash" between the factory default and |
464 // the re-instantiated server value. Starting sync ASAP minimizes the window | 465 // the re-instantiated server value. Starting sync ASAP minimizes the window |
465 // before the server value is re-instantiated (this window can otherwise be | 466 // before the server value is re-instantiated (this window can otherwise be |
466 // as long as 10 seconds by default). | 467 // as long as 10 seconds by default). |
467 const base::Closure start_sync_flare_for_prefs = | 468 const base::Closure start_sync_flare_for_prefs = |
468 base::Bind(sync_start_util::GetFlareForSyncableService(profile_path), | 469 base::Bind(sync_start_util::GetFlareForSyncableService(profile_path), |
469 syncer::PREFERENCES); | 470 syncer::PREFERENCES); |
470 | 471 |
471 PrefServiceSyncableFactory factory; | 472 PrefServiceSyncableFactory factory; |
| 473 scoped_refptr<PersistentPrefStore> user_pref_store( |
| 474 CreateProfilePrefStoreManager(profile_path) |
| 475 ->CreateProfilePrefStore(pref_io_task_runner, |
| 476 start_sync_flare_for_prefs, |
| 477 validation_delegate)); |
| 478 // BrowserUIPrefsMigrator unregisters and deletes itself after it is done. |
| 479 user_pref_store->AddObserver( |
| 480 new BrowserUIPrefsMigrator(user_pref_store.get())); |
472 PrepareFactory(&factory, | 481 PrepareFactory(&factory, |
473 policy_service, | 482 policy_service, |
474 supervised_user_settings, | 483 supervised_user_settings, |
475 scoped_refptr<PersistentPrefStore>( | 484 user_pref_store, |
476 CreateProfilePrefStoreManager(profile_path) | |
477 ->CreateProfilePrefStore(pref_io_task_runner, | |
478 start_sync_flare_for_prefs, | |
479 validation_delegate)), | |
480 extension_prefs, | 485 extension_prefs, |
481 async); | 486 async); |
482 scoped_ptr<PrefServiceSyncable> pref_service = | 487 scoped_ptr<PrefServiceSyncable> pref_service = |
483 factory.CreateSyncable(pref_registry.get()); | 488 factory.CreateSyncable(pref_registry.get()); |
484 | 489 |
485 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); | 490 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); |
486 | 491 |
487 return pref_service.Pass(); | 492 return pref_service.Pass(); |
488 } | 493 } |
489 | 494 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 | 528 |
524 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { | 529 void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
525 ProfilePrefStoreManager::RegisterProfilePrefs(registry); | 530 ProfilePrefStoreManager::RegisterProfilePrefs(registry); |
526 } | 531 } |
527 | 532 |
528 void RegisterPrefs(PrefRegistrySimple* registry) { | 533 void RegisterPrefs(PrefRegistrySimple* registry) { |
529 ProfilePrefStoreManager::RegisterPrefs(registry); | 534 ProfilePrefStoreManager::RegisterPrefs(registry); |
530 } | 535 } |
531 | 536 |
532 } // namespace chrome_prefs | 537 } // namespace chrome_prefs |
OLD | NEW |