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