summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prefs/pref_service.cc
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 03:41:37 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-12 03:41:37 +0000
commitea3e497b1949405ae04caa8b1dc8400672b1dfa1 (patch)
tree597971f904ab59e7e47fbe108c241e66640c5d4e /chrome/browser/prefs/pref_service.cc
parent92a794994111f442e9c7ba1792a5418a77c2ca74 (diff)
downloadchromium_src-ea3e497b1949405ae04caa8b1dc8400672b1dfa1.zip
chromium_src-ea3e497b1949405ae04caa8b1dc8400672b1dfa1.tar.gz
chromium_src-ea3e497b1949405ae04caa8b1dc8400672b1dfa1.tar.bz2
Keep emtpy List/Dictionary pref value with non-empty default.
- Add a MarkNeedsEmptyValue method to JsonPrefStore; - In PrefService::RegisterPreference, mark ListValue and DictionaryValue pref with non-empty default as needing empty value in |user_pref_store_|; - Update ChromeLauncherDelegate to put back default pinned apps and add migration logic for M19 users; - Add unit tests; BUG=122679 TEST=Verify fix for issue 122679. Review URL: http://codereview.chromium.org/10055003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs/pref_service.cc')
-rw-r--r--chrome/browser/prefs/pref_service.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc
index cf9f22e..de7f406 100644
--- a/chrome/browser/prefs/pref_service.cc
+++ b/chrome/browser/prefs/pref_service.cc
@@ -727,6 +727,23 @@ 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) {
+ const base::ListValue* list = NULL;
+ if (default_value->GetAsList(&list) && !list->empty())
+ needs_empty_value = true;
+ } else if (orig_type == base::Value::TYPE_DICTIONARY) {
+ const base::DictionaryValue* dict = NULL;
+ if (default_value->GetAsDictionary(&dict) && !dict->empty())
+ needs_empty_value = true;
+ }
+ if (needs_empty_value)
+ user_pref_store_->MarkNeedsEmptyValue(path);
+
// Hand off ownership.
default_store_->SetDefaultValue(path, scoped_value.release());