Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/prefs/scoped_user_pref_update.h ('k') | components/proximity_auth/messenger_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ble/bluetooth_low_energy_device_whitelist.h" 5 #include "components/proximity_auth/ble/bluetooth_low_energy_device_whitelist.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 &public_key); 48 &public_key);
49 return public_key; 49 return public_key;
50 } 50 }
51 51
52 std::string BluetoothLowEnergyDeviceWhitelist::GetDeviceAddress( 52 std::string BluetoothLowEnergyDeviceWhitelist::GetDeviceAddress(
53 const std::string& public_key) const { 53 const std::string& public_key) const {
54 const base::DictionaryValue* device_whitelist = GetWhitelistPrefs(); 54 const base::DictionaryValue* device_whitelist = GetWhitelistPrefs();
55 for (base::DictionaryValue::Iterator it(*device_whitelist); !it.IsAtEnd(); 55 for (base::DictionaryValue::Iterator it(*device_whitelist); !it.IsAtEnd();
56 it.Advance()) { 56 it.Advance()) {
57 std::string value_string; 57 std::string value_string;
58 DCHECK(it.value().IsType(base::Value::TYPE_STRING)); 58 DCHECK(it.value().IsType(base::Value::Type::STRING));
59 if (it.value().GetAsString(&value_string) && value_string == public_key) 59 if (it.value().GetAsString(&value_string) && value_string == public_key)
60 return it.key(); 60 return it.key();
61 } 61 }
62 return std::string(); 62 return std::string();
63 } 63 }
64 64
65 std::vector<std::string> BluetoothLowEnergyDeviceWhitelist::GetPublicKeys() 65 std::vector<std::string> BluetoothLowEnergyDeviceWhitelist::GetPublicKeys()
66 const { 66 const {
67 std::vector<std::string> public_keys; 67 std::vector<std::string> public_keys;
68 const base::DictionaryValue* device_whitelist = GetWhitelistPrefs(); 68 const base::DictionaryValue* device_whitelist = GetWhitelistPrefs();
69 for (base::DictionaryValue::Iterator it(*device_whitelist); !it.IsAtEnd(); 69 for (base::DictionaryValue::Iterator it(*device_whitelist); !it.IsAtEnd();
70 it.Advance()) { 70 it.Advance()) {
71 std::string value_string; 71 std::string value_string;
72 DCHECK(it.value().IsType(base::Value::TYPE_STRING)); 72 DCHECK(it.value().IsType(base::Value::Type::STRING));
73 it.value().GetAsString(&value_string); 73 it.value().GetAsString(&value_string);
74 public_keys.push_back(value_string); 74 public_keys.push_back(value_string);
75 } 75 }
76 return public_keys; 76 return public_keys;
77 } 77 }
78 78
79 void BluetoothLowEnergyDeviceWhitelist::AddOrUpdateDevice( 79 void BluetoothLowEnergyDeviceWhitelist::AddOrUpdateDevice(
80 const std::string& bluetooth_address, 80 const std::string& bluetooth_address,
81 const std::string& public_key) { 81 const std::string& public_key) {
82 if (HasDeviceWithPublicKey(public_key) && 82 if (HasDeviceWithPublicKey(public_key) &&
(...skipping 22 matching lines...) Expand all
105 return RemoveDeviceWithAddress(GetDeviceAddress(public_key)); 105 return RemoveDeviceWithAddress(GetDeviceAddress(public_key));
106 } 106 }
107 107
108 const base::DictionaryValue* 108 const base::DictionaryValue*
109 BluetoothLowEnergyDeviceWhitelist::GetWhitelistPrefs() const { 109 BluetoothLowEnergyDeviceWhitelist::GetWhitelistPrefs() const {
110 return pref_service_->GetDictionary( 110 return pref_service_->GetDictionary(
111 prefs::kBluetoothLowEnergyDeviceWhitelist); 111 prefs::kBluetoothLowEnergyDeviceWhitelist);
112 } 112 }
113 113
114 } // namespace proximity_auth 114 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/prefs/scoped_user_pref_update.h ('k') | components/proximity_auth/messenger_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698