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/extensions/api/music_manager_private/device_id.h" | 5 #include "chrome/browser/extensions/api/music_manager_private/device_id.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (result) { | 26 if (result) { |
27 *signature_return = StringToLowerASCII(base::HexEncode(digest.data(), | 27 *signature_return = StringToLowerASCII(base::HexEncode(digest.data(), |
28 digest.size())); | 28 digest.size())); |
29 } | 29 } |
30 return result; | 30 return result; |
31 } | 31 } |
32 | 32 |
33 void GetRawDeviceIdCallback(const std::string& extension_id, | 33 void GetRawDeviceIdCallback(const std::string& extension_id, |
34 const DeviceId::IdCallback& callback, | 34 const DeviceId::IdCallback& callback, |
35 const std::string& raw_device_id) { | 35 const std::string& raw_device_id) { |
36 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
37 | 37 |
38 if (raw_device_id.empty()) { | 38 if (raw_device_id.empty()) { |
39 callback.Run(""); | 39 callback.Run(""); |
40 return; | 40 return; |
41 } | 41 } |
42 | 42 |
43 std::string device_id; | 43 std::string device_id; |
44 if (!ComputeHmacSha256(raw_device_id, extension_id, &device_id)) { | 44 if (!ComputeHmacSha256(raw_device_id, extension_id, &device_id)) { |
45 DLOG(ERROR) << "Error while computing HMAC-SHA256 of device id."; | 45 DLOG(ERROR) << "Error while computing HMAC-SHA256 of device id."; |
46 callback.Run(""); | 46 callback.Run(""); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 172 } |
173 | 173 |
174 } // namespace | 174 } // namespace |
175 | 175 |
176 namespace extensions { | 176 namespace extensions { |
177 namespace api { | 177 namespace api { |
178 | 178 |
179 // static | 179 // static |
180 void DeviceId::GetDeviceId(const std::string& extension_id, | 180 void DeviceId::GetDeviceId(const std::string& extension_id, |
181 const IdCallback& callback) { | 181 const IdCallback& callback) { |
182 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 182 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
183 CHECK(!extension_id.empty()); | 183 CHECK(!extension_id.empty()); |
184 | 184 |
185 // Forward call to platform specific implementation, then compute the HMAC | 185 // Forward call to platform specific implementation, then compute the HMAC |
186 // in the callback. | 186 // in the callback. |
187 GetRawDeviceId(base::Bind(&GetRawDeviceIdCallback, extension_id, callback)); | 187 GetRawDeviceId(base::Bind(&GetRawDeviceIdCallback, extension_id, callback)); |
188 } | 188 } |
189 | 189 |
190 // static | 190 // static |
191 bool DeviceId::IsValidMacAddress(const void* bytes, size_t size) { | 191 bool DeviceId::IsValidMacAddress(const void* bytes, size_t size) { |
192 return IsValidMacAddressImpl(bytes, size); | 192 return IsValidMacAddressImpl(bytes, size); |
193 } | 193 } |
194 | 194 |
195 } // namespace api | 195 } // namespace api |
196 } // namespace extensions | 196 } // namespace extensions |
OLD | NEW |