| 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/macros.h" |
| 8 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "build/build_config.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 12 #if defined(OS_CHROMEOS) | 14 #if defined(OS_CHROMEOS) |
| 13 #include "chromeos/cryptohome/system_salt_getter.h" | 15 #include "chromeos/cryptohome/system_salt_getter.h" |
| 14 #endif | 16 #endif |
| 15 #include "components/pref_registry/pref_registry_syncable.h" | 17 #include "components/pref_registry/pref_registry_syncable.h" |
| 16 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/browser_ppapi_host.h" | 19 #include "content/public/browser/browser_ppapi_host.h" |
| 18 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 140 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 139 | 141 |
| 140 if (machine_id.empty()) { | 142 if (machine_id.empty()) { |
| 141 LOG(ERROR) << "Empty machine id"; | 143 LOG(ERROR) << "Empty machine id"; |
| 142 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); | 144 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); |
| 143 return; | 145 return; |
| 144 } | 146 } |
| 145 | 147 |
| 146 // Build the identifier as follows: | 148 // Build the identifier as follows: |
| 147 // SHA256(machine-id||service||SHA256(machine-id||service||salt)) | 149 // SHA256(machine-id||service||SHA256(machine-id||service||salt)) |
| 148 std::vector<uint8> salt_bytes; | 150 std::vector<uint8_t> salt_bytes; |
| 149 if (!base::HexStringToBytes(salt, &salt_bytes)) | 151 if (!base::HexStringToBytes(salt, &salt_bytes)) |
| 150 salt_bytes.clear(); | 152 salt_bytes.clear(); |
| 151 if (salt_bytes.size() != kSaltLength) { | 153 if (salt_bytes.size() != kSaltLength) { |
| 152 LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size(); | 154 LOG(ERROR) << "Unexpected salt bytes length: " << salt_bytes.size(); |
| 153 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); | 155 RunCallbackOnIOThread(std::string(), PP_ERROR_FAILED); |
| 154 return; | 156 return; |
| 155 } | 157 } |
| 156 | 158 |
| 157 char id_buf[256 / 8]; // 256-bits for SHA256 | 159 char id_buf[256 / 8]; // 256-bits for SHA256 |
| 158 std::string input = machine_id; | 160 std::string input = machine_id; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 BrowserThread::IO, | 205 BrowserThread::IO, |
| 204 FROM_HERE, | 206 FROM_HERE, |
| 205 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); | 207 base::Bind(&DeviceIDFetcher::RunCallbackOnIOThread, this, id, result)); |
| 206 return; | 208 return; |
| 207 } | 209 } |
| 208 in_progress_ = false; | 210 in_progress_ = false; |
| 209 callback_.Run(id, result); | 211 callback_.Run(id, result); |
| 210 } | 212 } |
| 211 | 213 |
| 212 } // namespace chrome | 214 } // namespace chrome |
| OLD | NEW |