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

Unified Diff: chrome/browser/media/media_device_id_salt.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: change return type from const string to string as it makes no difference Created 4 years, 6 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 | « chrome/browser/media/media_device_id_salt.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/media_device_id_salt.cc
diff --git a/chrome/browser/media/media_device_id_salt.cc b/chrome/browser/media/media_device_id_salt.cc
index 2220418e031c0f21a713d886d5eacaaa2903f2f9..f8fcfcf4e294fde8338ae4809d946a449becdcaf 100644
--- a/chrome/browser/media/media_device_id_salt.cc
+++ b/chrome/browser/media/media_device_id_salt.cc
@@ -9,35 +9,18 @@
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/resource_context.h"
using content::BrowserThread;
-namespace {
-
-std::string CreateSalt() {
- std::string salt;
- base::Base64Encode(base::RandBytesAsString(16), &salt);
- DCHECK(!salt.empty());
- return salt;
-}
-
-} // namespace
-
-MediaDeviceIDSalt::MediaDeviceIDSalt(PrefService* pref_service,
- bool incognito) {
+MediaDeviceIDSalt::MediaDeviceIDSalt(PrefService* pref_service) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (incognito) {
- incognito_salt_ = CreateSalt();
- return;
- }
-
media_device_id_salt_.Init(prefs::kMediaDeviceIdSalt, pref_service);
- if (media_device_id_salt_.GetValue().empty())
- media_device_id_salt_.SetValue(CreateSalt());
-
- media_device_id_salt_.MoveToThread(
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO));
+ if (media_device_id_salt_.GetValue().empty()) {
+ media_device_id_salt_.SetValue(
+ content::ResourceContext::CreateRandomMediaDeviceIDSalt());
+ }
}
MediaDeviceIDSalt::~MediaDeviceIDSalt() {
@@ -45,14 +28,11 @@ MediaDeviceIDSalt::~MediaDeviceIDSalt() {
void MediaDeviceIDSalt::ShutdownOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- if (incognito_salt_.empty())
- media_device_id_salt_.Destroy();
+ media_device_id_salt_.Destroy();
}
std::string MediaDeviceIDSalt::GetSalt() const {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- if (incognito_salt_.size())
- return incognito_salt_;
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
return media_device_id_salt_.GetValue();
}
@@ -62,6 +42,7 @@ void MediaDeviceIDSalt::RegisterProfilePrefs(
}
void MediaDeviceIDSalt::Reset(PrefService* pref_service) {
- pref_service->SetString(prefs::kMediaDeviceIdSalt,
- CreateSalt());
+ pref_service->SetString(
+ prefs::kMediaDeviceIdSalt,
+ content::ResourceContext::CreateRandomMediaDeviceIDSalt());
}
« no previous file with comments | « chrome/browser/media/media_device_id_salt.h ('k') | chrome/browser/profiles/profile_io_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698