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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 // Get the hashed prefs dictionary if it exists. If it doesn't, it will be | 292 // Get the hashed prefs dictionary if it exists. If it doesn't, it will be |
293 // created if we set preference values below. | 293 // created if we set preference values below. |
294 const base::DictionaryValue* hashed_prefs = NULL; | 294 const base::DictionaryValue* hashed_prefs = NULL; |
295 pref_hash_dicts->GetDictionaryWithoutPathExpansion(profile_name_, | 295 pref_hash_dicts->GetDictionaryWithoutPathExpansion(profile_name_, |
296 &hashed_prefs); | 296 &hashed_prefs); |
297 for (int i = 0; i < tracked_pref_path_count_; ++i) { | 297 for (int i = 0; i < tracked_pref_path_count_; ++i) { |
298 // Skip prefs that haven't been registered. | 298 // Skip prefs that haven't been registered. |
299 if (!prefs_->FindPreference(tracked_pref_paths_[i])) | 299 if (!prefs_->FindPreference(tracked_pref_paths_[i])) |
300 continue; | 300 continue; |
301 | 301 |
302 // Make sure tracked prefs are saved to disk even if empty. | |
303 // TODO(gab): Guarantee this for all prefs at a lower level and remove this | |
304 // hack. | |
305 prefs_->MarkUserStoreNeedsEmptyValue(tracked_pref_paths_[i]); | |
306 | |
307 const base::Value* value = prefs_->GetUserPrefValue(tracked_pref_paths_[i]); | 302 const base::Value* value = prefs_->GetUserPrefValue(tracked_pref_paths_[i]); |
308 std::string last_hash; | 303 std::string last_hash; |
309 // First try to get the stored expected hash... | 304 // First try to get the stored expected hash... |
310 if (hashed_prefs && | 305 if (hashed_prefs && |
311 hashed_prefs->GetString(tracked_pref_paths_[i], &last_hash)) { | 306 hashed_prefs->GetString(tracked_pref_paths_[i], &last_hash)) { |
312 // ... if we have one get the hash of the current value... | 307 // ... if we have one get the hash of the current value... |
313 const std::string value_hash = | 308 const std::string value_hash = |
314 GetHashedPrefValue(tracked_pref_paths_[i], value, | 309 GetHashedPrefValue(tracked_pref_paths_[i], value, |
315 HASHED_PREF_STYLE_NEW); | 310 HASHED_PREF_STYLE_NEW); |
316 // ... and check that it matches... | 311 // ... and check that it matches... |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 } | 460 } |
466 | 461 |
467 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { | 462 bool PrefMetricsService::Factory::ServiceIsNULLWhileTesting() const { |
468 return false; | 463 return false; |
469 } | 464 } |
470 | 465 |
471 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( | 466 content::BrowserContext* PrefMetricsService::Factory::GetBrowserContextToUse( |
472 content::BrowserContext* context) const { | 467 content::BrowserContext* context) const { |
473 return chrome::GetBrowserContextRedirectedInIncognito(context); | 468 return chrome::GetBrowserContextRedirectedInIncognito(context); |
474 } | 469 } |
OLD | NEW |