| 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 "chrome/browser/chromeos/login/screens/host_pairing_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/host_pairing_screen.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chromeos/login/wizard_controller.h" | 8 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 9 #include "components/pairing/host_pairing_controller.h" | 9 #include "components/pairing/host_pairing_controller.h" |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 std::string HostPairingScreen::GetName() const { | 57 std::string HostPairingScreen::GetName() const { |
| 58 return WizardController::kHostPairingScreenName; | 58 return WizardController::kHostPairingScreenName; |
| 59 } | 59 } |
| 60 | 60 |
| 61 void HostPairingScreen::PairingStageChanged(Stage new_stage) { | 61 void HostPairingScreen::PairingStageChanged(Stage new_stage) { |
| 62 DCHECK(new_stage != current_stage_); | 62 DCHECK(new_stage != current_stage_); |
| 63 | 63 |
| 64 std::string desired_page; | 64 std::string desired_page; |
| 65 switch (new_stage) { | 65 switch (new_stage) { |
| 66 case HostPairingController::STAGE_NONE: |
| 67 case HostPairingController::STAGE_INITIALIZATION_ERROR: { |
| 68 break; |
| 69 } |
| 66 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER: | 70 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER: |
| 67 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: { | 71 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: { |
| 68 desired_page = kPageWelcome; | 72 desired_page = kPageWelcome; |
| 69 break; | 73 break; |
| 70 } | 74 } |
| 71 case HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: { | 75 case HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: { |
| 72 desired_page = kPageCodeConfirmation; | 76 desired_page = kPageCodeConfirmation; |
| 73 context_.SetString(kContextKeyConfirmationCode, | 77 context_.SetString(kContextKeyConfirmationCode, |
| 74 controller_->GetConfirmationCode()); | 78 controller_->GetConfirmationCode()); |
| 75 break; | 79 break; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 91 } | 95 } |
| 92 case HostPairingController::STAGE_ENROLLMENT_ERROR: { | 96 case HostPairingController::STAGE_ENROLLMENT_ERROR: { |
| 93 desired_page = kPageEnrollmentError; | 97 desired_page = kPageEnrollmentError; |
| 94 break; | 98 break; |
| 95 } | 99 } |
| 96 case HostPairingController::STAGE_PAIRING_DONE: { | 100 case HostPairingController::STAGE_PAIRING_DONE: { |
| 97 desired_page = kPagePairingDone; | 101 desired_page = kPagePairingDone; |
| 98 break; | 102 break; |
| 99 } | 103 } |
| 100 case HostPairingController::STAGE_FINISHED: { | 104 case HostPairingController::STAGE_FINISHED: { |
| 101 get_screen_observer()->OnExit(WizardController::HOST_PAIRING_FINISHED); | 105 // This page is closed in EnrollHost. |
| 102 break; | |
| 103 } | |
| 104 default: { | |
| 105 NOTREACHED(); | |
| 106 break; | 106 break; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 current_stage_ = new_stage; | 109 current_stage_ = new_stage; |
| 110 context_.SetString(kContextKeyDeviceName, controller_->GetDeviceName()); | 110 context_.SetString(kContextKeyDeviceName, controller_->GetDeviceName()); |
| 111 context_.SetString(kContextKeyPage, desired_page); | 111 context_.SetString(kContextKeyPage, desired_page); |
| 112 CommitContextChanges(); | 112 CommitContextChanges(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void HostPairingScreen::ConfigureHost(bool accepted_eula, | 115 void HostPairingScreen::ConfigureHost(bool accepted_eula, |
| 116 const std::string& lang, | 116 const std::string& lang, |
| 117 const std::string& timezone, | 117 const std::string& timezone, |
| 118 bool send_reports, | 118 bool send_reports, |
| 119 const std::string& keyboard_layout) { | 119 const std::string& keyboard_layout) { |
| 120 // TODO(zork): Get configuration from UI and send to Host. | 120 // TODO(zork): Get configuration from UI and send to Host. |
| 121 // (http://crbug.com/405744) | 121 // (http://crbug.com/405744) |
| 122 } | 122 } |
| 123 | 123 |
| 124 void HostPairingScreen::EnrollHost(const std::string& auth_token) { | 124 void HostPairingScreen::EnrollHost(const std::string& auth_token) { |
| 125 // TODO(zork,achuith): Enroll device, send error on error. | 125 controller_->RemoveObserver(this); |
| 126 // (http://crbug.com/374990) | 126 WizardController::default_controller()->OnEnrollmentAuthTokenReceived( |
| 127 controller_->SetEnrollmentComplete(true); | 127 auth_token); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void HostPairingScreen::OnActorDestroyed(HostPairingScreenActor* actor) { | 130 void HostPairingScreen::OnActorDestroyed(HostPairingScreenActor* actor) { |
| 131 if (actor_ == actor) | 131 if (actor_ == actor) |
| 132 actor_ = NULL; | 132 actor_ = NULL; |
| 133 } | 133 } |
| 134 | 134 |
| 135 } // namespace chromeos | 135 } // namespace chromeos |
| OLD | NEW |