Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1089)

Unified Diff: content/public/browser/media_device_id.cc

Issue 143003031: Allow retrieval of media device ID salt even after ResourceContext has gone away. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add TODO about proper fix. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/media_device_id.h ('k') | content/public/browser/resource_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24709b2d443d203be5a799888348899176330091..65ac7e2dc4446635a7b73b86ea3f492fedfad2c6 100644
--- a/content/public/browser/media_device_id.cc
+++ b/content/public/browser/media_device_id.cc
@@ -6,12 +6,11 @@
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
-#include "content/public/browser/resource_context.h"
#include "crypto/hmac.h"
namespace content {
-std::string GetHMACForMediaDeviceID(ResourceContext* rc,
+std::string GetHMACForMediaDeviceID(const ResourceContext::SaltCallback& sc,
const GURL& security_origin,
const std::string& raw_unique_id) {
DCHECK(security_origin.is_valid());
@@ -19,21 +18,21 @@ std::string GetHMACForMediaDeviceID(ResourceContext* rc,
crypto::HMAC hmac(crypto::HMAC::SHA256);
const size_t digest_length = hmac.DigestLength();
std::vector<uint8> digest(digest_length);
- std::string salt = rc->GetMediaDeviceIDSalt();
+ std::string salt = sc.Run();
bool result = hmac.Init(security_origin.spec()) &&
hmac.Sign(raw_unique_id + salt, &digest[0], digest.size());
DCHECK(result);
return StringToLowerASCII(base::HexEncode(&digest[0], digest.size()));
}
-bool DoesMediaDeviceIDMatchHMAC(ResourceContext* rc,
+bool DoesMediaDeviceIDMatchHMAC(const ResourceContext::SaltCallback& sc,
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(rc, security_origin, raw_unique_id);
+ GetHMACForMediaDeviceID(sc, security_origin, raw_unique_id);
return guid_from_raw_device_id == device_guid;
}
« no previous file with comments | « content/public/browser/media_device_id.h ('k') | content/public/browser/resource_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698