Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: components/pairing/bluetooth_host_pairing_controller.cc

Issue 1535573002: 1) Add initialization error page; 2) Add connection error page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clear the enrollment related local state when the enrollment succeeds or an error occurs. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 ChangeStage(STAGE_CONTROLLER_CONNECTION_ERROR);
dzhioev (left Google) 2015/12/17 23:33:32 I don't think we should call this if |enrollment_s
xdai1 2015/12/17 23:49:08 Agreed. Addressed your comment.
316 } 318 }
317 319
318 void BluetoothHostPairingController::OnReceiveError( 320 void BluetoothHostPairingController::OnReceiveError(
319 device::BluetoothSocket::ErrorReason reason, 321 device::BluetoothSocket::ErrorReason reason,
320 const std::string& error_message) { 322 const std::string& error_message) {
321 LOG(ERROR) << reason << ", " << error_message; 323 LOG(ERROR) << reason << ", " << error_message;
324 ChangeStage(STAGE_CONTROLLER_CONNECTION_ERROR);
322 } 325 }
323 326
324 void BluetoothHostPairingController::OnHostStatusMessage( 327 void BluetoothHostPairingController::OnHostStatusMessage(
325 const pairing_api::HostStatus& message) { 328 const pairing_api::HostStatus& message) {
326 NOTREACHED(); 329 NOTREACHED();
327 } 330 }
328 331
329 void BluetoothHostPairingController::OnConfigureHostMessage( 332 void BluetoothHostPairingController::OnConfigureHostMessage(
330 const pairing_api::ConfigureHost& message) { 333 const pairing_api::ConfigureHost& message) {
331 ChangeStage(STAGE_SETUP_BASIC_CONFIGURATION); 334 ChangeStage(STAGE_SETUP_BASIC_CONFIGURATION);
(...skipping 13 matching lines...) Expand all
345 ChangeStage(STAGE_ENROLLING); 348 ChangeStage(STAGE_ENROLLING);
346 FOR_EACH_OBSERVER(Observer, observers_, 349 FOR_EACH_OBSERVER(Observer, observers_,
347 EnrollHostRequested( 350 EnrollHostRequested(
348 message.parameters().admin_access_token())); 351 message.parameters().admin_access_token()));
349 } 352 }
350 353
351 void BluetoothHostPairingController::OnCompleteSetupMessage( 354 void BluetoothHostPairingController::OnCompleteSetupMessage(
352 const pairing_api::CompleteSetup& message) { 355 const pairing_api::CompleteSetup& message) {
353 DCHECK(thread_checker_.CalledOnValidThread()); 356 DCHECK(thread_checker_.CalledOnValidThread());
354 if (current_stage_ != STAGE_ENROLLMENT_SUCCESS) { 357 if (current_stage_ != STAGE_ENROLLMENT_SUCCESS) {
358 ChangeStage(STAGE_ENROLLMENT_ERROR);
355 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol); 359 AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorInvalidProtocol);
356 return; 360 return;
357 } 361 }
358 362
359 // TODO(zork): Handle adding another controller. (http://crbug.com/405757) 363 // TODO(zork): Handle adding another controller. (http://crbug.com/405757)
360 ChangeStage(STAGE_FINISHED); 364 ChangeStage(STAGE_FINISHED);
361 } 365 }
362 366
363 void BluetoothHostPairingController::OnErrorMessage( 367 void BluetoothHostPairingController::OnErrorMessage(
364 const pairing_api::Error& message) { 368 const pairing_api::Error& message) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); 508 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION);
505 } 509 }
506 510
507 void BluetoothHostPairingController::AuthorizePairing( 511 void BluetoothHostPairingController::AuthorizePairing(
508 device::BluetoothDevice* device) { 512 device::BluetoothDevice* device) {
509 // Disallow unknown device. 513 // Disallow unknown device.
510 device->RejectPairing(); 514 device->RejectPairing();
511 } 515 }
512 516
513 } // namespace pairing_chromeos 517 } // namespace pairing_chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698