| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 base::TimeDelta::FromSeconds(kConnectingTimeoutSec)); | 496 base::TimeDelta::FromSeconds(kConnectingTimeoutSec)); |
| 497 } | 497 } |
| 498 return; | 498 return; |
| 499 } | 499 } |
| 500 connecting_closure_.Cancel(); | 500 connecting_closure_.Cancel(); |
| 501 | 501 |
| 502 bool is_online = (state == NetworkStateInformer::ONLINE); | 502 bool is_online = (state == NetworkStateInformer::ONLINE); |
| 503 bool is_under_captive_portal = | 503 bool is_under_captive_portal = |
| 504 (state == NetworkStateInformer::CAPTIVE_PORTAL); | 504 (state == NetworkStateInformer::CAPTIVE_PORTAL); |
| 505 bool is_proxy_error = IsProxyError(state, reason); | 505 bool is_proxy_error = IsProxyError(state, reason); |
| 506 bool is_timeout = (reason == ErrorScreenActor::kErrorReasonLoadingTimeout); | 506 bool is_gaia_loading_timeout = |
| 507 (reason == ErrorScreenActor::kErrorReasonLoadingTimeout); |
| 507 bool is_gaia_signin = | 508 bool is_gaia_signin = |
| 508 (IsSigninScreen(GetCurrentScreen()) || IsSigninScreenHiddenByError()) && | 509 (IsSigninScreen(GetCurrentScreen()) || IsSigninScreenHiddenByError()) && |
| 509 ui_state_ == UI_STATE_GAIA_SIGNIN; | 510 ui_state_ == UI_STATE_GAIA_SIGNIN; |
| 510 bool is_gaia_reloaded = false; | 511 bool is_gaia_reloaded = false; |
| 511 bool error_screen_should_overlay = !offline_login_active_ && IsGaiaLogin(); | 512 bool error_screen_should_overlay = !offline_login_active_ && IsGaiaLogin(); |
| 512 | 513 |
| 513 // Reload frame if network is changed. | 514 // Reload frame if network is changed. |
| 514 if (reason == ErrorScreenActor::kErrorReasonNetworkChanged) { | 515 if (reason == ErrorScreenActor::kErrorReasonNetworkChanged) { |
| 515 if (is_online && | 516 if (is_online && |
| 516 last_network_state_ != NetworkStateInformer::ONLINE && | 517 last_network_state_ != NetworkStateInformer::ONLINE && |
| 517 is_gaia_signin && !is_gaia_reloaded) { | 518 is_gaia_signin && !is_gaia_reloaded) { |
| 518 // Schedules a immediate retry. | 519 // Schedules a immediate retry. |
| 519 LOG(WARNING) << "Retry page load since network has been changed."; | 520 LOG(WARNING) << "Retry page load since network has been changed."; |
| 520 ReloadGaiaScreen(); | 521 ReloadGaiaScreen(); |
| 521 is_gaia_reloaded = true; | 522 is_gaia_reloaded = true; |
| 522 } | 523 } |
| 523 } | 524 } |
| 524 last_network_state_ = state; | 525 last_network_state_ = state; |
| 525 | 526 |
| 526 if (reason == ErrorScreenActor::kErrorReasonProxyConfigChanged && | 527 if (reason == ErrorScreenActor::kErrorReasonProxyConfigChanged && |
| 527 error_screen_should_overlay && | 528 error_screen_should_overlay && |
| 528 is_gaia_signin && !is_gaia_reloaded) { | 529 is_gaia_signin && !is_gaia_reloaded) { |
| 529 // Schedules a immediate retry. | 530 // Schedules a immediate retry. |
| 530 LOG(WARNING) << "Retry page load since proxy settings has been changed."; | 531 LOG(WARNING) << "Retry page load since proxy settings has been changed."; |
| 531 ReloadGaiaScreen(); | 532 ReloadGaiaScreen(); |
| 532 is_gaia_reloaded = true; | 533 is_gaia_reloaded = true; |
| 533 } | 534 } |
| 534 | 535 |
| 535 // Fake portal state for loading timeout. | 536 if (reason == ErrorScreenActor::kErrorReasonLoadingTimeout) |
| 536 if (reason == ErrorScreenActor::kErrorReasonLoadingTimeout) { | |
| 537 is_online = false; | 537 is_online = false; |
| 538 is_under_captive_portal = true; | |
| 539 } | |
| 540 | 538 |
| 541 // Portal was detected via generate_204 redirect on Chrome side. | 539 // Portal was detected via generate_204 redirect on Chrome side. |
| 542 // Subsequent call to show dialog if it's already shown does nothing. | 540 // Subsequent call to show dialog if it's already shown does nothing. |
| 543 if (reason == ErrorScreenActor::kErrorReasonPortalDetected) { | 541 if (reason == ErrorScreenActor::kErrorReasonPortalDetected) { |
| 544 is_online = false; | 542 is_online = false; |
| 545 is_under_captive_portal = true; | 543 is_under_captive_portal = true; |
| 546 } | 544 } |
| 547 | 545 |
| 546 if (is_online || !is_under_captive_portal) |
| 547 error_screen_actor_->HideCaptivePortal(); |
| 548 |
| 548 if (!is_online && is_gaia_signin && !offline_login_active_) { | 549 if (!is_online && is_gaia_signin && !offline_login_active_) { |
| 549 LOG(WARNING) << "Show offline message: state=" << state << ", " | 550 LOG(WARNING) << "Show offline message: state=" << state << ", " |
| 550 << "network_id=" << network_id << ", " | 551 << "network_id=" << network_id << ", " |
| 551 << "reason=" << reason << ", " | 552 << "reason=" << reason << ", " |
| 552 << "is_under_captive_portal=" << is_under_captive_portal; | 553 << "is_under_captive_portal=" << is_under_captive_portal; |
| 553 if (is_under_captive_portal && !is_proxy_error) { | 554 if (is_proxy_error) { |
| 555 error_screen_actor_->ShowProxyError(); |
| 556 } else if (is_under_captive_portal) { |
| 554 // Do not bother a user with obsessive captive portal showing. This | 557 // Do not bother a user with obsessive captive portal showing. This |
| 555 // check makes captive portal being shown only once: either when error | 558 // check makes captive portal being shown only once: either when error |
| 556 // screen is shown for the first time or when switching from another | 559 // screen is shown for the first time or when switching from another |
| 557 // error screen (offline, proxy). | 560 // error screen (offline, proxy). |
| 558 if (!IsGaiaLogin() || | 561 if (!IsGaiaLogin() || |
| 559 (error_screen_actor_->state() != | 562 (error_screen_actor_->state() != |
| 560 ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR)) { | 563 ErrorScreenActor::STATE_CAPTIVE_PORTAL_ERROR)) { |
| 561 // In case of timeout we're suspecting that network might be | 564 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 } | 565 } |
| 570 } else { | 566 std::string network_name = GetNetworkName(service_path); |
| 571 error_screen_actor_->HideCaptivePortal(); | 567 error_screen_actor_->ShowCaptivePortalError(network_name); |
| 572 } | 568 } else if (is_gaia_loading_timeout) { |
| 573 | 569 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 { | 570 } else { |
| 584 error_screen_actor_->ShowOfflineError(); | 571 error_screen_actor_->ShowOfflineError(); |
| 585 } | 572 } |
| 586 | 573 |
| 587 bool guest_signin_allowed = IsGuestSigninAllowed() && | 574 bool guest_signin_allowed = IsGuestSigninAllowed() && |
| 588 IsSigninScreenError(error_screen_actor_->state()); | 575 IsSigninScreenError(error_screen_actor_->state()); |
| 589 error_screen_actor_->AllowGuestSignin(guest_signin_allowed); | 576 error_screen_actor_->AllowGuestSignin(guest_signin_allowed); |
| 590 | 577 |
| 591 bool offline_login_allowed = IsOfflineLoginAllowed() && | 578 bool offline_login_allowed = IsOfflineLoginAllowed() && |
| 592 IsSigninScreenError(error_screen_actor_->state()); | 579 IsSigninScreenError(error_screen_actor_->state()); |
| 593 error_screen_actor_->AllowOfflineLogin(offline_login_allowed); | 580 error_screen_actor_->AllowOfflineLogin(offline_login_allowed); |
| 594 | 581 |
| 595 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) { | 582 if (GetCurrentScreen() != OobeUI::SCREEN_ERROR_MESSAGE) { |
| 596 DictionaryValue params; | 583 DictionaryValue params; |
| 597 params.SetInteger("lastNetworkType", static_cast<int>(connection_type)); | 584 params.SetInteger("lastNetworkType", static_cast<int>(connection_type)); |
| 598 error_screen_actor_->Show(OobeUI::SCREEN_GAIA_SIGNIN, ¶ms); | 585 error_screen_actor_->Show(OobeUI::SCREEN_GAIA_SIGNIN, ¶ms); |
| 599 } | 586 } |
| 600 } else { | 587 } else { |
| 601 error_screen_actor_->HideCaptivePortal(); | |
| 602 | |
| 603 if (IsSigninScreenHiddenByError()) { | 588 if (IsSigninScreenHiddenByError()) { |
| 604 LOG(WARNING) << "Hide offline message. state=" << state << ", " | 589 LOG(WARNING) << "Hide offline message. state=" << state << ", " |
| 605 << "network_id=" << network_id << ", " | 590 << "network_id=" << network_id << ", " |
| 606 << "reason=" << reason; | 591 << "reason=" << reason; |
| 607 error_screen_actor_->Hide(); | 592 error_screen_actor_->Hide(); |
| 608 | 593 |
| 609 // Forces a reload for Gaia screen on hiding error message. | 594 // Forces a reload for Gaia screen on hiding error message. |
| 610 if (is_gaia_signin && !is_gaia_reloaded) { | 595 if (is_gaia_signin && !is_gaia_reloaded) { |
| 611 ReloadGaiaScreen(); | 596 ReloadGaiaScreen(); |
| 612 is_gaia_reloaded = true; | 597 is_gaia_reloaded = true; |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1673 if (!cros_settings) | 1658 if (!cros_settings) |
| 1674 return false; | 1659 return false; |
| 1675 | 1660 |
| 1676 // Offline login is allowed only when user pods are hidden. | 1661 // Offline login is allowed only when user pods are hidden. |
| 1677 bool show_pods; | 1662 bool show_pods; |
| 1678 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1663 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
| 1679 return !show_pods; | 1664 return !show_pods; |
| 1680 } | 1665 } |
| 1681 | 1666 |
| 1682 } // namespace chromeos | 1667 } // namespace chromeos |
| OLD | NEW |