OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 #include "chrome/browser/media/media_device_id_salt.h" | 4 #include "chrome/browser/media/media_device_id_salt.h" |
5 | 5 |
6 #include "base/base64.h" | 6 #include "base/base64.h" |
7 #include "base/rand_util.h" | 7 #include "base/rand_util.h" |
8 #include "chrome/browser/profiles/profile_io_data.h" | 8 #include "chrome/browser/profiles/profile_io_data.h" |
9 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
10 #include "components/prefs/pref_service.h" | 10 #include "components/prefs/pref_service.h" |
| 11 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
12 #include "content/public/browser/resource_context.h" | |
13 | 13 |
14 using content::BrowserThread; | 14 using content::BrowserThread; |
15 | 15 |
16 MediaDeviceIDSalt::MediaDeviceIDSalt(PrefService* pref_service) { | 16 MediaDeviceIDSalt::MediaDeviceIDSalt(PrefService* pref_service) { |
17 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 17 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
18 | 18 |
19 media_device_id_salt_.Init(prefs::kMediaDeviceIdSalt, pref_service); | 19 media_device_id_salt_.Init(prefs::kMediaDeviceIdSalt, pref_service); |
20 if (media_device_id_salt_.GetValue().empty()) { | 20 if (media_device_id_salt_.GetValue().empty()) { |
21 media_device_id_salt_.SetValue( | 21 media_device_id_salt_.SetValue( |
22 content::ResourceContext::CreateRandomMediaDeviceIDSalt()); | 22 content::BrowserContext::CreateRandomMediaDeviceIDSalt()); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 MediaDeviceIDSalt::~MediaDeviceIDSalt() { | 26 MediaDeviceIDSalt::~MediaDeviceIDSalt() { |
27 } | 27 } |
28 | 28 |
29 void MediaDeviceIDSalt::ShutdownOnUIThread() { | |
30 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
31 media_device_id_salt_.Destroy(); | |
32 } | |
33 | |
34 std::string MediaDeviceIDSalt::GetSalt() const { | 29 std::string MediaDeviceIDSalt::GetSalt() const { |
35 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 30 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
36 return media_device_id_salt_.GetValue(); | 31 return media_device_id_salt_.GetValue(); |
37 } | 32 } |
38 | 33 |
39 void MediaDeviceIDSalt::RegisterProfilePrefs( | 34 void MediaDeviceIDSalt::RegisterProfilePrefs( |
40 user_prefs::PrefRegistrySyncable* registry) { | 35 user_prefs::PrefRegistrySyncable* registry) { |
41 registry->RegisterStringPref(prefs::kMediaDeviceIdSalt, std::string()); | 36 registry->RegisterStringPref(prefs::kMediaDeviceIdSalt, std::string()); |
42 } | 37 } |
43 | 38 |
44 void MediaDeviceIDSalt::Reset(PrefService* pref_service) { | 39 void MediaDeviceIDSalt::Reset(PrefService* pref_service) { |
45 pref_service->SetString( | 40 pref_service->SetString( |
46 prefs::kMediaDeviceIdSalt, | 41 prefs::kMediaDeviceIdSalt, |
47 content::ResourceContext::CreateRandomMediaDeviceIDSalt()); | 42 content::BrowserContext::CreateRandomMediaDeviceIDSalt()); |
48 } | 43 } |
OLD | NEW |