| Index: components/pairing/bluetooth_host_pairing_controller.cc
|
| diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
|
| index a22dfc32952b0fddef88900f12d4b8e89daf52c2..b9e8b583e06b083b80f312782f01ee42d2349534 100644
|
| --- a/components/pairing/bluetooth_host_pairing_controller.cc
|
| +++ b/components/pairing/bluetooth_host_pairing_controller.cc
|
| @@ -106,9 +106,19 @@ void BluetoothHostPairingController::OnGetAdapter(
|
| DCHECK(!adapter_);
|
| adapter_ = adapter;
|
|
|
| + if (adapter_->IsPresent()) {
|
| + SetName();
|
| + } else {
|
| + // Set the name once the adapter is present.
|
| + adapter_->AddObserver(this);
|
| + }
|
| +}
|
| +
|
| +void BluetoothHostPairingController::SetName() {
|
| // TODO(zork): Make the device name prettier. (http://crbug.com/405774)
|
| device_name_ = base::StringPrintf("%s%s", kDeviceNamePrefix,
|
| adapter_->GetAddress().c_str());
|
| +
|
| adapter_->SetName(
|
| device_name_,
|
| base::Bind(&BluetoothHostPairingController::OnSetName,
|
| @@ -298,6 +308,16 @@ void BluetoothHostPairingController::OnErrorMessage(
|
| NOTREACHED();
|
| }
|
|
|
| +void BluetoothHostPairingController::AdapterPresentChanged(
|
| + device::BluetoothAdapter* adapter,
|
| + bool present) {
|
| + DCHECK_EQ(adapter, adapter_.get());
|
| + if (present) {
|
| + adapter_->RemoveObserver(this);
|
| + SetName();
|
| + }
|
| +}
|
| +
|
| void BluetoothHostPairingController::AddObserver(Observer* observer) {
|
| observers_.AddObserver(observer);
|
| }
|
|
|