OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ui/webui/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.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/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 bool IsSigninScreen(const OobeUI::Screen screen) { | 147 bool IsSigninScreen(const OobeUI::Screen screen) { |
148 return screen == OobeUI::SCREEN_GAIA_SIGNIN || | 148 return screen == OobeUI::SCREEN_GAIA_SIGNIN || |
149 screen == OobeUI::SCREEN_ACCOUNT_PICKER; | 149 screen == OobeUI::SCREEN_ACCOUNT_PICKER; |
150 } | 150 } |
151 | 151 |
152 // Returns true if |state| is related to the sign-in screen errors. | 152 // Returns true if |state| is related to the sign-in screen errors. |
153 bool IsSigninScreenError(ErrorScreenActor::State state) { | 153 bool IsSigninScreenError(ErrorScreenActor::State state) { |
154 return state == ErrorScreenActor::STATE_PROXY_ERROR || | 154 return state == ErrorScreenActor::STATE_PROXY_ERROR || |
155 state == ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR || | 155 state == ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR || |
| 156 state == ErrorScreenActor::STATE_TIMEOUT_ERROR || |
156 state == ErrorScreenActor::STATE_OFFLINE_ERROR; | 157 state == ErrorScreenActor::STATE_OFFLINE_ERROR; |
157 } | 158 } |
158 | 159 |
159 // Returns a pointer to a Network instance by service path or NULL if | 160 // Returns a pointer to a Network instance by service path or NULL if |
160 // network can not be found. | 161 // network can not be found. |
161 Network* FindNetworkByPath(const std::string& service_path) { | 162 Network* FindNetworkByPath(const std::string& service_path) { |
162 CrosLibrary* cros = CrosLibrary::Get(); | 163 CrosLibrary* cros = CrosLibrary::Get(); |
163 if (!cros) | 164 if (!cros) |
164 return NULL; | 165 return NULL; |
165 NetworkLibrary* network_library = cros->GetNetworkLibrary(); | 166 NetworkLibrary* network_library = cros->GetNetworkLibrary(); |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 base::TimeDelta::FromSeconds(kConnectingTimeoutSec)); | 497 base::TimeDelta::FromSeconds(kConnectingTimeoutSec)); |
497 } | 498 } |
498 return; | 499 return; |
499 } | 500 } |
500 connecting_closure_.Cancel(); | 501 connecting_closure_.Cancel(); |
501 | 502 |
502 bool is_online = (state == NetworkStateInformer::ONLINE); | 503 bool is_online = (state == NetworkStateInformer::ONLINE); |
503 bool is_under_captive_portal = | 504 bool is_under_captive_portal = |
504 (state == NetworkStateInformer::CAPTIVE_PORTAL); | 505 (state == NetworkStateInformer::CAPTIVE_PORTAL); |
505 bool is_proxy_error = IsProxyError(state, reason); | 506 bool is_proxy_error = IsProxyError(state, reason); |
506 bool is_timeout = (reason == ErrorScreenActor::kErrorReasonLoadingTimeout); | 507 bool is_gaia_loading_timeout = |
| 508 (reason == ErrorScreenActor::kErrorReasonLoadingTimeout); |
507 bool is_gaia_signin = | 509 bool is_gaia_signin = |
508 (IsSigninScreen(GetCurrentScreen()) || IsSigninScreenHiddenByError()) && | 510 (IsSigninScreen(GetCurrentScreen()) || IsSigninScreenHiddenByError()) && |
509 ui_state_ == UI_STATE_GAIA_SIGNIN; | 511 ui_state_ == UI_STATE_GAIA_SIGNIN; |
510 bool is_gaia_reloaded = false; | 512 bool is_gaia_reloaded = false; |
511 bool error_screen_should_overlay = !offline_login_active_ && IsGaiaLogin(); | 513 bool error_screen_should_overlay = !offline_login_active_ && IsGaiaLogin(); |
512 | 514 |
513 // Reload frame if network is changed. | 515 // Reload frame if network is changed. |
514 if (reason == ErrorScreenActor::kErrorReasonNetworkChanged) { | 516 if (reason == ErrorScreenActor::kErrorReasonNetworkChanged) { |
515 if (is_online && | 517 if (is_online && |
516 last_network_state_ != NetworkStateInformer::ONLINE && | 518 last_network_state_ != NetworkStateInformer::ONLINE && |
517 is_gaia_signin && !is_gaia_reloaded) { | 519 is_gaia_signin && !is_gaia_reloaded) { |
518 // Schedules a immediate retry. | 520 // Schedules a immediate retry. |
519 LOG(WARNING) << "Retry page load since network has been changed."; | 521 LOG(WARNING) << "Retry page load since network has been changed."; |
520 ReloadGaiaScreen(); | 522 ReloadGaiaScreen(); |
521 is_gaia_reloaded = true; | 523 is_gaia_reloaded = true; |
522 } | 524 } |
523 } | 525 } |
524 last_network_state_ = state; | 526 last_network_state_ = state; |
525 | 527 |
526 if (reason == ErrorScreenActor::kErrorReasonProxyConfigChanged && | 528 if (reason == ErrorScreenActor::kErrorReasonProxyConfigChanged && |
527 error_screen_should_overlay && | 529 error_screen_should_overlay && |
528 is_gaia_signin && !is_gaia_reloaded) { | 530 is_gaia_signin && !is_gaia_reloaded) { |
529 // Schedules a immediate retry. | 531 // Schedules a immediate retry. |
530 LOG(WARNING) << "Retry page load since proxy settings has been changed."; | 532 LOG(WARNING) << "Retry page load since proxy settings has been changed."; |
531 ReloadGaiaScreen(); | 533 ReloadGaiaScreen(); |
532 is_gaia_reloaded = true; | 534 is_gaia_reloaded = true; |
533 } | 535 } |
534 | 536 |
535 // Fake portal state for loading timeout. | 537 if (reason == ErrorScreenActor::kErrorReasonLoadingTimeout) |
536 if (reason == ErrorScreenActor::kErrorReasonLoadingTimeout) { | |
537 is_online = false; | 538 is_online = false; |
538 is_under_captive_portal = true; | |
539 } | |
540 | 539 |
541 // Portal was detected via generate_204 redirect on Chrome side. | 540 // Portal was detected via generate_204 redirect on Chrome side. |
542 // Subsequent call to show dialog if it's already shown does nothing. | 541 // Subsequent call to show dialog if it's already shown does nothing. |
543 if (reason == ErrorScreenActor::kErrorReasonPortalDetected) { | 542 if (reason == ErrorScreenActor::kErrorReasonPortalDetected) { |
544 is_online = false; | 543 is_online = false; |
545 is_under_captive_portal = true; | 544 is_under_captive_portal = true; |
546 } | 545 } |
547 | 546 |
| 547 if (is_online || !is_under_captive_portal) |
| 548 error_screen_actor_->HideCaptivePortal(); |
| 549 |
548 if (!is_online && is_gaia_signin && !offline_login_active_) { | 550 if (!is_online && is_gaia_signin && !offline_login_active_) { |
549 LOG(WARNING) << "Show offline message: state=" << state << ", " | 551 LOG(WARNING) << "Show offline message: state=" << state << ", " |
550 << "network_id=" << network_id << ", " | 552 << "network_id=" << network_id << ", " |
551 << "reason=" << reason << ", " | 553 << "reason=" << reason << ", " |
552 << "is_under_captive_portal=" << is_under_captive_portal; | 554 << "is_under_captive_portal=" << is_under_captive_portal; |
553 if (is_under_captive_portal && !is_proxy_error) { | 555 if (is_proxy_error) { |
| 556 error_screen_actor_->ShowProxyError(); |
| 557 } else if (is_under_captive_portal) { |
554 // Do not bother a user with obsessive captive portal showing. This | 558 // Do not bother a user with obsessive captive portal showing. This |
555 // check makes captive portal being shown only once: either when error | 559 // check makes captive portal being shown only once: either when error |
556 // screen is shown for the first time or when switching from another | 560 // screen is shown for the first time or when switching from another |
557 // error screen (offline, proxy). | 561 // error screen (offline, proxy). |
558 if (!IsGaiaLogin() || | 562 if (!IsGaiaLogin() || |
559 (error_screen_actor_->state() != | 563 (error_screen_actor_->state() != |
560 ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR)) { | 564 ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR)) { |
561 // In case of timeout we're suspecting that network might be | 565 error_screen_actor_->FixCaptivePortal(); |
562 // a captive portal but would like to check that first. | |
563 // Otherwise (signal from shill / generate_204 got redirected) | |
564 // show dialog right away. | |
565 if (is_timeout) | |
566 error_screen_actor_->FixCaptivePortal(); | |
567 else | |
568 error_screen_actor_->ShowCaptivePortal(); | |
569 } | 566 } |
570 } else { | 567 std::string network_name = GetNetworkName(service_path); |
571 error_screen_actor_->HideCaptivePortal(); | 568 error_screen_actor_->ShowCaptivePortalError(network_name); |
572 } | 569 } else if (is_gaia_loading_timeout) { |
573 | 570 error_screen_actor_->ShowTimeoutError(); |
574 if (is_under_captive_portal) { | |
575 if (is_proxy_error) { | |
576 error_screen_actor_->ShowProxyError(); | |
577 } else { | |
578 std::string network_name = GetNetworkName(service_path); | |
579 error_screen_actor_->ShowCaptivePortalError(network_name); | |
580 } | |
581 } else if (is_proxy_error) { | |
582 error_screen_actor_->ShowProxyError(); | |
583 } else { | 571 } else { |
584 error_screen_actor_->ShowOfflineError(); | 572 error_screen_actor_->ShowOfflineError(); |
585 } | 573 } |
586 | 574 |
587 bool guest_signin_allowed = IsGuestSigninAllowed() && | 575 bool guest_signin_allowed = IsGuestSigninAllowed() && |
588 IsSigninScreenError(error_screen_actor_->state()); | 576 IsSigninScreenError(error_screen_actor_->state()); |
589 error_screen_actor_->AllowGuestSignin(guest_signin_allowed); | 577 error_screen_actor_->AllowGuestSignin(guest_signin_allowed); |
590 | 578 |
591 bool offline_login_allowed = IsOfflineLoginAllowed() && | 579 bool offline_login_allowed = IsOfflineLoginAllowed() && |
592 IsSigninScreenError(error_screen_actor_->state()); | 580 IsSigninScreenError(error_screen_actor_->state()) && |
| 581 error_screen_actor_->state() != ErrorScreenActor::STATE_TIMEOUT_ERROR; |
593 error_screen_actor_->AllowOfflineLogin(offline_login_allowed); | 582 error_screen_actor_->AllowOfflineLogin(offline_login_allowed); |
594 | 583 |
595 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) { | 584 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) { |
596 DictionaryValue params; | 585 DictionaryValue params; |
597 params.SetInteger("lastNetworkType", static_cast<int>(connection_type)); | 586 params.SetInteger("lastNetworkType", static_cast<int>(connection_type)); |
598 error_screen_actor_->Show(OobeUI::SCREEN_GAIA_SIGNIN, ¶ms); | 587 error_screen_actor_->Show(OobeUI::SCREEN_GAIA_SIGNIN, ¶ms); |
599 } | 588 } |
600 } else { | 589 } else { |
601 error_screen_actor_->HideCaptivePortal(); | |
602 | |
603 if (IsSigninScreenHiddenByError()) { | 590 if (IsSigninScreenHiddenByError()) { |
604 LOG(WARNING) << "Hide offline message. state=" << state << ", " | 591 LOG(WARNING) << "Hide offline message. state=" << state << ", " |
605 << "network_id=" << network_id << ", " | 592 << "network_id=" << network_id << ", " |
606 << "reason=" << reason; | 593 << "reason=" << reason; |
607 error_screen_actor_->Hide(); | 594 error_screen_actor_->Hide(); |
608 | 595 |
609 // Forces a reload for Gaia screen on hiding error message. | 596 // Forces a reload for Gaia screen on hiding error message. |
610 if (is_gaia_signin && !is_gaia_reloaded) { | 597 if (is_gaia_signin && !is_gaia_reloaded) { |
611 ReloadGaiaScreen(); | 598 ReloadGaiaScreen(); |
612 is_gaia_reloaded = true; | 599 is_gaia_reloaded = true; |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (!cros_settings) | 1660 if (!cros_settings) |
1674 return false; | 1661 return false; |
1675 | 1662 |
1676 // Offline login is allowed only when user pods are hidden. | 1663 // Offline login is allowed only when user pods are hidden. |
1677 bool show_pods; | 1664 bool show_pods; |
1678 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1665 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
1679 return !show_pods; | 1666 return !show_pods; |
1680 } | 1667 } |
1681 | 1668 |
1682 } // namespace chromeos | 1669 } // namespace chromeos |
OLD | NEW |