| Index: chrome/service/service_process_prefs.cc
|
| diff --git a/chrome/service/service_process_prefs.cc b/chrome/service/service_process_prefs.cc
|
| index b925e2bed8d6926cba7c8a365e6c75636048433d..38c0d507de3392604f88d8ef8dc89f3b67774a0d 100644
|
| --- a/chrome/service/service_process_prefs.cc
|
| +++ b/chrome/service/service_process_prefs.cc
|
| @@ -22,11 +22,15 @@ void ServiceProcessPrefs::WritePrefs() {
|
| prefs_->CommitPendingWrite();
|
| }
|
|
|
| -void ServiceProcessPrefs::GetString(const std::string& key,
|
| - std::string* result) const {
|
| +std::string ServiceProcessPrefs::GetString(const std::string& key,
|
| + const std::string& default) const {
|
| const Value* value;
|
| - if (prefs_->GetValue(key, &value) == PersistentPrefStore::READ_OK)
|
| - value->GetAsString(result);
|
| + std::string result;
|
| + if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
|
| + !value->GetAsString(&result)) {
|
| + return default;
|
| + }
|
| + return result;
|
| }
|
|
|
| void ServiceProcessPrefs::SetString(const std::string& key,
|
| @@ -34,28 +38,45 @@ void ServiceProcessPrefs::SetString(const std::string& key,
|
| prefs_->SetValue(key, Value::CreateStringValue(value));
|
| }
|
|
|
| -void ServiceProcessPrefs::GetBoolean(const std::string& key,
|
| - bool* result) const {
|
| +bool ServiceProcessPrefs::GetBoolean(const std::string& key,
|
| + bool default) const {
|
| const Value* value;
|
| - if (prefs_->GetValue(key, &value) == PersistentPrefStore::READ_OK)
|
| - value->GetAsBoolean(result);
|
| + bool result = false;
|
| + if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
|
| + !value->GetAsBoolean(&result)) {
|
| + return default;
|
| + }
|
| + return result;
|
| }
|
|
|
| void ServiceProcessPrefs::SetBoolean(const std::string& key, bool value) {
|
| prefs_->SetValue(key, Value::CreateBooleanValue(value));
|
| }
|
|
|
| -void ServiceProcessPrefs::GetDictionary(const std::string& key,
|
| - const DictionaryValue** result) const {
|
| +const DictionaryValue* ServiceProcessPrefs::GetDictionary(
|
| + const std::string& key) const {
|
| const Value* value;
|
| + const DictionaryValue* result = NULL;
|
| if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
|
| !value->IsType(Value::TYPE_DICTIONARY)) {
|
| - return;
|
| + return NULL;
|
| }
|
|
|
| - *result = static_cast<const DictionaryValue*>(value);
|
| + return static_cast<const DictionaryValue*>(value);
|
| +}
|
| +
|
| +const base::ListValue* ServiceProcessPrefs::GetList(
|
| + const std::string& key) const {
|
| + const Value* value;
|
| + if (prefs_->GetValue(key, &value) != PersistentPrefStore::READ_OK ||
|
| + !value->IsType(Value::TYPE_LIST)) {
|
| + return NULL;
|
| + }
|
| +
|
| + return static_cast<const ListValue*>(value);
|
| }
|
|
|
| void ServiceProcessPrefs::RemovePref(const std::string& key) {
|
| prefs_->RemoveValue(key);
|
| }
|
| +
|
|
|