| 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/pref_service.h" | 5 #include "chrome/browser/prefs/pref_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 PrefServiceBase* PrefServiceBase::FromBrowserContext(BrowserContext* context) { | 118 PrefServiceBase* PrefServiceBase::FromBrowserContext(BrowserContext* context) { |
| 119 return static_cast<Profile*>(context)->GetPrefs(); | 119 return static_cast<Profile*>(context)->GetPrefs(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // static | 122 // static |
| 123 PrefService* PrefService::CreatePrefService( | 123 PrefService* PrefService::CreatePrefService( |
| 124 const FilePath& pref_filename, | 124 const FilePath& pref_filename, |
| 125 policy::PolicyService* policy_service, | 125 policy::PolicyService* policy_service, |
| 126 PrefStore* extension_prefs, | 126 PrefStore* extension_prefs, |
| 127 bool async) { | 127 bool async, |
| 128 base::SequencedTaskRunner* sequenced_task_runner) { |
| 128 using policy::ConfigurationPolicyPrefStore; | 129 using policy::ConfigurationPolicyPrefStore; |
| 129 | 130 |
| 130 #if defined(OS_LINUX) | 131 #if defined(OS_LINUX) |
| 131 // We'd like to see what fraction of our users have the preferences | 132 // We'd like to see what fraction of our users have the preferences |
| 132 // stored on a network file system, as we've had no end of troubles | 133 // stored on a network file system, as we've had no end of troubles |
| 133 // with NFS/AFS. | 134 // with NFS/AFS. |
| 134 // TODO(evanm): remove this once we've collected state. | 135 // TODO(evanm): remove this once we've collected state. |
| 135 file_util::FileSystemType fstype; | 136 file_util::FileSystemType fstype; |
| 136 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) { | 137 if (file_util::GetFileSystemType(pref_filename.DirName(), &fstype)) { |
| 137 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType", | 138 UMA_HISTOGRAM_ENUMERATION("PrefService.FileSystemType", |
| 138 static_cast<int>(fstype), | 139 static_cast<int>(fstype), |
| 139 file_util::FILE_SYSTEM_TYPE_COUNT); | 140 file_util::FILE_SYSTEM_TYPE_COUNT); |
| 140 } | 141 } |
| 141 #endif | 142 #endif |
| 142 | 143 |
| 143 #if defined(ENABLE_CONFIGURATION_POLICY) | 144 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 144 ConfigurationPolicyPrefStore* managed = | 145 ConfigurationPolicyPrefStore* managed = |
| 145 ConfigurationPolicyPrefStore::CreateMandatoryPolicyPrefStore( | 146 ConfigurationPolicyPrefStore::CreateMandatoryPolicyPrefStore( |
| 146 policy_service); | 147 policy_service); |
| 147 ConfigurationPolicyPrefStore* recommended = | 148 ConfigurationPolicyPrefStore* recommended = |
| 148 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore( | 149 ConfigurationPolicyPrefStore::CreateRecommendedPolicyPrefStore( |
| 149 policy_service); | 150 policy_service); |
| 150 #else | 151 #else |
| 151 ConfigurationPolicyPrefStore* managed = NULL; | 152 ConfigurationPolicyPrefStore* managed = NULL; |
| 152 ConfigurationPolicyPrefStore* recommended = NULL; | 153 ConfigurationPolicyPrefStore* recommended = NULL; |
| 153 #endif // ENABLE_CONFIGURATION_POLICY | 154 #endif // ENABLE_CONFIGURATION_POLICY |
| 154 | 155 |
| 155 CommandLinePrefStore* command_line = | 156 CommandLinePrefStore* command_line = |
| 156 new CommandLinePrefStore(CommandLine::ForCurrentProcess()); | 157 new CommandLinePrefStore(CommandLine::ForCurrentProcess()); |
| 157 JsonPrefStore* user = new JsonPrefStore( | 158 JsonPrefStore* user = JsonPrefStore::Create( |
| 158 pref_filename, | 159 pref_filename, sequenced_task_runner); |
| 159 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); | |
| 160 DefaultPrefStore* default_pref_store = new DefaultPrefStore(); | 160 DefaultPrefStore* default_pref_store = new DefaultPrefStore(); |
| 161 | 161 |
| 162 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); | 162 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); |
| 163 PrefModelAssociator* pref_sync_associator = new PrefModelAssociator(); | 163 PrefModelAssociator* pref_sync_associator = new PrefModelAssociator(); |
| 164 | 164 |
| 165 return new PrefService( | 165 return new PrefService( |
| 166 pref_notifier, | 166 pref_notifier, |
| 167 new PrefValueStore( | 167 new PrefValueStore( |
| 168 managed, | 168 managed, |
| 169 extension_prefs, | 169 extension_prefs, |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 1047 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 bool PrefService::Preference::IsUserModifiable() const { | 1050 bool PrefService::Preference::IsUserModifiable() const { |
| 1051 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 1051 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
| 1052 } | 1052 } |
| 1053 | 1053 |
| 1054 bool PrefService::Preference::IsExtensionModifiable() const { | 1054 bool PrefService::Preference::IsExtensionModifiable() const { |
| 1055 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 1055 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
| 1056 } | 1056 } |
| OLD | NEW |