[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / media_device_salt / media_device_id_salt.cc
1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/media_device_salt/media_device_id_salt.h"
6
7 #include "base/base64.h"
8 #include "base/rand_util.h"
9 #include "base/system/system_monitor.h"
10 #include "components/prefs/pref_service.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/media_device_id.h"
13
14 using content::BrowserThread;
15
16 namespace media_device_salt {
17
18 namespace prefs {
19 const char kMediaDeviceIdSalt[] = "media.device_id_salt";
20 }
21
22 MediaDeviceIDSalt::MediaDeviceIDSalt(PrefService* pref_service) {
23   DCHECK_CURRENTLY_ON(BrowserThread::UI);
24
25   media_device_id_salt_.Init(prefs::kMediaDeviceIdSalt, pref_service);
26   if (media_device_id_salt_.GetValue().empty()) {
27     media_device_id_salt_.SetValue(base::UnguessableToken::Create().ToString());
28   }
29 }
30
31 MediaDeviceIDSalt::~MediaDeviceIDSalt() = default;
32
33 std::string MediaDeviceIDSalt::GetSalt() const {
34   DCHECK_CURRENTLY_ON(BrowserThread::UI);
35   return media_device_id_salt_.GetValue();
36 }
37
38 void MediaDeviceIDSalt::RegisterProfilePrefs(
39     user_prefs::PrefRegistrySyncable* registry) {
40   registry->RegisterStringPref(prefs::kMediaDeviceIdSalt, std::string());
41 }
42
43 void MediaDeviceIDSalt::Reset(PrefService* pref_service) {
44   pref_service->SetString(prefs::kMediaDeviceIdSalt,
45                           base::UnguessableToken::Create().ToString());
46 }
47
48 }  // namespace media_device_salt