Chromium Code Reviews| 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..4528684370eef417f6a945e00d8e0a0a27dfe16f 100644 |
| --- a/chrome/browser/media/media_device_id_salt.cc |
| +++ b/chrome/browser/media/media_device_id_salt.cc |
| @@ -9,32 +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()); |
| + if (media_device_id_salt_.GetValue().empty()) { |
|
jam
2016/06/14 16:20:33
i'm confused, the cl description says "This result
Guido Urdaneta
2016/06/14 17:30:57
Clarified via IM and in the updated CL description
|
| + media_device_id_salt_.SetValue( |
| + content::ResourceContext::CreateRandomMediaDeviceIDSalt()); |
| + } |
| media_device_id_salt_.MoveToThread( |
| BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| @@ -45,14 +31,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_; |
| return media_device_id_salt_.GetValue(); |
| } |
| @@ -62,6 +45,7 @@ void MediaDeviceIDSalt::RegisterProfilePrefs( |
| } |
| void MediaDeviceIDSalt::Reset(PrefService* pref_service) { |
| - pref_service->SetString(prefs::kMediaDeviceIdSalt, |
| - CreateSalt()); |
| + pref_service->SetString( |
| + prefs::kMediaDeviceIdSalt, |
| + content::ResourceContext::CreateRandomMediaDeviceIDSalt()); |
| } |