Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_metrics_service.h" | 5 #include "chrome/browser/prefs/pref_metrics_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 // Get the hashed prefs dictionary if it exists. If it doesn't, it will be | 280 // Get the hashed prefs dictionary if it exists. If it doesn't, it will be |
| 281 // created if we set preference values below. | 281 // created if we set preference values below. |
| 282 const base::DictionaryValue* hashed_prefs = NULL; | 282 const base::DictionaryValue* hashed_prefs = NULL; |
| 283 pref_hash_dicts->GetDictionaryWithoutPathExpansion(profile_name_, | 283 pref_hash_dicts->GetDictionaryWithoutPathExpansion(profile_name_, |
| 284 &hashed_prefs); | 284 &hashed_prefs); |
| 285 for (int i = 0; i < tracked_pref_path_count_; ++i) { | 285 for (int i = 0; i < tracked_pref_path_count_; ++i) { |
| 286 // Skip prefs that haven't been registered. | 286 // Skip prefs that haven't been registered. |
| 287 if (!prefs_->FindPreference(tracked_pref_paths_[i])) | 287 if (!prefs_->FindPreference(tracked_pref_paths_[i])) |
| 288 continue; | 288 continue; |
| 289 | 289 |
| 290 // Make sure tracked prefs are saved to disk even if empty. | |
| 291 // TODO(gab): Guarantee this for all prefs at a lower level and remove this | |
| 292 // hack. | |
| 293 prefs_->MarkUserStoreNeedsEmptyValue(tracked_pref_paths_[i]); | |
|
battre
2013/11/22 13:01:57
I think I would move this into the constructor. Ot
gab
2013/11/22 18:24:37
Done, thanks.
| |
| 294 | |
| 290 const base::Value* value = prefs_->GetUserPrefValue(tracked_pref_paths_[i]); | 295 const base::Value* value = prefs_->GetUserPrefValue(tracked_pref_paths_[i]); |
| 291 std::string last_hash; | 296 std::string last_hash; |
| 292 // First try to get the stored expected hash... | 297 // First try to get the stored expected hash... |
| 293 if (hashed_prefs && | 298 if (hashed_prefs && |
| 294 hashed_prefs->GetString(tracked_pref_paths_[i], &last_hash)) { | 299 hashed_prefs->GetString(tracked_pref_paths_[i], &last_hash)) { |
| 295 // ... if we have one get the hash of the current value... | 300 // ... if we have one get the hash of the current value... |
| 296 const std::string value_hash = | 301 const std::string value_hash = |
| 297 GetHashedPrefValue(tracked_pref_paths_[i], value, | 302 GetHashedPrefValue(tracked_pref_paths_[i], value, |
| 298 HASHED_PREF_STYLE_NEW); | 303 HASHED_PREF_STYLE_NEW); |
| 299 // ... and check that it matches... | 304 // ... and check that it matches... |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 } | 455 } |
| 451 | 456 |
| 452 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 457 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
| 453 return false; | 458 return false; |
| 454 } | 459 } |
| 455 | 460 |
| 456 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 461 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
| 457 content::BrowserContext* context) const { | 462 content::BrowserContext* context) const { |
| 458 return chrome::GetBrowserContextRedirectedInIncognito(context); | 463 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 459 } | 464 } |
| OLD | NEW |