OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/renderer_host/pepper/device_id_fetcher.h" | 5 #include "chrome/browser/renderer_host/pepper/device_id_fetcher.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size(); | 152 LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size(); |
153 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); | 153 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); |
154 return; | 154 return; |
155 } | 155 } |
156 | 156 |
157 char id_buf[256 / 8]; // 256-bits for SHA256 | 157 char id_buf[256 / 8]; // 256-bits for SHA256 |
158 std::string input = machine_id; | 158 std::string input = machine_id; |
159 input.append(kDRMIdentifierFile); | 159 input.append(kDRMIdentifierFile); |
160 input.append(salt_bytes.begin(), salt_bytes.end()); | 160 input.append(salt_bytes.begin(), salt_bytes.end()); |
161 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); | 161 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); |
162 std::string id = base::StringToLowerASCII( | 162 std::string id = base::ToLowerASCII( |
163 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); | 163 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); |
164 input = machine_id; | 164 input = machine_id; |
165 input.append(kDRMIdentifierFile); | 165 input.append(kDRMIdentifierFile); |
166 input.append(id); | 166 input.append(id); |
167 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); | 167 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); |
168 id = base::StringToLowerASCII( | 168 id = base::ToLowerASCII( |
169 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); | 169 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); |
170 | 170 |
171 RunCallbackOnIOThread(id, PP_OK); | 171 RunCallbackOnIOThread(id, PP_OK); |
172 } | 172 } |
173 | 173 |
174 // TODO(raymes): This is temporary code to migrate ChromeOS devices to the new | 174 // TODO(raymes): This is temporary code to migrate ChromeOS devices to the new |
175 // scheme for generating device IDs. Delete this once we are sure most ChromeOS | 175 // scheme for generating device IDs. Delete this once we are sure most ChromeOS |
176 // devices have been migrated. | 176 // devices have been migrated. |
177 void DeviceIDFetcher::LegacyComputeOnBlockingPool( | 177 void DeviceIDFetcher::LegacyComputeOnBlockingPool( |
178 const base::FilePath& profile_path, | 178 const base::FilePath& profile_path, |
(...skipping 24 matching lines...) Expand all Loading... |
203 BrowserThread::IO, | 203 BrowserThread::IO, |
204 FROM_HERE, | 204 FROM_HERE, |
205 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); | 205 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); |
206 return; | 206 return; |
207 } | 207 } |
208 in_progress_ = false; | 208 in_progress_ = false; |
209 callback_.Run(id, result); | 209 callback_.Run(id, result); |
210 } | 210 } |
211 | 211 |
212 } // namespace chrome | 212 } // namespace chrome |
OLD | NEW |