| 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 "components/user_prefs/tracked/pref_hash_calculator.h" | 5 #include "components/user_prefs/tracked/pref_hash_calculator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 // Generates a device ID based on the input device ID. The derived device ID has | 79 // Generates a device ID based on the input device ID. The derived device ID has |
| 80 // no useful properties beyond those of the input device ID except that it is | 80 // no useful properties beyond those of the input device ID except that it is |
| 81 // consistent with previous implementations. | 81 // consistent with previous implementations. |
| 82 // TODO(gab): Remove this once UMA reports for | 82 // TODO(gab): Remove this once UMA reports for |
| 83 // Settings.TrackedPreferenceMigratedLegacyDeviceId become insignificant. | 83 // Settings.TrackedPreferenceMigratedLegacyDeviceId become insignificant. |
| 84 std::string GenerateDeviceIdLikePrefMetricsServiceDid( | 84 std::string GenerateDeviceIdLikePrefMetricsServiceDid( |
| 85 const std::string& original_device_id) { | 85 const std::string& original_device_id) { |
| 86 if (original_device_id.empty()) | 86 if (original_device_id.empty()) |
| 87 return std::string(); | 87 return std::string(); |
| 88 return base::StringToLowerASCII( | 88 return base::ToLowerASCII( |
| 89 GetDigestString(original_device_id, "PrefMetricsService")); | 89 GetDigestString(original_device_id, "PrefMetricsService")); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace | 92 } // namespace |
| 93 | 93 |
| 94 PrefHashCalculator::PrefHashCalculator(const std::string& seed, | 94 PrefHashCalculator::PrefHashCalculator(const std::string& seed, |
| 95 const std::string& device_id) | 95 const std::string& device_id) |
| 96 : seed_(seed), | 96 : seed_(seed), |
| 97 device_id_(device_id), | 97 device_id_(device_id), |
| 98 legacy_device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) { | 98 legacy_device_id_(GenerateDeviceIdLikePrefMetricsServiceDid(device_id)) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 116 digest_string)) { | 116 digest_string)) { |
| 117 return VALID; | 117 return VALID; |
| 118 } | 118 } |
| 119 if (VerifyDigestString(seed_, | 119 if (VerifyDigestString(seed_, |
| 120 GetMessage(legacy_device_id_, path, value_as_string), | 120 GetMessage(legacy_device_id_, path, value_as_string), |
| 121 digest_string)) { | 121 digest_string)) { |
| 122 return VALID_SECURE_LEGACY; | 122 return VALID_SECURE_LEGACY; |
| 123 } | 123 } |
| 124 return INVALID; | 124 return INVALID; |
| 125 } | 125 } |
| OLD | NEW |