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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/screens/host_pairing_screen.h"
7 #include "base/command_line.h"
8 #include "chrome/browser/chromeos/login/wizard_controller.h"
9 #include "components/pairing/host_pairing_controller.h"
13 using namespace host_pairing;
14 using namespace pairing_chromeos;
16 HostPairingScreen::HostPairingScreen(
17 BaseScreenDelegate* base_screen_delegate,
19 HostPairingScreenActor* actor,
20 pairing_chromeos::HostPairingController* remora_controller)
21 : BaseScreen(base_screen_delegate),
24 remora_controller_(remora_controller),
25 current_stage_(HostPairingController::STAGE_NONE) {
26 actor_->SetDelegate(this);
27 remora_controller_->AddObserver(this);
30 HostPairingScreen::~HostPairingScreen() {
32 actor_->SetDelegate(NULL);
33 remora_controller_->RemoveObserver(this);
36 void HostPairingScreen::CommitContextChanges() {
37 if (!context_.HasChanges())
39 base::DictionaryValue diff;
40 context_.GetChangesAndReset(&diff);
42 actor_->OnContextChanged(diff);
45 void HostPairingScreen::PrepareToShow() {
48 void HostPairingScreen::Show() {
51 PairingStageChanged(remora_controller_->GetCurrentStage());
54 void HostPairingScreen::Hide() {
59 std::string HostPairingScreen::GetName() const {
60 return WizardController::kHostPairingScreenName;
63 void HostPairingScreen::PairingStageChanged(Stage new_stage) {
64 std::string desired_page;
66 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER:
67 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: {
68 desired_page = kPageWelcome;
71 case HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: {
72 desired_page = kPageCodeConfirmation;
73 context_.SetString(kContextKeyConfirmationCode,
74 remora_controller_->GetConfirmationCode());
80 current_stage_ = new_stage;
81 context_.SetString(kContextKeyDeviceName,
82 remora_controller_->GetDeviceName());
83 context_.SetString(kContextKeyPage, desired_page);
84 CommitContextChanges();
87 void HostPairingScreen::ConfigureHost(bool accepted_eula,
88 const std::string& lang,
89 const std::string& timezone,
91 const std::string& keyboard_layout) {
92 VLOG(1) << "ConfigureHostMessage language=" << lang
93 << ", timezone=" << timezone
94 << ", keyboard_layout=" << keyboard_layout;
96 remora_controller_->RemoveObserver(this);
98 delegate_->ConfigureHost(
99 accepted_eula, lang, timezone, send_reports, keyboard_layout);
101 get_base_screen_delegate()->OnExit(WizardController::HOST_PAIRING_FINISHED);
104 void HostPairingScreen::EnrollHost(const std::string& auth_token) {
108 void HostPairingScreen::OnActorDestroyed(HostPairingScreenActor* actor) {
113 } // namespace chromeos