OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/update_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/update_screen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 void UpdateScreen::OnPortalDetectionCompleted( | 226 void UpdateScreen::OnPortalDetectionCompleted( |
227 const NetworkState* network, | 227 const NetworkState* network, |
228 const NetworkPortalDetector::CaptivePortalState& state) { | 228 const NetworkPortalDetector::CaptivePortalState& state) { |
229 LOG(WARNING) << "UpdateScreen::PortalDetectionCompleted(): " | 229 LOG(WARNING) << "UpdateScreen::PortalDetectionCompleted(): " |
230 << "network=" << (network ? network->path() : "") << ", " | 230 << "network=" << (network ? network->path() : "") << ", " |
231 << "state.status=" << state.status << ", " | 231 << "state.status=" << state.status << ", " |
232 << "state.response_code=" << state.response_code; | 232 << "state.response_code=" << state.response_code; |
233 | 233 |
234 // Wait for the sane detection results. | 234 // Wait for the sane detection results. |
235 if (network && | 235 if (network && |
236 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN) { | 236 state.status == captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN) { |
237 return; | 237 return; |
238 } | 238 } |
239 | 239 |
240 // Restart portal detection for the first notification about offline state. | 240 // Restart portal detection for the first notification about offline state. |
241 if ((!network || | 241 if ((!network || |
242 state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE) && | 242 state.status == captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE) && |
243 is_first_detection_notification_) { | 243 is_first_detection_notification_) { |
244 is_first_detection_notification_ = false; | 244 is_first_detection_notification_ = false; |
245 base::MessageLoop::current()->PostTask( | 245 base::MessageLoop::current()->PostTask( |
246 FROM_HERE, | 246 FROM_HERE, |
247 base::Bind( | 247 base::Bind( |
248 base::IgnoreResult(&NetworkPortalDetector::StartDetectionIfIdle), | 248 base::IgnoreResult(&NetworkPortalDetector::StartDetectionIfIdle), |
249 base::Unretained(NetworkPortalDetector::Get()))); | 249 base::Unretained(NetworkPortalDetector::Get()))); |
250 return; | 250 return; |
251 } | 251 } |
252 is_first_detection_notification_ = false; | 252 is_first_detection_notification_ = false; |
253 | 253 |
254 NetworkPortalDetector::CaptivePortalStatus status = state.status; | 254 captive_portal::CaptivePortalStatus status = state.status; |
255 if (state_ == STATE_ERROR) { | 255 if (state_ == STATE_ERROR) { |
256 // In the case of online state hide error message and proceed to | 256 // In the case of online state hide error message and proceed to |
257 // the update stage. Otherwise, update error message content. | 257 // the update stage. Otherwise, update error message content. |
258 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) | 258 if (status == captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE) |
259 StartUpdateCheck(); | 259 StartUpdateCheck(); |
260 else | 260 else |
261 UpdateErrorMessage(network, status); | 261 UpdateErrorMessage(network, status); |
262 } else if (state_ == STATE_FIRST_PORTAL_CHECK) { | 262 } else if (state_ == STATE_FIRST_PORTAL_CHECK) { |
263 // In the case of online state immediately proceed to the update | 263 // In the case of online state immediately proceed to the update |
264 // stage. Otherwise, prepare and show error message. | 264 // stage. Otherwise, prepare and show error message. |
265 if (status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) { | 265 if (status == captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE) { |
266 StartUpdateCheck(); | 266 StartUpdateCheck(); |
267 } else { | 267 } else { |
268 UpdateErrorMessage(network, status); | 268 UpdateErrorMessage(network, status); |
269 ShowErrorMessage(); | 269 ShowErrorMessage(); |
270 } | 270 } |
271 } | 271 } |
272 } | 272 } |
273 | 273 |
274 void UpdateScreen::StartNetworkCheck() { | 274 void UpdateScreen::StartNetworkCheck() { |
275 // If portal detector is enabled and portal detection before AU is | 275 // If portal detector is enabled and portal detection before AU is |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 get_screen_observer()->ShowErrorScreen(); | 484 get_screen_observer()->ShowErrorScreen(); |
485 } | 485 } |
486 | 486 |
487 void UpdateScreen::HideErrorMessage() { | 487 void UpdateScreen::HideErrorMessage() { |
488 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; | 488 LOG(WARNING) << "UpdateScreen::HideErrorMessage()"; |
489 get_screen_observer()->HideErrorScreen(this); | 489 get_screen_observer()->HideErrorScreen(this); |
490 } | 490 } |
491 | 491 |
492 void UpdateScreen::UpdateErrorMessage( | 492 void UpdateScreen::UpdateErrorMessage( |
493 const NetworkState* network, | 493 const NetworkState* network, |
494 const NetworkPortalDetector::CaptivePortalStatus status) { | 494 const captive_portal::CaptivePortalStatus status) { |
495 switch (status) { | 495 switch (status) { |
496 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: | 496 case captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE: |
497 NOTREACHED(); | 497 NOTREACHED(); |
498 break; | 498 break; |
499 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: | 499 case captive_portal::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
500 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: | 500 case captive_portal::CAPTIVE_PORTAL_STATUS_OFFLINE: |
501 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, | 501 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, |
502 std::string()); | 502 std::string()); |
503 break; | 503 break; |
504 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: | 504 case captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL: |
505 DCHECK(network); | 505 DCHECK(network); |
506 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, | 506 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, |
507 network->name()); | 507 network->name()); |
508 if (is_first_portal_notification_) { | 508 if (is_first_portal_notification_) { |
509 is_first_portal_notification_ = false; | 509 is_first_portal_notification_ = false; |
510 GetErrorScreen()->FixCaptivePortal(); | 510 GetErrorScreen()->FixCaptivePortal(); |
511 } | 511 } |
512 break; | 512 break; |
513 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: | 513 case captive_portal::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
514 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, | 514 GetErrorScreen()->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
515 std::string()); | 515 std::string()); |
516 break; | 516 break; |
517 default: | 517 default: |
518 NOTREACHED(); | 518 NOTREACHED(); |
519 break; | 519 break; |
520 } | 520 } |
521 } | 521 } |
522 | 522 |
523 } // namespace chromeos | 523 } // namespace chromeos |
OLD | NEW |