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

Side by Side Diff: extensions/browser/api/bluetooth/bluetooth_private_api.cc

Issue 2137013005: [Extensions] Code Cleanup - Remove redundant smart-ptr get()s (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const char kForgetDeviceError[] = "Failed to forget device"; 95 const char kForgetDeviceError[] = "Failed to forget device";
96 const char kSetDiscoveryFilterFailed[] = "Failed to set discovery filter"; 96 const char kSetDiscoveryFilterFailed[] = "Failed to set discovery filter";
97 const char kPairingFailed[] = "Pairing failed"; 97 const char kPairingFailed[] = "Pairing failed";
98 98
99 // Returns true if the pairing response options passed into the 99 // Returns true if the pairing response options passed into the
100 // setPairingResponse function are valid. 100 // setPairingResponse function are valid.
101 bool ValidatePairingResponseOptions( 101 bool ValidatePairingResponseOptions(
102 const device::BluetoothDevice* device, 102 const device::BluetoothDevice* device,
103 const bt_private::SetPairingResponseOptions& options) { 103 const bt_private::SetPairingResponseOptions& options) {
104 bool response = options.response != bt_private::PAIRING_RESPONSE_NONE; 104 bool response = options.response != bt_private::PAIRING_RESPONSE_NONE;
105 bool pincode = options.pincode.get() != nullptr; 105 bool pincode = options.pincode != nullptr;
106 bool passkey = options.passkey.get() != nullptr; 106 bool passkey = options.passkey != nullptr;
107 107
108 if (!response && !pincode && !passkey) 108 if (!response && !pincode && !passkey)
109 return false; 109 return false;
110 if (pincode && passkey) 110 if (pincode && passkey)
111 return false; 111 return false;
112 if (options.response != bt_private::PAIRING_RESPONSE_CONFIRM && 112 if (options.response != bt_private::PAIRING_RESPONSE_CONFIRM &&
113 (pincode || passkey)) 113 (pincode || passkey))
114 return false; 114 return false;
115 115
116 if (options.response == bt_private::PAIRING_RESPONSE_CANCEL) 116 if (options.response == bt_private::PAIRING_RESPONSE_CANCEL)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 return true; 273 return true;
274 } 274 }
275 275
276 if (!ValidatePairingResponseOptions(device, options)) { 276 if (!ValidatePairingResponseOptions(device, options)) {
277 SetError(kInvalidPairingResponseOptions); 277 SetError(kInvalidPairingResponseOptions);
278 SendResponse(false); 278 SendResponse(false);
279 return true; 279 return true;
280 } 280 }
281 281
282 if (options.pincode.get()) { 282 if (options.pincode.get()) {
283 device->SetPinCode(*options.pincode.get()); 283 device->SetPinCode(*options.pincode);
284 } else if (options.passkey.get()) { 284 } else if (options.passkey.get()) {
285 device->SetPasskey(*options.passkey.get()); 285 device->SetPasskey(*options.passkey);
286 } else { 286 } else {
287 switch (options.response) { 287 switch (options.response) {
288 case bt_private::PAIRING_RESPONSE_CONFIRM: 288 case bt_private::PAIRING_RESPONSE_CONFIRM:
289 device->ConfirmPairing(); 289 device->ConfirmPairing();
290 break; 290 break;
291 case bt_private::PAIRING_RESPONSE_REJECT: 291 case bt_private::PAIRING_RESPONSE_REJECT:
292 device->RejectPairing(); 292 device->RejectPairing();
293 break; 293 break;
294 case bt_private::PAIRING_RESPONSE_CANCEL: 294 case bt_private::PAIRING_RESPONSE_CANCEL:
295 device->CancelPairing(); 295 device->CancelPairing();
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 device::BluetoothDevice::ConnectErrorCode error) { 617 device::BluetoothDevice::ConnectErrorCode error) {
618 SetError(kPairingFailed); 618 SetError(kPairingFailed);
619 SendResponse(false); 619 SendResponse(false);
620 } 620 }
621 621
622 //////////////////////////////////////////////////////////////////////////////// 622 ////////////////////////////////////////////////////////////////////////////////
623 623
624 } // namespace api 624 } // namespace api
625 625
626 } // namespace extensions 626 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698