Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 4 |
| 5 #include "components/proximity_auth/proximity_auth_pref_manager.h" | 5 #include "components/proximity_auth/proximity_auth_pref_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/common/pref_names.h" | |
|
Tim Song
2017/07/11 23:45:57
We shouldn't depend on anything from chrome/.
sacomoto
2017/07/12 15:52:52
Done.
| |
| 13 #include "components/pref_registry/pref_registry_syncable.h" | |
| 12 #include "components/prefs/pref_registry_simple.h" | 14 #include "components/prefs/pref_registry_simple.h" |
| 13 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 14 #include "components/prefs/scoped_user_pref_update.h" | 16 #include "components/prefs/scoped_user_pref_update.h" |
| 15 #include "components/proximity_auth/logging/logging.h" | 17 #include "components/proximity_auth/logging/logging.h" |
| 16 #include "components/proximity_auth/proximity_auth_pref_names.h" | 18 #include "components/proximity_auth/proximity_auth_pref_names.h" |
| 17 | 19 |
| 18 namespace proximity_auth { | 20 namespace proximity_auth { |
| 19 | 21 |
| 20 ProximityAuthPrefManager::ProximityAuthPrefManager(PrefService* pref_service) | 22 ProximityAuthPrefManager::ProximityAuthPrefManager(PrefService* pref_service) |
| 21 : pref_service_(pref_service) {} | 23 : pref_service_(pref_service) {} |
| 22 | 24 |
| 23 ProximityAuthPrefManager::~ProximityAuthPrefManager() {} | 25 ProximityAuthPrefManager::~ProximityAuthPrefManager() {} |
| 24 | 26 |
| 25 // static | 27 // static |
| 26 void ProximityAuthPrefManager::RegisterPrefs(PrefRegistrySimple* registry) { | 28 void ProximityAuthPrefManager::RegisterPrefs(PrefRegistrySimple* registry) { |
|
Tim Song
2017/07/11 23:45:57
We should take a PrefRegistrySyncable here to be m
sacomoto
2017/07/12 15:52:53
Done.
| |
| 27 registry->RegisterInt64Pref(prefs::kProximityAuthLastPasswordEntryTimestampMs, | 29 registry->RegisterInt64Pref(prefs::kProximityAuthLastPasswordEntryTimestampMs, |
| 28 0L); | 30 0L); |
| 29 registry->RegisterDictionaryPref(prefs::kProximityAuthRemoteBleDevices); | 31 registry->RegisterDictionaryPref(prefs::kProximityAuthRemoteBleDevices); |
| 32 registry->RegisterIntegerPref( | |
| 33 ::prefs::kEasyUnlockProximityThreshold, 1, | |
|
Tim Song
2017/07/11 23:45:57
Move this to proximity_auth_pref_names in the comp
sacomoto
2017/07/12 15:52:53
Done.
| |
| 34 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 30 } | 35 } |
| 31 | 36 |
| 32 bool ProximityAuthPrefManager::HasDeviceWithAddress( | 37 bool ProximityAuthPrefManager::HasDeviceWithAddress( |
| 33 const std::string& bluetooth_address) const { | 38 const std::string& bluetooth_address) const { |
| 34 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices) | 39 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices) |
| 35 ->HasKey(bluetooth_address); | 40 ->HasKey(bluetooth_address); |
| 36 } | 41 } |
| 37 | 42 |
| 38 bool ProximityAuthPrefManager::HasDeviceWithPublicKey( | 43 bool ProximityAuthPrefManager::HasDeviceWithPublicKey( |
| 39 const std::string& public_key) const { | 44 const std::string& public_key) const { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 int64_t ProximityAuthPrefManager::GetLastPasswordEntryTimestampMs() const { | 119 int64_t ProximityAuthPrefManager::GetLastPasswordEntryTimestampMs() const { |
| 115 return pref_service_->GetInt64( | 120 return pref_service_->GetInt64( |
| 116 prefs::kProximityAuthLastPasswordEntryTimestampMs); | 121 prefs::kProximityAuthLastPasswordEntryTimestampMs); |
| 117 } | 122 } |
| 118 | 123 |
| 119 const base::DictionaryValue* ProximityAuthPrefManager::GetRemoteBleDevices() | 124 const base::DictionaryValue* ProximityAuthPrefManager::GetRemoteBleDevices() |
| 120 const { | 125 const { |
| 121 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices); | 126 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices); |
| 122 } | 127 } |
| 123 | 128 |
| 129 void ProximityAuthPrefManager::SetProximityThreshold(ProximityThreshold value) { | |
| 130 pref_service_->SetInteger(::prefs::kEasyUnlockProximityThreshold, value); | |
| 131 } | |
| 132 | |
| 133 ProximityAuthPrefManager::ProximityThreshold | |
| 134 ProximityAuthPrefManager::GetProximityThreshold() const { | |
| 135 int pref_value = | |
| 136 pref_service_->GetInteger(::prefs::kEasyUnlockProximityThreshold); | |
| 137 return static_cast<ProximityThreshold>(pref_value); | |
| 138 } | |
| 139 | |
| 124 } // namespace proximity_auth | 140 } // namespace proximity_auth |
| OLD | NEW |