| 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" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 &public_key); | 45 &public_key); |
| 46 return public_key; | 46 return public_key; |
| 47 } | 47 } |
| 48 | 48 |
| 49 std::string ProximityAuthPrefManager::GetDeviceAddress( | 49 std::string ProximityAuthPrefManager::GetDeviceAddress( |
| 50 const std::string& public_key) const { | 50 const std::string& public_key) const { |
| 51 const base::DictionaryValue* remote_ble_devices = GetRemoteBleDevices(); | 51 const base::DictionaryValue* remote_ble_devices = GetRemoteBleDevices(); |
| 52 for (base::DictionaryValue::Iterator it(*remote_ble_devices); !it.IsAtEnd(); | 52 for (base::DictionaryValue::Iterator it(*remote_ble_devices); !it.IsAtEnd(); |
| 53 it.Advance()) { | 53 it.Advance()) { |
| 54 std::string value_string; | 54 std::string value_string; |
| 55 DCHECK(it.value().IsType(base::Value::TYPE_STRING)); | 55 DCHECK(it.value().IsType(base::Value::Type::STRING)); |
| 56 if (it.value().GetAsString(&value_string) && value_string == public_key) | 56 if (it.value().GetAsString(&value_string) && value_string == public_key) |
| 57 return it.key(); | 57 return it.key(); |
| 58 } | 58 } |
| 59 return std::string(); | 59 return std::string(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::vector<std::string> ProximityAuthPrefManager::GetPublicKeys() const { | 62 std::vector<std::string> ProximityAuthPrefManager::GetPublicKeys() const { |
| 63 std::vector<std::string> public_keys; | 63 std::vector<std::string> public_keys; |
| 64 const base::DictionaryValue* remote_ble_devices = GetRemoteBleDevices(); | 64 const base::DictionaryValue* remote_ble_devices = GetRemoteBleDevices(); |
| 65 for (base::DictionaryValue::Iterator it(*remote_ble_devices); !it.IsAtEnd(); | 65 for (base::DictionaryValue::Iterator it(*remote_ble_devices); !it.IsAtEnd(); |
| 66 it.Advance()) { | 66 it.Advance()) { |
| 67 std::string value_string; | 67 std::string value_string; |
| 68 DCHECK(it.value().IsType(base::Value::TYPE_STRING)); | 68 DCHECK(it.value().IsType(base::Value::Type::STRING)); |
| 69 it.value().GetAsString(&value_string); | 69 it.value().GetAsString(&value_string); |
| 70 public_keys.push_back(value_string); | 70 public_keys.push_back(value_string); |
| 71 } | 71 } |
| 72 return public_keys; | 72 return public_keys; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ProximityAuthPrefManager::AddOrUpdateDevice( | 75 void ProximityAuthPrefManager::AddOrUpdateDevice( |
| 76 const std::string& bluetooth_address, | 76 const std::string& bluetooth_address, |
| 77 const std::string& public_key) { | 77 const std::string& public_key) { |
| 78 PA_LOG(INFO) << "Adding " << public_key << " , " << bluetooth_address | 78 PA_LOG(INFO) << "Adding " << public_key << " , " << bluetooth_address |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 const std::string& public_key) { | 103 const std::string& public_key) { |
| 104 return RemoveDeviceWithAddress(GetDeviceAddress(public_key)); | 104 return RemoveDeviceWithAddress(GetDeviceAddress(public_key)); |
| 105 } | 105 } |
| 106 | 106 |
| 107 const base::DictionaryValue* ProximityAuthPrefManager::GetRemoteBleDevices() | 107 const base::DictionaryValue* ProximityAuthPrefManager::GetRemoteBleDevices() |
| 108 const { | 108 const { |
| 109 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices); | 109 return pref_service_->GetDictionary(prefs::kProximityAuthRemoteBleDevices); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace proximity_auth | 112 } // namespace proximity_auth |
| OLD | NEW |