OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 unsigned passkey = 0; | 282 unsigned passkey = 0; |
283 base::StringToUint(auth_token, &passkey); | 283 base::StringToUint(auth_token, &passkey); |
284 | 284 |
285 VLOG(1) << "Passkey supplied: " << address << ": " << passkey; | 285 VLOG(1) << "Passkey supplied: " << address << ": " << passkey; |
286 device->SetPasskey(passkey); | 286 device->SetPasskey(passkey); |
287 } else { | 287 } else { |
288 LOG(WARNING) << "Auth token supplied after pairing ended: " << address | 288 LOG(WARNING) << "Auth token supplied after pairing ended: " << address |
289 << ": " << auth_token; | 289 << ": " << auth_token; |
290 } | 290 } |
291 } else { | 291 } else { |
| 292 // Determine if the device supports pairing: |
| 293 PairingDelegate* delegate = NULL; |
| 294 if (device->IsPairable()) |
| 295 delegate = this; |
| 296 |
292 // Connection request. | 297 // Connection request. |
293 VLOG(1) << "Connect: " << address; | 298 VLOG(1) << "Connect: " << address; |
294 device->Connect( | 299 device->Connect( |
295 this, | 300 delegate, |
296 base::Bind(&base::DoNothing), | 301 base::Bind(&BluetoothOptionsHandler::DismissDisplayOrConfirm, |
| 302 weak_ptr_factory_.GetWeakPtr()), |
297 base::Bind(&BluetoothOptionsHandler::ConnectError, | 303 base::Bind(&BluetoothOptionsHandler::ConnectError, |
298 weak_ptr_factory_.GetWeakPtr(), | 304 weak_ptr_factory_.GetWeakPtr(), |
299 device->GetAddress())); | 305 device->GetAddress())); |
300 } | 306 } |
301 } else if (command == kCancelCommand) { | 307 } else if (command == kCancelCommand) { |
302 // Cancel pairing. | 308 // Cancel pairing. |
303 VLOG(1) << "Cancel pairing: " << address; | 309 VLOG(1) << "Cancel pairing: " << address; |
304 device->CancelPairing(); | 310 device->CancelPairing(); |
305 } else if (command == kAcceptCommand) { | 311 } else if (command == kAcceptCommand) { |
306 // Confirm displayed Passkey. | 312 // Confirm displayed Passkey. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 void BluetoothOptionsHandler::DeviceConnecting( | 503 void BluetoothOptionsHandler::DeviceConnecting( |
498 device::BluetoothDevice* device) { | 504 device::BluetoothDevice* device) { |
499 DCHECK(device); | 505 DCHECK(device); |
500 DictionaryValue params; | 506 DictionaryValue params; |
501 params.SetString("pairing", kStartConnecting); | 507 params.SetString("pairing", kStartConnecting); |
502 SendDeviceNotification(device, ¶ms); | 508 SendDeviceNotification(device, ¶ms); |
503 } | 509 } |
504 | 510 |
505 } // namespace options | 511 } // namespace options |
506 } // namespace chromeos | 512 } // namespace chromeos |
OLD | NEW |