Chromium Code Reviews| Index: device/bluetooth/bluetooth_pairing_chromeos.cc |
| diff --git a/device/bluetooth/bluetooth_pairing_chromeos.cc b/device/bluetooth/bluetooth_pairing_chromeos.cc |
| index b81c342dd5e1005de66571335da4726e6444e8d8..b0540295d17843619dd71a4163191d9a7d128ea9 100644 |
| --- a/device/bluetooth/bluetooth_pairing_chromeos.cc |
| +++ b/device/bluetooth/bluetooth_pairing_chromeos.cc |
| @@ -74,10 +74,10 @@ void BluetoothPairingChromeOS::RequestPinCode( |
| UMA_PAIRING_METHOD_REQUEST_PINCODE, |
| UMA_PAIRING_METHOD_COUNT); |
| - DCHECK(pincode_callback_.is_null()); |
| + ResetCallbacks(); |
| pincode_callback_ = callback; |
| - pairing_delegate_->RequestPinCode(device_); |
| pairing_delegate_used_ = true; |
| + pairing_delegate_->RequestPinCode(device_); |
| } |
| bool BluetoothPairingChromeOS::ExpectingPinCode() const { |
| @@ -104,8 +104,9 @@ void BluetoothPairingChromeOS::DisplayPinCode(const std::string& pincode) { |
| UMA_PAIRING_METHOD_DISPLAY_PINCODE, |
| UMA_PAIRING_METHOD_COUNT); |
| - pairing_delegate_->DisplayPinCode(device_, pincode); |
| + ResetCallbacks(); |
| pairing_delegate_used_ = true; |
| + pairing_delegate_->DisplayPinCode(device_, pincode); |
| // If this is not an outgoing connection to the device, the pairing context |
| // needs to be cleaned up again as there's no reliable indication of |
| @@ -120,10 +121,10 @@ void BluetoothPairingChromeOS::RequestPasskey( |
| UMA_PAIRING_METHOD_REQUEST_PASSKEY, |
| UMA_PAIRING_METHOD_COUNT); |
| - DCHECK(passkey_callback_.is_null()); |
| + ResetCallbacks(); |
| passkey_callback_ = callback; |
| - pairing_delegate_->RequestPasskey(device_); |
| pairing_delegate_used_ = true; |
| + pairing_delegate_->RequestPasskey(device_); |
| } |
| bool BluetoothPairingChromeOS::ExpectingPasskey() const { |
| @@ -150,22 +151,23 @@ void BluetoothPairingChromeOS::DisplayPasskey(uint32 passkey) { |
| UMA_PAIRING_METHOD_DISPLAY_PASSKEY, |
| UMA_PAIRING_METHOD_COUNT); |
| - |
| + ResetCallbacks(); |
| + pairing_delegate_used_ = true; |
| pairing_delegate_->DisplayPasskey(device_, passkey); |
| + |
| +} |
| + |
| +void BluetoothPairingChromeOS::KeysEntered(uint16 entered) { |
| pairing_delegate_used_ = true; |
| + pairing_delegate_->KeysEntered(device_, entered); |
| // If this is not an outgoing connection to the device, the pairing context |
| // needs to be cleaned up again as there's no reliable indication of |
| // completion of incoming pairing. |
| - if (!device_->IsConnecting()) |
| + if (entered > 6 && !device_->IsConnecting()) |
|
stevenjb
2014/02/28 21:40:54
const for 6
keybuk
2014/02/28 22:28:54
Done.
|
| device_->EndPairing(); |
| } |
| -void BluetoothPairingChromeOS::KeysEntered(uint16 entered) { |
| - pairing_delegate_->KeysEntered(device_, entered); |
| - pairing_delegate_used_ = true; |
| -} |
| - |
| void BluetoothPairingChromeOS::RequestConfirmation( |
| uint32 passkey, |
| const BluetoothAgentServiceProvider::Delegate::ConfirmationCallback& |
| @@ -174,10 +176,10 @@ void BluetoothPairingChromeOS::RequestConfirmation( |
| UMA_PAIRING_METHOD_CONFIRM_PASSKEY, |
| UMA_PAIRING_METHOD_COUNT); |
| - DCHECK(confirmation_callback_.is_null()); |
| + ResetCallbacks(); |
| confirmation_callback_ = callback; |
| - pairing_delegate_->ConfirmPasskey(device_, passkey); |
| pairing_delegate_used_ = true; |
| + pairing_delegate_->ConfirmPasskey(device_, passkey); |
| } |
| void BluetoothPairingChromeOS::RequestAuthorization( |
| @@ -187,10 +189,10 @@ void BluetoothPairingChromeOS::RequestAuthorization( |
| UMA_PAIRING_METHOD_NONE, |
| UMA_PAIRING_METHOD_COUNT); |
| - DCHECK(confirmation_callback_.is_null()); |
| + ResetCallbacks(); |
| confirmation_callback_ = callback; |
| - pairing_delegate_->AuthorizePairing(device_); |
| pairing_delegate_used_ = true; |
| + pairing_delegate_->AuthorizePairing(device_); |
| } |
| bool BluetoothPairingChromeOS::ExpectingConfirmation() const { |
| @@ -226,6 +228,12 @@ BluetoothPairingChromeOS::GetPairingDelegate() const { |
| return pairing_delegate_; |
| } |
| +void BluetoothPairingChromeOS::ResetCallbacks() { |
| + pincode_callback_.Reset(); |
| + passkey_callback_.Reset(); |
| + confirmation_callback_.Reset(); |
| +} |
| + |
| bool BluetoothPairingChromeOS::RunPairingCallbacks( |
| BluetoothAgentServiceProvider::Delegate::Status status) { |
| pairing_delegate_used_ = true; |