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

Side by Side Diff: chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.cc

Issue 679133002: ScreenObserver is renamed to BaseScreenDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 6 years, 1 month 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 "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen. h" 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen. h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h" 11 #include "chrome/browser/chromeos/login/error_screens_histogram_helper.h"
12 #include "chrome/browser/chromeos/login/screen_manager.h" 12 #include "chrome/browser/chromeos/login/screen_manager.h"
13 #include "chrome/browser/chromeos/login/screens/screen_observer.h" 13 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h"
14 #include "chrome/browser/chromeos/login/wizard_controller.h" 14 #include "chrome/browser/chromeos/login/wizard_controller.h"
15 #include "chromeos/chromeos_switches.h" 15 #include "chromeos/chromeos_switches.h"
16 #include "chromeos/network/network_state.h" 16 #include "chromeos/network/network_state.h"
17 #include "chromeos/network/network_state_handler.h" 17 #include "chromeos/network/network_state_handler.h"
18 18
19 namespace chromeos { 19 namespace chromeos {
20 20
21 // static 21 // static
22 AutoEnrollmentCheckScreen* AutoEnrollmentCheckScreen::Get( 22 AutoEnrollmentCheckScreen* AutoEnrollmentCheckScreen::Get(
23 ScreenManager* manager) { 23 ScreenManager* manager) {
24 return static_cast<AutoEnrollmentCheckScreen*>( 24 return static_cast<AutoEnrollmentCheckScreen*>(
25 manager->GetScreen(WizardController::kAutoEnrollmentCheckScreenName)); 25 manager->GetScreen(WizardController::kAutoEnrollmentCheckScreenName));
26 } 26 }
27 27
28 AutoEnrollmentCheckScreen::AutoEnrollmentCheckScreen( 28 AutoEnrollmentCheckScreen::AutoEnrollmentCheckScreen(
29 ScreenObserver* observer, 29 BaseScreenDelegate* base_screen_delegate,
30 AutoEnrollmentCheckScreenActor* actor) 30 AutoEnrollmentCheckScreenActor* actor)
31 : BaseScreen(observer), 31 : BaseScreen(base_screen_delegate),
32 actor_(actor), 32 actor_(actor),
33 captive_portal_status_( 33 captive_portal_status_(
34 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN), 34 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN),
35 auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE), 35 auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE),
36 histogram_helper_(new ErrorScreensHistogramHelper("Enrollment")) { 36 histogram_helper_(new ErrorScreensHistogramHelper("Enrollment")) {
37 if (actor_) 37 if (actor_)
38 actor_->SetDelegate(this); 38 actor_->SetDelegate(this);
39 } 39 }
40 40
41 AutoEnrollmentCheckScreen::~AutoEnrollmentCheckScreen() { 41 AutoEnrollmentCheckScreen::~AutoEnrollmentCheckScreen() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 void AutoEnrollmentCheckScreen::Hide() { 94 void AutoEnrollmentCheckScreen::Hide() {
95 } 95 }
96 96
97 std::string AutoEnrollmentCheckScreen::GetName() const { 97 std::string AutoEnrollmentCheckScreen::GetName() const {
98 return WizardController::kAutoEnrollmentCheckScreenName; 98 return WizardController::kAutoEnrollmentCheckScreenName;
99 } 99 }
100 100
101 void AutoEnrollmentCheckScreen::OnExit() { 101 void AutoEnrollmentCheckScreen::OnExit() {
102 get_screen_observer()->OnExit( 102 get_base_screen_delegate()->OnExit(
103 ScreenObserver::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED); 103 BaseScreenDelegate::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED);
104 } 104 }
105 105
106 void AutoEnrollmentCheckScreen::OnActorDestroyed( 106 void AutoEnrollmentCheckScreen::OnActorDestroyed(
107 AutoEnrollmentCheckScreenActor* actor) { 107 AutoEnrollmentCheckScreenActor* actor) {
108 if (actor_ == actor) 108 if (actor_ == actor)
109 actor_ = NULL; 109 actor_ = NULL;
110 } 110 }
111 111
112 void AutoEnrollmentCheckScreen::OnPortalDetectionCompleted( 112 void AutoEnrollmentCheckScreen::OnPortalDetectionCompleted(
113 const NetworkState* /* network */, 113 const NetworkState* /* network */,
114 const NetworkPortalDetector::CaptivePortalState& state) { 114 const NetworkPortalDetector::CaptivePortalState& state) {
115 UpdateState(state.status, auto_enrollment_state_); 115 UpdateState(state.status, auto_enrollment_state_);
116 } 116 }
117 117
118 void AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed( 118 void AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed(
119 policy::AutoEnrollmentState state) { 119 policy::AutoEnrollmentState state) {
120 UpdateState(captive_portal_status_, state); 120 UpdateState(captive_portal_status_, state);
121 } 121 }
122 122
123 void AutoEnrollmentCheckScreen::UpdateState( 123 void AutoEnrollmentCheckScreen::UpdateState(
124 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status, 124 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status,
125 policy::AutoEnrollmentState new_auto_enrollment_state) { 125 policy::AutoEnrollmentState new_auto_enrollment_state) {
126 // Configure the error screen to show the approriate error message. 126 // Configure the error screen to show the approriate error message.
127 if (!UpdateCaptivePortalStatus(new_captive_portal_status)) 127 if (!UpdateCaptivePortalStatus(new_captive_portal_status))
128 UpdateAutoEnrollmentState(new_auto_enrollment_state); 128 UpdateAutoEnrollmentState(new_auto_enrollment_state);
129 129
130 // Update the connecting indicator. 130 // Update the connecting indicator.
131 ErrorScreen* error_screen = get_screen_observer()->GetErrorScreen(); 131 ErrorScreen* error_screen = get_base_screen_delegate()->GetErrorScreen();
132 error_screen->ShowConnectingIndicator( 132 error_screen->ShowConnectingIndicator(
133 new_auto_enrollment_state == policy::AUTO_ENROLLMENT_STATE_PENDING); 133 new_auto_enrollment_state == policy::AUTO_ENROLLMENT_STATE_PENDING);
134 134
135 // Determine whether a retry is in order. 135 // Determine whether a retry is in order.
136 bool retry = (new_captive_portal_status == 136 bool retry = (new_captive_portal_status ==
137 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) && 137 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) &&
138 (captive_portal_status_ != 138 (captive_portal_status_ !=
139 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE); 139 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE);
140 140
141 // Save the new state. 141 // Save the new state.
(...skipping 28 matching lines...) Expand all
170 switch (new_captive_portal_status) { 170 switch (new_captive_portal_status) {
171 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: 171 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN:
172 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: 172 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE:
173 return false; 173 return false;
174 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: 174 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE:
175 ShowErrorScreen(ErrorScreen::ERROR_STATE_OFFLINE); 175 ShowErrorScreen(ErrorScreen::ERROR_STATE_OFFLINE);
176 return true; 176 return true;
177 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: 177 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL:
178 ShowErrorScreen(ErrorScreen::ERROR_STATE_PORTAL); 178 ShowErrorScreen(ErrorScreen::ERROR_STATE_PORTAL);
179 if (captive_portal_status_ != new_captive_portal_status) 179 if (captive_portal_status_ != new_captive_portal_status)
180 get_screen_observer()->GetErrorScreen()->FixCaptivePortal(); 180 get_base_screen_delegate()->GetErrorScreen()->FixCaptivePortal();
181 return true; 181 return true;
182 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: 182 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED:
183 ShowErrorScreen(ErrorScreen::ERROR_STATE_PROXY); 183 ShowErrorScreen(ErrorScreen::ERROR_STATE_PROXY);
184 return true; 184 return true;
185 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: 185 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT:
186 NOTREACHED() << "Bad status: CAPTIVE_PORTAL_STATUS_COUNT"; 186 NOTREACHED() << "Bad status: CAPTIVE_PORTAL_STATUS_COUNT";
187 return false; 187 return false;
188 } 188 }
189 189
190 // Return is required to avoid compiler warning. 190 // Return is required to avoid compiler warning.
(...skipping 20 matching lines...) Expand all
211 211
212 // Return is required to avoid compiler warning. 212 // Return is required to avoid compiler warning.
213 NOTREACHED() << "bad state " << new_auto_enrollment_state; 213 NOTREACHED() << "bad state " << new_auto_enrollment_state;
214 return false; 214 return false;
215 } 215 }
216 216
217 void AutoEnrollmentCheckScreen::ShowErrorScreen( 217 void AutoEnrollmentCheckScreen::ShowErrorScreen(
218 ErrorScreen::ErrorState error_state) { 218 ErrorScreen::ErrorState error_state) {
219 const NetworkState* network = 219 const NetworkState* network =
220 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); 220 NetworkHandler::Get()->network_state_handler()->DefaultNetwork();
221 ErrorScreen* error_screen = get_screen_observer()->GetErrorScreen(); 221 ErrorScreen* error_screen = get_base_screen_delegate()->GetErrorScreen();
222 error_screen->SetUIState(ErrorScreen::UI_STATE_AUTO_ENROLLMENT_ERROR); 222 error_screen->SetUIState(ErrorScreen::UI_STATE_AUTO_ENROLLMENT_ERROR);
223 error_screen->AllowGuestSignin(true); 223 error_screen->AllowGuestSignin(true);
224 error_screen->SetErrorState(error_state, 224 error_screen->SetErrorState(error_state,
225 network ? network->name() : std::string()); 225 network ? network->name() : std::string());
226 get_screen_observer()->ShowErrorScreen(); 226 get_base_screen_delegate()->ShowErrorScreen();
227 histogram_helper_->OnErrorShow(error_state); 227 histogram_helper_->OnErrorShow(error_state);
228 } 228 }
229 229
230 void AutoEnrollmentCheckScreen::SignalCompletion() { 230 void AutoEnrollmentCheckScreen::SignalCompletion() {
231 NetworkPortalDetector::Get()->RemoveObserver(this); 231 NetworkPortalDetector::Get()->RemoveObserver(this);
232 auto_enrollment_progress_subscription_.reset(); 232 auto_enrollment_progress_subscription_.reset();
233 get_screen_observer()->OnExit( 233 get_base_screen_delegate()->OnExit(
234 ScreenObserver::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED); 234 BaseScreenDelegate::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED);
235 } 235 }
236 236
237 } // namespace chromeos 237 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698