Chromium Code Reviews| 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 3d62c3ace401f0eafd34b146eb00e1dc0c04e8c1..864bce556643e3386394d0eb8475dcb4ad1ee1fc 100644 |
| --- a/components/pairing/bluetooth_host_pairing_controller.cc |
| +++ b/components/pairing/bluetooth_host_pairing_controller.cc |
| @@ -118,9 +118,16 @@ void BluetoothHostPairingController::OnGetAdapter( |
| } |
| 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()); |
| + int device_id = 0; |
| + for (size_t i = 0; i < adapter_->GetAddress().length(); ++i) { |
| + int value = adapter_->GetAddress()[i]; |
| + if (i % 2) { |
| + value *= 0x100; |
| + } |
| + device_id ^= value; |
| + } |
| + |
|
dzhioev (left Google)
2014/09/18 04:12:37
Does this cycle calculate some hash function?
Can
Zachary Kuznia
2014/09/18 08:45:47
Good call, done and done.
|
| + device_name_ = base::StringPrintf("%s%04X", kDeviceNamePrefix, device_id); |
|
dzhioev (left Google)
2014/09/18 04:12:37
You should use 'unsigned int' with 'X' flag.
Zachary Kuznia
2014/09/18 08:45:47
Done.
|
| adapter_->SetName( |
| device_name_, |
| @@ -232,14 +239,12 @@ void BluetoothHostPairingController::OnReceiveComplete( |
| void BluetoothHostPairingController::OnCreateServiceError( |
| const std::string& message) { |
| LOG(ERROR) << message; |
| - // TODO(zork): Add a stage for initialization error. (http://crbug.com/405744) |
| - ChangeStage(STAGE_NONE); |
| + ChangeStage(STAGE_INITIALIZATION_ERROR); |
| } |
| void BluetoothHostPairingController::OnSetError() { |
| adapter_->RemovePairingDelegate(this); |
| - // TODO(zork): Add a stage for initialization error. (http://crbug.com/405744) |
| - ChangeStage(STAGE_NONE); |
| + ChangeStage(STAGE_INITIALIZATION_ERROR); |
| } |
| void BluetoothHostPairingController::OnAcceptError( |
| @@ -267,7 +272,12 @@ void BluetoothHostPairingController::OnHostStatusMessage( |
| void BluetoothHostPairingController::OnConfigureHostMessage( |
| const pairing_api::ConfigureHost& message) { |
| - // TODO(zork): Add event to API to handle this case. (http://crbug.com/405744) |
| + FOR_EACH_OBSERVER(Observer, observers_, |
| + ConfigureHost(message.parameters().accepted_eula(), |
| + message.parameters().lang(), |
| + message.parameters().timezone(), |
| + message.parameters().send_reports(), |
| + message.parameters().keyboard_layout())); |
| } |
| void BluetoothHostPairingController::OnPairDevicesMessage( |
| @@ -337,9 +347,10 @@ void BluetoothHostPairingController::StartPairing() { |
| DCHECK_EQ(current_stage_, STAGE_NONE); |
| bool bluetooth_available = |
| device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable(); |
| - // TODO(zork): Add a stage for initialization error. (http://crbug.com/405744) |
| - if (!bluetooth_available) |
| + if (!bluetooth_available) { |
| + ChangeStage(STAGE_INITIALIZATION_ERROR); |
| return; |
| + } |
| device::BluetoothAdapterFactory::GetAdapter( |
| base::Bind(&BluetoothHostPairingController::OnGetAdapter, |