| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ios/chrome/browser/prefs/ios_chrome_pref_service_factory.h" | 5 #include "ios/chrome/browser/prefs/ios_chrome_pref_service_factory.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "components/prefs/json_pref_store.h" | 12 #include "components/prefs/json_pref_store.h" |
| 13 #include "components/prefs/persistent_pref_store.h" | 13 #include "components/prefs/persistent_pref_store.h" |
| 14 #include "components/prefs/pref_filter.h" | 14 #include "components/prefs/pref_filter.h" |
| 15 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 16 #include "components/proxy_config/proxy_config_pref_names.h" | 16 #include "components/proxy_config/proxy_config_pref_names.h" |
| 17 #include "components/search_engines/default_search_pref_migration.h" | |
| 18 #include "components/sync_preferences/pref_service_syncable.h" | 17 #include "components/sync_preferences/pref_service_syncable.h" |
| 19 #include "components/sync_preferences/pref_service_syncable_factory.h" | 18 #include "components/sync_preferences/pref_service_syncable_factory.h" |
| 20 #include "ios/chrome/browser/application_context.h" | 19 #include "ios/chrome/browser/application_context.h" |
| 21 #include "ios/chrome/browser/prefs/ios_chrome_pref_model_associator_client.h" | 20 #include "ios/chrome/browser/prefs/ios_chrome_pref_model_associator_client.h" |
| 22 | 21 |
| 23 namespace { | 22 namespace { |
| 24 | 23 |
| 25 const char kPreferencesFilename[] = "Preferences"; | 24 const char kPreferencesFilename[] = "Preferences"; |
| 26 | 25 |
| 27 // Record PersistentPrefStore's reading errors distribution. | 26 // Record PersistentPrefStore's reading errors distribution. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 // chrome_prefs::CreateProfilePrefs uses ProfilePrefStoreManager to create | 60 // chrome_prefs::CreateProfilePrefs uses ProfilePrefStoreManager to create |
| 62 // the preference store however since Chrome on iOS does not need to track | 61 // the preference store however since Chrome on iOS does not need to track |
| 63 // preference modifications (as applications are sand-boxed), it can use a | 62 // preference modifications (as applications are sand-boxed), it can use a |
| 64 // simple JsonPrefStore to store them (which is what PrefStoreManager uses | 63 // simple JsonPrefStore to store them (which is what PrefStoreManager uses |
| 65 // on platforms that do not track preference modifications). | 64 // on platforms that do not track preference modifications). |
| 66 sync_preferences::PrefServiceSyncableFactory factory; | 65 sync_preferences::PrefServiceSyncableFactory factory; |
| 67 PrepareFactory(&factory, browser_state_path.Append(kPreferencesFilename), | 66 PrepareFactory(&factory, browser_state_path.Append(kPreferencesFilename), |
| 68 pref_io_task_runner); | 67 pref_io_task_runner); |
| 69 std::unique_ptr<sync_preferences::PrefServiceSyncable> pref_service = | 68 std::unique_ptr<sync_preferences::PrefServiceSyncable> pref_service = |
| 70 factory.CreateSyncable(pref_registry.get()); | 69 factory.CreateSyncable(pref_registry.get()); |
| 71 ConfigureDefaultSearchPrefMigrationToDictionaryValue(pref_service.get()); | |
| 72 return pref_service; | 70 return pref_service; |
| 73 } | 71 } |
| 74 | 72 |
| 75 std::unique_ptr<sync_preferences::PrefServiceSyncable> | 73 std::unique_ptr<sync_preferences::PrefServiceSyncable> |
| 76 CreateIncognitoBrowserStatePrefs( | 74 CreateIncognitoBrowserStatePrefs( |
| 77 sync_preferences::PrefServiceSyncable* pref_service) { | 75 sync_preferences::PrefServiceSyncable* pref_service) { |
| 78 // List of keys that cannot be changed in the user prefs file by the incognito | 76 // List of keys that cannot be changed in the user prefs file by the incognito |
| 79 // browser state. All preferences that store information about the browsing | 77 // browser state. All preferences that store information about the browsing |
| 80 // history or behaviour of the user should have this property. | 78 // history or behaviour of the user should have this property. |
| 81 std::vector<const char*> overlay_pref_names; | 79 std::vector<const char*> overlay_pref_names; |
| 82 overlay_pref_names.push_back(proxy_config::prefs::kProxy); | 80 overlay_pref_names.push_back(proxy_config::prefs::kProxy); |
| 83 return base::WrapUnique(pref_service->CreateIncognitoPrefService( | 81 return base::WrapUnique(pref_service->CreateIncognitoPrefService( |
| 84 nullptr, // incognito_extension_pref_store | 82 nullptr, // incognito_extension_pref_store |
| 85 overlay_pref_names)); | 83 overlay_pref_names)); |
| 86 } | 84 } |
| OLD | NEW |