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/controller_pairing_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/controller_pairing_screen.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/login/wizard_controller.h" | 9 #include "chrome/browser/chromeos/login/wizard_controller.h" |
10 #include "google_apis/gaia/gaia_auth_util.h" | 10 #include "google_apis/gaia/gaia_auth_util.h" |
11 | 11 |
12 using namespace chromeos::controller_pairing; | 12 using namespace chromeos::controller_pairing; |
13 using namespace pairing_chromeos; | 13 using namespace pairing_chromeos; |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 | 16 |
17 ControllerPairingScreen::ControllerPairingScreen( | 17 ControllerPairingScreen::ControllerPairingScreen( |
18 ScreenObserver* observer, | 18 ScreenObserver* observer, |
19 ControllerPairingScreenActor* actor, | 19 ControllerPairingScreenActor* actor, |
20 ControllerPairingController* shark_controller) | 20 ControllerPairingController* shark_controller) |
21 : BaseScreen(observer), | 21 : BaseScreen(observer), |
22 actor_(actor), | 22 actor_(actor), |
23 shark_controller_(shark_controller), | 23 shark_controller_(shark_controller), |
| 24 delegate_(nullptr), |
24 current_stage_(ControllerPairingController::STAGE_NONE), | 25 current_stage_(ControllerPairingController::STAGE_NONE), |
25 device_preselected_(false) { | 26 device_preselected_(false) { |
26 actor_->SetDelegate(this); | 27 actor_->SetDelegate(this); |
27 shark_controller_->AddObserver(this); | 28 shark_controller_->AddObserver(this); |
28 } | 29 } |
29 | 30 |
30 ControllerPairingScreen::~ControllerPairingScreen() { | 31 ControllerPairingScreen::~ControllerPairingScreen() { |
31 if (actor_) | 32 if (actor_) |
32 actor_->SetDelegate(NULL); | 33 actor_->SetDelegate(NULL); |
33 shark_controller_->RemoveObserver(this); | 34 shark_controller_->RemoveObserver(this); |
34 } | 35 } |
35 | 36 |
| 37 void ControllerPairingScreen::SetDelegate(Delegate* delegate) { |
| 38 delegate_ = delegate; |
| 39 } |
| 40 |
36 void ControllerPairingScreen::CommitContextChanges() { | 41 void ControllerPairingScreen::CommitContextChanges() { |
37 if (!context_.HasChanges()) | 42 if (!context_.HasChanges()) |
38 return; | 43 return; |
39 base::DictionaryValue diff; | 44 base::DictionaryValue diff; |
40 context_.GetChangesAndReset(&diff); | 45 context_.GetChangesAndReset(&diff); |
41 if (actor_) | 46 if (actor_) |
42 actor_->OnContextChanged(diff); | 47 actor_->OnContextChanged(diff); |
43 } | 48 } |
44 | 49 |
45 bool ControllerPairingScreen::ExpectStageIs(Stage stage) const { | 50 bool ControllerPairingScreen::ExpectStageIs(Stage stage) const { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 desired_page = kPageEstablishingConnectionError; | 97 desired_page = kPageEstablishingConnectionError; |
93 break; | 98 break; |
94 } | 99 } |
95 case ControllerPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: { | 100 case ControllerPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: { |
96 desired_page = kPageCodeConfirmation; | 101 desired_page = kPageCodeConfirmation; |
97 context_.SetString(kContextKeyConfirmationCode, | 102 context_.SetString(kContextKeyConfirmationCode, |
98 shark_controller_->GetConfirmationCode()); | 103 shark_controller_->GetConfirmationCode()); |
99 break; | 104 break; |
100 } | 105 } |
101 case ControllerPairingController::STAGE_PAIRING_DONE: { | 106 case ControllerPairingController::STAGE_PAIRING_DONE: { |
102 get_screen_observer()->SetHostConfiguration(); | 107 if (delegate_) |
| 108 delegate_->SetHostConfiguration(); |
103 break; | 109 break; |
104 } | 110 } |
105 case ControllerPairingController::STAGE_HOST_UPDATE_IN_PROGRESS: { | 111 case ControllerPairingController::STAGE_HOST_UPDATE_IN_PROGRESS: { |
106 desired_page = kPageHostUpdate; | 112 desired_page = kPageHostUpdate; |
107 break; | 113 break; |
108 } | 114 } |
109 case ControllerPairingController::STAGE_HOST_CONNECTION_LOST: { | 115 case ControllerPairingController::STAGE_HOST_CONNECTION_LOST: { |
110 desired_page = kPageHostConnectionLost; | 116 desired_page = kPageHostConnectionLost; |
111 break; | 117 break; |
112 } | 118 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 ++key) { | 214 ++key) { |
209 if (*key == kContextKeySelectedDevice) { | 215 if (*key == kContextKeySelectedDevice) { |
210 context_.SetBoolean(kContextKeyControlsDisabled, | 216 context_.SetBoolean(kContextKeyControlsDisabled, |
211 context_.GetString(*key).empty()); | 217 context_.GetString(*key).empty()); |
212 CommitContextChanges(); | 218 CommitContextChanges(); |
213 } | 219 } |
214 } | 220 } |
215 } | 221 } |
216 | 222 |
217 } // namespace chromeos | 223 } // namespace chromeos |
OLD | NEW |