| 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "components/pairing/bluetooth_pairing_constants.h" | 10 #include "components/pairing/bluetooth_pairing_constants.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 DCHECK(thread_checker_.CalledOnValidThread()); | 262 DCHECK(thread_checker_.CalledOnValidThread()); |
| 263 if (current_stage_ != STAGE_WAITING_FOR_CREDENTIALS) { | 263 if (current_stage_ != STAGE_WAITING_FOR_CREDENTIALS) { |
| 264 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); | 264 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 | 267 |
| 268 ChangeStage(STAGE_ENROLLING); | 268 ChangeStage(STAGE_ENROLLING); |
| 269 // TODO(zork,achuith): Enroll device, send error on error. | 269 // TODO(zork,achuith): Enroll device, send error on error. |
| 270 // (http://crbug.com/374990) | 270 // (http://crbug.com/374990) |
| 271 // For now, test domain is sent in the access token. | 271 // For now, test domain is sent in the access token. |
| 272 enrollment_domain_ = message.parameters().admin_access_token(); | 272 FOR_EACH_OBSERVER(Observer, observers_, |
| 273 ChangeStage(STAGE_PAIRING_DONE); | 273 EnrollHost(message.parameters().admin_access_token())); |
| 274 SendHostStatus(); | 274 } |
| 275 |
| 276 void BluetoothHostPairingController::SetEnrollmentComplete(bool success) { |
| 277 DCHECK_EQ(current_stage_, STAGE_ENROLLING); |
| 278 DCHECK(thread_checker_.CalledOnValidThread()); |
| 279 if (success) { |
| 280 ChangeStage(STAGE_PAIRING_DONE); |
| 281 SendHostStatus(); |
| 282 } else { |
| 283 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorEnrollmentFailed); |
| 284 } |
| 275 } | 285 } |
| 276 | 286 |
| 277 void BluetoothHostPairingController::OnCompleteSetupMessage( | 287 void BluetoothHostPairingController::OnCompleteSetupMessage( |
| 278 const pairing_api::CompleteSetup& message) { | 288 const pairing_api::CompleteSetup& message) { |
| 279 DCHECK(thread_checker_.CalledOnValidThread()); | 289 DCHECK(thread_checker_.CalledOnValidThread()); |
| 280 if (current_stage_ != STAGE_PAIRING_DONE) { | 290 if (current_stage_ != STAGE_PAIRING_DONE) { |
| 281 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); | 291 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); |
| 282 return; | 292 return; |
| 283 } | 293 } |
| 284 | 294 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); | 385 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); |
| 376 } | 386 } |
| 377 | 387 |
| 378 void BluetoothHostPairingController::AuthorizePairing( | 388 void BluetoothHostPairingController::AuthorizePairing( |
| 379 device::BluetoothDevice* device) { | 389 device::BluetoothDevice* device) { |
| 380 // Disallow unknown device. | 390 // Disallow unknown device. |
| 381 device->RejectPairing(); | 391 device->RejectPairing(); |
| 382 } | 392 } |
| 383 | 393 |
| 384 } // namespace pairing_chromeos | 394 } // namespace pairing_chromeos |
| OLD | NEW |