Index: chrome/browser/prefs/pref_metrics_service.cc |
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc |
index fa290296c75b6ac2f26a3609416bb0e6c2e07d10..c57bea5c99c65f53a0bb9ccc8be7bb9532fbae3b 100644 |
--- a/chrome/browser/prefs/pref_metrics_service.cc |
+++ b/chrome/browser/prefs/pref_metrics_service.cc |
@@ -284,7 +284,8 @@ void PrefMetricsService::CheckTrackedPreferences() { |
// Get the hashed prefs dictionary if it exists. If it doesn't, it will be |
// created if we set preference values below. |
const base::DictionaryValue* hashed_prefs = NULL; |
- pref_hash_dicts->GetDictionary(profile_name_, &hashed_prefs); |
+ pref_hash_dicts->GetDictionaryWithoutPathExpansion(profile_name_, |
battre
2013/09/12 08:38:47
This is pretty error prone. Can you please update
michaelpg
2013/09/14 18:18:32
Done.
|
+ &hashed_prefs); |
for (int i = 0; i < tracked_pref_path_count_; ++i) { |
// Skip prefs that haven't been registered. |
if (!prefs_->FindPreference(tracked_pref_paths_[i])) |
@@ -344,8 +345,16 @@ void PrefMetricsService::UpdateTrackedPreference(const char* path) { |
const base::Value* value = prefs_->GetUserPrefValue(path); |
if (value) { |
DictionaryPrefUpdate update(local_state_, prefs::kProfilePreferenceHashes); |
- update->SetString(GetHashedPrefPath(path), |
- GetHashedPrefValue(path, value)); |
+ DictionaryValue* child_dictionary = NULL; |
+ |
+ // Get the dictionary corresponding to the profile name, |
+ // which may have a . |
xiyuan
2013/09/12 16:18:37
nit: which may have a '.'.
michaelpg
2013/09/14 18:18:32
Done.
|
+ if (!update->GetDictionaryWithoutPathExpansion(profile_name_, |
+ &child_dictionary)) { |
+ child_dictionary = new DictionaryValue; |
+ update->SetWithoutPathExpansion(profile_name_, child_dictionary); |
+ } |
+ child_dictionary->SetString(path, GetHashedPrefValue(path, value)); |
} else { |
RemoveTrackedPreference(path); |
} |
@@ -353,14 +362,13 @@ void PrefMetricsService::UpdateTrackedPreference(const char* path) { |
bool PrefMetricsService::RemoveTrackedPreference(const char* path) { |
DictionaryPrefUpdate update(local_state_, prefs::kProfilePreferenceHashes); |
- return update->Remove(GetHashedPrefPath(path), NULL); |
-} |
+ DictionaryValue* child_dictionary = NULL; |
-std::string PrefMetricsService::GetHashedPrefPath(const char* path) { |
- std::string hash_pref_path(profile_name_); |
- hash_pref_path.append("."); |
- hash_pref_path.append(path); |
- return hash_pref_path; |
+ if (!update->GetDictionaryWithoutPathExpansion(profile_name_, |
+ &child_dictionary)) { |
+ return false; |
+ } |
+ return child_dictionary->Remove(path, NULL); |
} |
std::string PrefMetricsService::GetHashedPrefValue( |