Chromium Code Reviews| Index: content/public/browser/media_device_id.cc |
| diff --git a/content/public/browser/media_device_id.cc b/content/public/browser/media_device_id.cc |
| index c2e2c3c09652960d97fcaf886493cd67bb35d84b..68d7ae94406fd8281b8504f0ec710fe777b13d6d 100644 |
| --- a/content/public/browser/media_device_id.cc |
| +++ b/content/public/browser/media_device_id.cc |
| @@ -6,30 +6,35 @@ |
| #include "base/logging.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_util.h" |
| +#include "content/public/browser/content_browser_client.h" |
| +#include "content/public/common/content_client.h" |
|
jam
2013/11/06 00:20:03
nit: remove these two
perkj_chrome
2013/11/28 21:42:14
Done.
|
| #include "crypto/hmac.h" |
| namespace content { |
| -std::string GetHMACForMediaDeviceID(const GURL& security_origin, |
| +std::string GetHMACForMediaDeviceID(ResourceContext* rc, |
| + const GURL& security_origin, |
| const std::string& raw_unique_id) { |
| DCHECK(security_origin.is_valid()); |
| DCHECK(!raw_unique_id.empty()); |
| crypto::HMAC hmac(crypto::HMAC::SHA256); |
| const size_t digest_length = hmac.DigestLength(); |
| std::vector<uint8> digest(digest_length); |
| + std::string salt = rc->GetMediaDeviceIDSalt(); |
| bool result = hmac.Init(security_origin.spec()) && |
| - hmac.Sign(raw_unique_id, &digest[0], digest.size()); |
| + hmac.Sign(raw_unique_id + salt, &digest[0], digest.size()); |
| DCHECK(result); |
| return StringToLowerASCII(base::HexEncode(&digest[0], digest.size())); |
| } |
| -bool DoesMediaDeviceIDMatchHMAC(const GURL& security_origin, |
| +bool DoesMediaDeviceIDMatchHMAC(ResourceContext* rc, |
| + const GURL& security_origin, |
| const std::string& device_guid, |
| const std::string& raw_unique_id) { |
| DCHECK(security_origin.is_valid()); |
| DCHECK(!raw_unique_id.empty()); |
| std::string guid_from_raw_device_id = |
| - GetHMACForMediaDeviceID(security_origin, raw_unique_id); |
| + GetHMACForMediaDeviceID(rc, security_origin, raw_unique_id); |
| return guid_from_raw_device_id == device_guid; |
| } |