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/file_util.h" | 7 #include "base/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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size(); | 155 LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size(); |
156 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); | 156 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); |
157 return; | 157 return; |
158 } | 158 } |
159 | 159 |
160 char id_buf[256 / 8]; // 256-bits for SHA256 | 160 char id_buf[256 / 8]; // 256-bits for SHA256 |
161 std::string input = machine_id; | 161 std::string input = machine_id; |
162 input.append(kDRMIdentifierFile); | 162 input.append(kDRMIdentifierFile); |
163 input.append(salt_bytes.begin(), salt_bytes.end()); | 163 input.append(salt_bytes.begin(), salt_bytes.end()); |
164 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); | 164 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); |
165 std::string id = StringToLowerASCII( | 165 std::string id = base::StringToLowerASCII( |
166 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); | 166 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); |
167 input = machine_id; | 167 input = machine_id; |
168 input.append(kDRMIdentifierFile); | 168 input.append(kDRMIdentifierFile); |
169 input.append(id); | 169 input.append(id); |
170 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); | 170 crypto::SHA256HashString(input, &id_buf, sizeof(id_buf)); |
171 id = StringToLowerASCII( | 171 id = base::StringToLowerASCII( |
172 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); | 172 base::HexEncode(reinterpret_cast<const void*>(id_buf), sizeof(id_buf))); |
173 | 173 |
174 RunCallbackOnIOThread(id, PP_OK); | 174 RunCallbackOnIOThread(id, PP_OK); |
175 } | 175 } |
176 | 176 |
177 // TODO(raymes): This is temporary code to migrate ChromeOS devices to the new | 177 // TODO(raymes): This is temporary code to migrate ChromeOS devices to the new |
178 // scheme for generating device IDs. Delete this once we are sure most ChromeOS | 178 // scheme for generating device IDs. Delete this once we are sure most ChromeOS |
179 // devices have been migrated. | 179 // devices have been migrated. |
180 void DeviceIDFetcher::LegacyComputeOnBlockingPool( | 180 void DeviceIDFetcher::LegacyComputeOnBlockingPool( |
181 const base::FilePath& profile_path, | 181 const base::FilePath& profile_path, |
(...skipping 24 matching lines...) Expand all Loading... |
206 BrowserThread::IO, | 206 BrowserThread::IO, |
207 FROM_HERE, | 207 FROM_HERE, |
208 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); | 208 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); |
209 return; | 209 return; |
210 } | 210 } |
211 in_progress_ = false; | 211 in_progress_ = false; |
212 callback_.Run(id, result); | 212 callback_.Run(id, result); |
213 } | 213 } |
214 | 214 |
215 } // namespace chrome | 215 } // namespace chrome |
OLD | NEW |