| 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 "components/prefs/pref_registry_simple.h" | 12 #include "components/prefs/pref_registry_simple.h" |
| 13 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
| 14 #include "components/prefs/scoped_user_pref_update.h" | 14 #include "components/prefs/scoped_user_pref_update.h" |
| 15 #include "components/proximity_auth/logging/logging.h" | 15 #include "components/proximity_auth/logging/logging.h" |
| 16 #include "components/proximity_auth/proximity_auth_pref_names.h" | 16 #include "components/proximity_auth/proximity_auth_pref_names.h" |
| 17 | 17 |
| 18 namespace proximity_auth { | 18 namespace proximity_auth { |
| 19 | 19 |
| 20 ProximityAuthPrefManager::ProximityAuthPrefManager(PrefService* pref_service) | 20 ProximityAuthPrefManager::ProximityAuthPrefManager(PrefService* pref_service) |
| 21 : pref_service_(pref_service) {} | 21 : pref_service_(pref_service) {} |
| 22 | 22 |
| 23 ProximityAuthPrefManager::~ProximityAuthPrefManager() {} | 23 ProximityAuthPrefManager::~ProximityAuthPrefManager() {} |
| 24 | 24 |
| 25 // static | 25 // static |
| 26 void ProximityAuthPrefManager::RegisterPrefs(PrefRegistrySimple* registry) { | 26 void ProximityAuthPrefManager::RegisterPrefs(PrefRegistrySimple* registry) { |
| 27 registry->RegisterInt64Pref(prefs::kProximityAuthLastPasswordEntryTimestampMs, |
| 28 0L); |
| 27 registry->RegisterDictionaryPref(prefs::kProximityAuthRemoteBleDevices); | 29 registry->RegisterDictionaryPref(prefs::kProximityAuthRemoteBleDevices); |
| 28 } | 30 } |
| 29 | 31 |
| 30 bool ProximityAuthPrefManager::HasDeviceWithAddress( | 32 bool ProximityAuthPrefManager::HasDeviceWithAddress( |
| 31 const std::string& bluetooth_address) const { | 33 const std::string& bluetooth_address) const { |
| 32 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices) | 34 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices) |
| 33 ->HasKey(bluetooth_address); | 35 ->HasKey(bluetooth_address); |
| 34 } | 36 } |
| 35 | 37 |
| 36 bool ProximityAuthPrefManager::HasDeviceWithPublicKey( | 38 bool ProximityAuthPrefManager::HasDeviceWithPublicKey( |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 DictionaryPrefUpdate remote_ble_devices_update( | 98 DictionaryPrefUpdate remote_ble_devices_update( |
| 97 pref_service_, prefs::kProximityAuthRemoteBleDevices); | 99 pref_service_, prefs::kProximityAuthRemoteBleDevices); |
| 98 return remote_ble_devices_update->RemoveWithoutPathExpansion( | 100 return remote_ble_devices_update->RemoveWithoutPathExpansion( |
| 99 bluetooth_address, nullptr); | 101 bluetooth_address, nullptr); |
| 100 } | 102 } |
| 101 | 103 |
| 102 bool ProximityAuthPrefManager::RemoveDeviceWithPublicKey( | 104 bool ProximityAuthPrefManager::RemoveDeviceWithPublicKey( |
| 103 const std::string& public_key) { | 105 const std::string& public_key) { |
| 104 return RemoveDeviceWithAddress(GetDeviceAddress(public_key)); | 106 return RemoveDeviceWithAddress(GetDeviceAddress(public_key)); |
| 105 } | 107 } |
| 108 void ProximityAuthPrefManager::SetLastPasswordEntryTimestampMs( |
| 109 int64_t timestamp_ms) { |
| 110 pref_service_->SetInt64(prefs::kProximityAuthLastPasswordEntryTimestampMs, |
| 111 timestamp_ms); |
| 112 } |
| 113 |
| 114 int64_t ProximityAuthPrefManager::GetLastPasswordEntryTimestampMs() { |
| 115 return pref_service_->GetInt64( |
| 116 prefs::kProximityAuthLastPasswordEntryTimestampMs); |
| 117 } |
| 106 | 118 |
| 107 const base::DictionaryValue* ProximityAuthPrefManager::GetRemoteBleDevices() | 119 const base::DictionaryValue* ProximityAuthPrefManager::GetRemoteBleDevices() |
| 108 const { | 120 const { |
| 109 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices); | 121 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices); |
| 110 } | 122 } |
| 111 | 123 |
| 112 } // namespace proximity_auth | 124 } // namespace proximity_auth |
| OLD | NEW |