diff options
author | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 06:59:50 +0000 |
---|---|---|
committer | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-04 06:59:50 +0000 |
commit | b314272591420e941281d56e96079756b334c404 (patch) | |
tree | 41ab73dbaf890dd87f1610c707defff67a50a857 /device | |
parent | 90be8cd625f609af86d135ef4e54503360699efa (diff) | |
download | chromium_src-b314272591420e941281d56e96079756b334c404.zip chromium_src-b314272591420e941281d56e96079756b334c404.tar.gz chromium_src-b314272591420e941281d56e96079756b334c404.tar.bz2 |
Bluetooth: notify user of incoming pairing requests
Implement a low-priority pairing delegate in the form of an Aura Status
Tray Notification Controller that displays a rich notification when an
incoming pairing request is received and allows the user to accept or
reject it when appropriate.
BUG=345535
TESTS=chromeos=1 on Linux presents fake pairing requests
Review URL: https://codereview.chromium.org/183853010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r-- | device/bluetooth/bluetooth_device_chromeos.cc | 1 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_pairing_chromeos.cc | 44 | ||||
-rw-r--r-- | device/bluetooth/bluetooth_pairing_chromeos.h | 4 |
3 files changed, 32 insertions, 17 deletions
diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc index b76c512..d45ea7b 100644 --- a/device/bluetooth/bluetooth_device_chromeos.cc +++ b/device/bluetooth/bluetooth_device_chromeos.cc @@ -395,7 +395,6 @@ void BluetoothDeviceChromeOS::ClearOutOfBandPairingData( BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing( BluetoothDevice::PairingDelegate* pairing_delegate) { - DCHECK(!pairing_); pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate)); return pairing_.get(); } diff --git a/device/bluetooth/bluetooth_pairing_chromeos.cc b/device/bluetooth/bluetooth_pairing_chromeos.cc index b81c342..dc73f6d 100644 --- a/device/bluetooth/bluetooth_pairing_chromeos.cc +++ b/device/bluetooth/bluetooth_pairing_chromeos.cc @@ -26,6 +26,10 @@ enum UMAPairingMethod { UMA_PAIRING_METHOD_COUNT }; +// Number of keys that will be entered for a passkey, six digits plus the +// final enter. +const uint16 kPasskeyMaxKeysEntered = 7; + } // namespace namespace chromeos { @@ -74,10 +78,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 +108,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 +125,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 +155,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 >= kPasskeyMaxKeysEntered && !device_->IsConnecting()) 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 +180,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 +193,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 +232,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; diff --git a/device/bluetooth/bluetooth_pairing_chromeos.h b/device/bluetooth/bluetooth_pairing_chromeos.h index 85c45c6..ae906bc 100644 --- a/device/bluetooth/bluetooth_pairing_chromeos.h +++ b/device/bluetooth/bluetooth_pairing_chromeos.h @@ -108,6 +108,10 @@ class BluetoothPairingChromeOS { device::BluetoothDevice::PairingDelegate* GetPairingDelegate() const; private: + // Internal method to reset the current set of callbacks because a new + // request has arrived that supercedes them. + void ResetCallbacks(); + // Internal method to respond to the relevant callback for a RejectPairing // or CancelPairing call. bool RunPairingCallbacks( |