Chromium Code Reviews| Index: chrome/browser/prefs/pref_service.cc |
| diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc |
| index cf9f22ed0ca0a25eb861411b84f73eea557b496b..500ec96938efd2eb710be8dee21510a47c7dd2c6 100644 |
| --- a/chrome/browser/prefs/pref_service.cc |
| +++ b/chrome/browser/prefs/pref_service.cc |
| @@ -727,6 +727,22 @@ void PrefService::RegisterPreference(const char* path, |
| DCHECK(orig_type != Value::TYPE_NULL && orig_type != Value::TYPE_BINARY) << |
| "invalid preference type: " << orig_type; |
| + // For ListValue and DictionaryValue with non empty default, empty value |
| + // for |path| needs to be persisted in |user_pref_store_|. So that |
| + // non empty default is not used when user sets an empty ListValue or |
| + // DictionaryValue. |
| + bool needs_empty_value = false; |
| + if (orig_type == base::Value::TYPE_LIST) { |
| + base::ListValue * list = static_cast<base::ListValue*>(default_value); |
|
battre
2012/04/11 21:55:51
nit: base::ListValue*
battre
2012/04/11 21:55:51
instead of the static_cast, I would recommend to u
xiyuan
2012/04/11 22:36:46
Done.
xiyuan
2012/04/11 22:36:46
Done.
|
| + needs_empty_value = !list->empty(); |
| + } else if (orig_type == base::Value::TYPE_DICTIONARY) { |
| + base::DictionaryValue* dict = |
| + static_cast<base::DictionaryValue*>(default_value); |
| + needs_empty_value = !dict->empty(); |
| + } |
| + if (needs_empty_value) |
| + user_pref_store_->MarkNeedsEmptyValue(path); |
| + |
| // Hand off ownership. |
| default_store_->SetDefaultValue(path, scoped_value.release()); |