OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/bluetooth/bluetooth_private_api.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 const char kAdapterNotPresent[] = | 80 const char kAdapterNotPresent[] = |
81 "Could not find a Bluetooth adapter."; | 81 "Could not find a Bluetooth adapter."; |
82 | 82 |
83 // Returns true if the pairing response options passed into the | 83 // Returns true if the pairing response options passed into the |
84 // setPairingResponse function are valid. | 84 // setPairingResponse function are valid. |
85 bool ValidatePairingResponseOptions( | 85 bool ValidatePairingResponseOptions( |
86 const device::BluetoothDevice* device, | 86 const device::BluetoothDevice* device, |
87 const bt_private::SetPairingResponseOptions& options) { | 87 const bt_private::SetPairingResponseOptions& options) { |
88 bool response = options.response != bt_private::PAIRING_RESPONSE_NONE; | 88 bool response = options.response != bt_private::PAIRING_RESPONSE_NONE; |
89 bool pincode = options.pincode.get() != NULL; | 89 bool pincode = options.pincode.get() != nullptr; |
90 bool passkey = options.passkey.get() != NULL; | 90 bool passkey = options.passkey.get() != nullptr; |
91 | 91 |
92 if (!response && !pincode && !passkey) | 92 if (!response && !pincode && !passkey) |
93 return false; | 93 return false; |
94 if (pincode && passkey) | 94 if (pincode && passkey) |
95 return false; | 95 return false; |
96 if (options.response != bt_private::PAIRING_RESPONSE_CONFIRM && | 96 if (options.response != bt_private::PAIRING_RESPONSE_CONFIRM && |
97 (pincode || passkey)) | 97 (pincode || passkey)) |
98 return false; | 98 return false; |
99 | 99 |
100 // Check the BluetoothDevice is in expecting the correct response. | 100 // Check the BluetoothDevice is in expecting the correct response. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 DCHECK(pending_properties_.empty()); | 213 DCHECK(pending_properties_.empty()); |
214 DCHECK(!failed_properties_.empty()); | 214 DCHECK(!failed_properties_.empty()); |
215 | 215 |
216 std::vector<std::string> failed_vector; | 216 std::vector<std::string> failed_vector; |
217 std::copy(failed_properties_.begin(), | 217 std::copy(failed_properties_.begin(), |
218 failed_properties_.end(), | 218 failed_properties_.end(), |
219 std::back_inserter(failed_vector)); | 219 std::back_inserter(failed_vector)); |
220 | 220 |
221 std::vector<std::string> replacements(1); | 221 std::vector<std::string> replacements(1); |
222 replacements[0] = JoinString(failed_vector, ", "); | 222 replacements[0] = JoinString(failed_vector, ", "); |
223 std::string error = | 223 std::string error = ReplaceStringPlaceholders( |
224 ReplaceStringPlaceholders(kSetAdapterPropertyError, replacements, NULL); | 224 kSetAdapterPropertyError, replacements, nullptr); |
225 SetError(error); | 225 SetError(error); |
226 SendResponse(false); | 226 SendResponse(false); |
227 } | 227 } |
228 | 228 |
229 BluetoothPrivateSetPairingResponseFunction:: | 229 BluetoothPrivateSetPairingResponseFunction:: |
230 BluetoothPrivateSetPairingResponseFunction() {} | 230 BluetoothPrivateSetPairingResponseFunction() {} |
231 | 231 |
232 BluetoothPrivateSetPairingResponseFunction:: | 232 BluetoothPrivateSetPairingResponseFunction:: |
233 ~BluetoothPrivateSetPairingResponseFunction() {} | 233 ~BluetoothPrivateSetPairingResponseFunction() {} |
234 | 234 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 SendResponse(true); | 284 SendResponse(true); |
285 return true; | 285 return true; |
286 } | 286 } |
287 | 287 |
288 } // namespace core_api | 288 } // namespace core_api |
289 | 289 |
290 } // namespace extensions | 290 } // namespace extensions |
OLD | NEW |