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

Unified Diff: device/bluetooth/bluetooth_pairing_chromeos.cc

Issue 183853010: Bluetooth: notify user of incoming pairing requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698