Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / chromeos / login / screens / host_pairing_screen.cc
blobfba3190cacb25820925d60538afca2e7efed7b8a
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"
11 namespace chromeos {
13 using namespace host_pairing;
14 using namespace pairing_chromeos;
16 HostPairingScreen::HostPairingScreen(
17 BaseScreenDelegate* base_screen_delegate,
18 Delegate* delegate,
19 HostPairingScreenActor* actor,
20 pairing_chromeos::HostPairingController* remora_controller)
21 : BaseScreen(base_screen_delegate),
22 delegate_(delegate),
23 actor_(actor),
24 remora_controller_(remora_controller),
25 current_stage_(HostPairingController::STAGE_NONE) {
26 actor_->SetDelegate(this);
27 remora_controller_->AddObserver(this);
30 HostPairingScreen::~HostPairingScreen() {
31 if (actor_)
32 actor_->SetDelegate(NULL);
33 remora_controller_->RemoveObserver(this);
36 void HostPairingScreen::CommitContextChanges() {
37 if (!context_.HasChanges())
38 return;
39 base::DictionaryValue diff;
40 context_.GetChangesAndReset(&diff);
41 if (actor_)
42 actor_->OnContextChanged(diff);
45 void HostPairingScreen::PrepareToShow() {
48 void HostPairingScreen::Show() {
49 if (actor_)
50 actor_->Show();
51 PairingStageChanged(remora_controller_->GetCurrentStage());
54 void HostPairingScreen::Hide() {
55 if (actor_)
56 actor_->Hide();
59 std::string HostPairingScreen::GetName() const {
60 return WizardController::kHostPairingScreenName;
63 void HostPairingScreen::PairingStageChanged(Stage new_stage) {
64 std::string desired_page;
65 switch (new_stage) {
66 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER:
67 case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: {
68 desired_page = kPageWelcome;
69 break;
71 case HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: {
72 desired_page = kPageCodeConfirmation;
73 context_.SetString(kContextKeyConfirmationCode,
74 remora_controller_->GetConfirmationCode());
75 break;
77 default:
78 break;
80 current_stage_ = new_stage;
81 context_.SetString(kContextKeyDeviceName,
82 remora_controller_->GetDeviceName());
83 context_.SetString(kContextKeyPage, desired_page);
84 CommitContextChanges();
87 void HostPairingScreen::ConfigureHostRequested(
88 bool accepted_eula,
89 const std::string& lang,
90 const std::string& timezone,
91 bool send_reports,
92 const std::string& keyboard_layout) {
93 VLOG(1) << "ConfigureHostMessage language=" << lang
94 << ", timezone=" << timezone
95 << ", keyboard_layout=" << keyboard_layout;
97 remora_controller_->RemoveObserver(this);
98 if (delegate_) {
99 delegate_->ConfigureHostRequested(
100 accepted_eula, lang, timezone, send_reports, keyboard_layout);
102 Finish(WizardController::HOST_PAIRING_FINISHED);
105 void HostPairingScreen::AddNetworkRequested(const std::string& onc_spec) {
106 if (delegate_)
107 delegate_->AddNetworkRequested(onc_spec);
110 void HostPairingScreen::EnrollHostRequested(const std::string& auth_token) {
111 NOTREACHED();
114 void HostPairingScreen::OnActorDestroyed(HostPairingScreenActor* actor) {
115 if (actor_ == actor)
116 actor_ = NULL;
119 } // namespace chromeos