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/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/base_screen_delegate.h" | 13 #include "chrome/browser/chromeos/login/screens/base_screen_delegate.h" |
| 14 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
| 15 #include "chrome/browser/chromeos/login/screens/network_error.h" |
14 #include "chrome/browser/chromeos/login/wizard_controller.h" | 16 #include "chrome/browser/chromeos/login/wizard_controller.h" |
15 #include "chromeos/chromeos_switches.h" | 17 #include "chromeos/chromeos_switches.h" |
16 #include "chromeos/network/network_state.h" | 18 #include "chromeos/network/network_state.h" |
17 #include "chromeos/network/network_state_handler.h" | 19 #include "chromeos/network/network_state_handler.h" |
18 | 20 |
19 namespace chromeos { | 21 namespace chromeos { |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
23 NetworkPortalDetector::CaptivePortalStatus GetCaptivePortalStatus() { | 25 NetworkPortalDetector::CaptivePortalStatus GetCaptivePortalStatus() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 auto_enrollment_controller_->Retry(); | 177 auto_enrollment_controller_->Retry(); |
176 } | 178 } |
177 | 179 |
178 bool AutoEnrollmentCheckScreen::UpdateCaptivePortalStatus( | 180 bool AutoEnrollmentCheckScreen::UpdateCaptivePortalStatus( |
179 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status) { | 181 NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status) { |
180 switch (new_captive_portal_status) { | 182 switch (new_captive_portal_status) { |
181 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | 183 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
182 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | 184 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: |
183 return false; | 185 return false; |
184 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: | 186 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: |
185 ShowErrorScreen(ErrorScreen::ERROR_STATE_OFFLINE); | 187 ShowErrorScreen(NetworkError::ERROR_STATE_OFFLINE); |
186 return true; | 188 return true; |
187 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: | 189 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: |
188 ShowErrorScreen(ErrorScreen::ERROR_STATE_PORTAL); | 190 ShowErrorScreen(NetworkError::ERROR_STATE_PORTAL); |
189 if (captive_portal_status_ != new_captive_portal_status) | 191 if (captive_portal_status_ != new_captive_portal_status) |
190 get_base_screen_delegate()->GetErrorScreen()->FixCaptivePortal(); | 192 get_base_screen_delegate()->GetErrorScreen()->FixCaptivePortal(); |
191 return true; | 193 return true; |
192 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | 194 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
193 ShowErrorScreen(ErrorScreen::ERROR_STATE_PROXY); | 195 ShowErrorScreen(NetworkError::ERROR_STATE_PROXY); |
194 return true; | 196 return true; |
195 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: | 197 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_COUNT: |
196 NOTREACHED() << "Bad status: CAPTIVE_PORTAL_STATUS_COUNT"; | 198 NOTREACHED() << "Bad status: CAPTIVE_PORTAL_STATUS_COUNT"; |
197 return false; | 199 return false; |
198 } | 200 } |
199 | 201 |
200 // Return is required to avoid compiler warning. | 202 // Return is required to avoid compiler warning. |
201 NOTREACHED() << "Bad status " << new_captive_portal_status; | 203 NOTREACHED() << "Bad status " << new_captive_portal_status; |
202 return false; | 204 return false; |
203 } | 205 } |
204 | 206 |
205 bool AutoEnrollmentCheckScreen::UpdateAutoEnrollmentState( | 207 bool AutoEnrollmentCheckScreen::UpdateAutoEnrollmentState( |
206 policy::AutoEnrollmentState new_auto_enrollment_state) { | 208 policy::AutoEnrollmentState new_auto_enrollment_state) { |
207 switch (new_auto_enrollment_state) { | 209 switch (new_auto_enrollment_state) { |
208 case policy::AUTO_ENROLLMENT_STATE_IDLE: | 210 case policy::AUTO_ENROLLMENT_STATE_IDLE: |
209 // The client should have been started already. | 211 // The client should have been started already. |
210 NOTREACHED(); | 212 NOTREACHED(); |
211 return false; | 213 return false; |
212 case policy::AUTO_ENROLLMENT_STATE_PENDING: | 214 case policy::AUTO_ENROLLMENT_STATE_PENDING: |
213 case policy::AUTO_ENROLLMENT_STATE_SERVER_ERROR: | 215 case policy::AUTO_ENROLLMENT_STATE_SERVER_ERROR: |
214 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT: | 216 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT: |
215 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: | 217 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: |
216 return false; | 218 return false; |
217 case policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR: | 219 case policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR: |
218 ShowErrorScreen(ErrorScreen::ERROR_STATE_OFFLINE); | 220 ShowErrorScreen(NetworkError::ERROR_STATE_OFFLINE); |
219 return true; | 221 return true; |
220 } | 222 } |
221 | 223 |
222 // Return is required to avoid compiler warning. | 224 // Return is required to avoid compiler warning. |
223 NOTREACHED() << "bad state " << new_auto_enrollment_state; | 225 NOTREACHED() << "bad state " << new_auto_enrollment_state; |
224 return false; | 226 return false; |
225 } | 227 } |
226 | 228 |
227 void AutoEnrollmentCheckScreen::ShowErrorScreen( | 229 void AutoEnrollmentCheckScreen::ShowErrorScreen( |
228 ErrorScreen::ErrorState error_state) { | 230 NetworkError::ErrorState error_state) { |
229 const NetworkState* network = | 231 const NetworkState* network = |
230 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); | 232 NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
231 ErrorScreen* error_screen = get_base_screen_delegate()->GetErrorScreen(); | 233 ErrorScreen* error_screen = get_base_screen_delegate()->GetErrorScreen(); |
232 error_screen->SetUIState(ErrorScreen::UI_STATE_AUTO_ENROLLMENT_ERROR); | 234 error_screen->SetUIState(NetworkError::UI_STATE_AUTO_ENROLLMENT_ERROR); |
233 error_screen->AllowGuestSignin(true); | 235 error_screen->AllowGuestSignin(true); |
234 error_screen->SetErrorState(error_state, | 236 error_screen->SetErrorState(error_state, |
235 network ? network->name() : std::string()); | 237 network ? network->name() : std::string()); |
236 get_base_screen_delegate()->ShowErrorScreen(); | 238 get_base_screen_delegate()->ShowErrorScreen(); |
237 histogram_helper_->OnErrorShow(error_state); | 239 histogram_helper_->OnErrorShow(error_state); |
238 } | 240 } |
239 | 241 |
240 void AutoEnrollmentCheckScreen::SignalCompletion() { | 242 void AutoEnrollmentCheckScreen::SignalCompletion() { |
241 NetworkPortalDetector::Get()->RemoveObserver(this); | 243 NetworkPortalDetector::Get()->RemoveObserver(this); |
242 auto_enrollment_progress_subscription_.reset(); | 244 auto_enrollment_progress_subscription_.reset(); |
(...skipping 18 matching lines...) Expand all Loading... |
261 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT: | 263 case policy::AUTO_ENROLLMENT_STATE_TRIGGER_ENROLLMENT: |
262 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: | 264 case policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT: |
263 // Decision made, ready to proceed. | 265 // Decision made, ready to proceed. |
264 return true; | 266 return true; |
265 } | 267 } |
266 NOTREACHED(); | 268 NOTREACHED(); |
267 return false; | 269 return false; |
268 } | 270 } |
269 | 271 |
270 } // namespace chromeos | 272 } // namespace chromeos |
OLD | NEW |