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

Unified Diff: content/browser/resource_context_impl.cc

Issue 1987643002: Make default media device ID salts random by default (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: content/browser/resource_context_impl.cc
diff --git a/content/browser/resource_context_impl.cc b/content/browser/resource_context_impl.cc
index e7aa29b9570d5706018be8032db33507b15392f9..7808a26e4eb956812f0f0291eec8ce2042c641b0 100644
--- a/content/browser/resource_context_impl.cc
+++ b/content/browser/resource_context_impl.cc
@@ -6,9 +6,13 @@
#include <stdint.h>
+#include <string>
+
+#include "base/base64.h"
#include "base/bind.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
+#include "base/rand_util.h"
#include "content/browser/blob_storage/chrome_blob_storage_context.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/loader/resource_request_info_impl.h"
@@ -30,9 +34,8 @@ const char kBlobStorageContextKeyName[] = "content_blob_storage_context";
const char kStreamContextKeyName[] = "content_stream_context";
const char kURLDataManagerBackendKeyName[] = "url_data_manager_backend";
-// Used by the default implementation of GetMediaDeviceIDSalt, below.
-std::string ReturnEmptySalt() {
- return std::string();
+std::string GetSalt(const std::string& salt) {
+ return salt;
}
} // namespace
@@ -60,7 +63,7 @@ ResourceContext::~ResourceContext() {
}
ResourceContext::SaltCallback ResourceContext::GetMediaDeviceIDSalt() {
- return base::Bind(&ReturnEmptySalt);
+ return base::Bind(&GetSalt, std::string());
}
std::unique_ptr<net::ClientCertStore> ResourceContext::CreateClientCertStore() {
@@ -76,6 +79,20 @@ void ResourceContext::CreateKeygenHandler(
new net::KeygenHandler(key_size_in_bits, challenge_string, url)));
}
+// static
+std::string ResourceContext::CreateRandomMediaDeviceIDSalt() {
+ std::string salt;
+ base::Base64Encode(base::RandBytesAsString(16), &salt);
+ DCHECK(!salt.empty());
+ return salt;
+}
+
+// static
+ResourceContext::SaltCallback ResourceContext::CreateSaltCallback(
+ const std::string& salt) {
+ return base::Bind(GetSalt, salt);
+}
+
ChromeBlobStorageContext* GetChromeBlobStorageContextForResourceContext(
const ResourceContext* resource_context) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);

Powered by Google App Engine
This is Rietveld 408576698