| 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 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 31 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 32 #include "chrome/browser/ui/profile_error_dialog.h" | 32 #include "chrome/browser/ui/profile_error_dialog.h" |
| 33 #include "chrome/common/json_pref_store.h" | 33 #include "chrome/common/json_pref_store.h" |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 36 #include "grit/chromium_strings.h" | 36 #include "grit/chromium_strings.h" |
| 37 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 | 39 |
| 40 using content::BrowserContext; |
| 40 using content::BrowserThread; | 41 using content::BrowserThread; |
| 41 | 42 |
| 42 namespace { | 43 namespace { |
| 43 | 44 |
| 44 // A helper function for RegisterLocalized*Pref that creates a Value* based on | 45 // A helper function for RegisterLocalized*Pref that creates a Value* based on |
| 45 // the string value in the locale dll. Because we control the values in a | 46 // the string value in the locale dll. Because we control the values in a |
| 46 // locale dll, this should always return a Value of the appropriate type. | 47 // locale dll, this should always return a Value of the appropriate type. |
| 47 Value* CreateLocaleDefaultValue(base::Value::Type type, int message_id) { | 48 Value* CreateLocaleDefaultValue(base::Value::Type type, int message_id) { |
| 48 std::string resource_string = l10n_util::GetStringUTF8(message_id); | 49 std::string resource_string = l10n_util::GetStringUTF8(message_id); |
| 49 DCHECK(!resource_string.empty()); | 50 DCHECK(!resource_string.empty()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 base::Bind(&NotifyReadError, message_id)); | 108 base::Bind(&NotifyReadError, message_id)); |
| 108 } | 109 } |
| 109 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, | 110 UMA_HISTOGRAM_ENUMERATION("PrefService.ReadError", error, |
| 110 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); | 111 PersistentPrefStore::PREF_READ_ERROR_MAX_ENUM); |
| 111 } | 112 } |
| 112 } | 113 } |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 } // namespace | 116 } // namespace |
| 116 | 117 |
| 117 PrefServiceBase* PrefServiceBase::ForProfile(Profile* profile) { | 118 PrefServiceBase* PrefServiceBase::ForContext(BrowserContext* context) { |
| 118 return profile->GetPrefs(); | 119 return static_cast<Profile*>(context)->GetPrefs(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 // static | 122 // static |
| 122 PrefService* PrefService::CreatePrefService( | 123 PrefService* PrefService::CreatePrefService( |
| 123 const FilePath& pref_filename, | 124 const FilePath& pref_filename, |
| 124 policy::PolicyService* policy_service, | 125 policy::PolicyService* policy_service, |
| 125 PrefStore* extension_prefs, | 126 PrefStore* extension_prefs, |
| 126 bool async) { | 127 bool async) { |
| 127 using policy::ConfigurationPolicyPrefStore; | 128 using policy::ConfigurationPolicyPrefStore; |
| 128 | 129 |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); | 1047 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); |
| 1047 } | 1048 } |
| 1048 | 1049 |
| 1049 bool PrefService::Preference::IsUserModifiable() const { | 1050 bool PrefService::Preference::IsUserModifiable() const { |
| 1050 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); | 1051 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); |
| 1051 } | 1052 } |
| 1052 | 1053 |
| 1053 bool PrefService::Preference::IsExtensionModifiable() const { | 1054 bool PrefService::Preference::IsExtensionModifiable() const { |
| 1054 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); | 1055 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); |
| 1055 } | 1056 } |
| OLD | NEW |