OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/pairing/bluetooth_host_pairing_controller.h" | 5 #include "components/pairing/bluetooth_host_pairing_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 301 } |
302 | 302 |
303 void BluetoothHostPairingController::OnSetError() { | 303 void BluetoothHostPairingController::OnSetError() { |
304 adapter_->RemovePairingDelegate(this); | 304 adapter_->RemovePairingDelegate(this); |
305 ChangeStage(STAGE_INITIALIZATION_ERROR); | 305 ChangeStage(STAGE_INITIALIZATION_ERROR); |
306 } | 306 } |
307 | 307 |
308 void BluetoothHostPairingController::OnAcceptError( | 308 void BluetoothHostPairingController::OnAcceptError( |
309 const std::string& error_message) { | 309 const std::string& error_message) { |
310 LOG(ERROR) << error_message; | 310 LOG(ERROR) << error_message; |
| 311 ChangeStage(STAGE_CONTROLLER_CONNECTION_ERROR); |
311 } | 312 } |
312 | 313 |
313 void BluetoothHostPairingController::OnSendError( | 314 void BluetoothHostPairingController::OnSendError( |
314 const std::string& error_message) { | 315 const std::string& error_message) { |
315 LOG(ERROR) << error_message; | 316 LOG(ERROR) << error_message; |
| 317 if (enrollment_status_ != ENROLLMENT_STATUS_ENROLLING && |
| 318 enrollment_status_ != ENROLLMENT_STATUS_SUCCESS) { |
| 319 ChangeStage(STAGE_CONTROLLER_CONNECTION_ERROR); |
| 320 } |
316 } | 321 } |
317 | 322 |
318 void BluetoothHostPairingController::OnReceiveError( | 323 void BluetoothHostPairingController::OnReceiveError( |
319 device::BluetoothSocket::ErrorReason reason, | 324 device::BluetoothSocket::ErrorReason reason, |
320 const std::string& error_message) { | 325 const std::string& error_message) { |
321 LOG(ERROR) << reason << ", " << error_message; | 326 LOG(ERROR) << reason << ", " << error_message; |
| 327 ChangeStage(STAGE_CONTROLLER_CONNECTION_ERROR); |
322 } | 328 } |
323 | 329 |
324 void BluetoothHostPairingController::OnHostStatusMessage( | 330 void BluetoothHostPairingController::OnHostStatusMessage( |
325 const pairing_api::HostStatus& message) { | 331 const pairing_api::HostStatus& message) { |
326 NOTREACHED(); | 332 NOTREACHED(); |
327 } | 333 } |
328 | 334 |
329 void BluetoothHostPairingController::OnConfigureHostMessage( | 335 void BluetoothHostPairingController::OnConfigureHostMessage( |
330 const pairing_api::ConfigureHost& message) { | 336 const pairing_api::ConfigureHost& message) { |
331 ChangeStage(STAGE_SETUP_BASIC_CONFIGURATION); | 337 ChangeStage(STAGE_SETUP_BASIC_CONFIGURATION); |
(...skipping 13 matching lines...) Expand all Loading... |
345 ChangeStage(STAGE_ENROLLING); | 351 ChangeStage(STAGE_ENROLLING); |
346 FOR_EACH_OBSERVER(Observer, observers_, | 352 FOR_EACH_OBSERVER(Observer, observers_, |
347 EnrollHostRequested( | 353 EnrollHostRequested( |
348 message.parameters().admin_access_token())); | 354 message.parameters().admin_access_token())); |
349 } | 355 } |
350 | 356 |
351 void BluetoothHostPairingController::OnCompleteSetupMessage( | 357 void BluetoothHostPairingController::OnCompleteSetupMessage( |
352 const pairing_api::CompleteSetup& message) { | 358 const pairing_api::CompleteSetup& message) { |
353 DCHECK(thread_checker_.CalledOnValidThread()); | 359 DCHECK(thread_checker_.CalledOnValidThread()); |
354 if (current_stage_ != STAGE_ENROLLMENT_SUCCESS) { | 360 if (current_stage_ != STAGE_ENROLLMENT_SUCCESS) { |
| 361 ChangeStage(STAGE_ENROLLMENT_ERROR); |
355 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); | 362 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); |
356 return; | 363 return; |
357 } | 364 } |
358 | 365 |
359 // TODO(zork): Handle adding another controller. (http://crbug.com/405757) | 366 // TODO(zork): Handle adding another controller. (http://crbug.com/405757) |
360 ChangeStage(STAGE_FINISHED); | 367 ChangeStage(STAGE_FINISHED); |
361 } | 368 } |
362 | 369 |
363 void BluetoothHostPairingController::OnErrorMessage( | 370 void BluetoothHostPairingController::OnErrorMessage( |
364 const pairing_api::Error& message) { | 371 const pairing_api::Error& message) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); | 511 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); |
505 } | 512 } |
506 | 513 |
507 void BluetoothHostPairingController::AuthorizePairing( | 514 void BluetoothHostPairingController::AuthorizePairing( |
508 device::BluetoothDevice* device) { | 515 device::BluetoothDevice* device) { |
509 // Disallow unknown device. | 516 // Disallow unknown device. |
510 device->RejectPairing(); | 517 device->RejectPairing(); |
511 } | 518 } |
512 | 519 |
513 } // namespace pairing_chromeos | 520 } // namespace pairing_chromeos |
OLD | NEW |