| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
| 6 | 6 |
| 7 #include "ash/common/system/chromeos/devicetype_utils.h" | 7 #include "ash/common/system/chromeos/devicetype_utils.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 weak_factory_(this) { | 233 weak_factory_(this) { |
| 234 DCHECK(network_state_informer_.get()); | 234 DCHECK(network_state_informer_.get()); |
| 235 set_call_js_prefix(kJsScreenPath); | 235 set_call_js_prefix(kJsScreenPath); |
| 236 } | 236 } |
| 237 | 237 |
| 238 GaiaScreenHandler::~GaiaScreenHandler() { | 238 GaiaScreenHandler::~GaiaScreenHandler() { |
| 239 if (network_portal_detector_) | 239 if (network_portal_detector_) |
| 240 network_portal_detector_->RemoveObserver(this); | 240 network_portal_detector_->RemoveObserver(this); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void GaiaScreenHandler::MaybePreloadAuthExtension() { |
| 244 VLOG(1) << "MaybePreloadAuthExtension"; |
| 245 |
| 246 if (!network_portal_detector_) { |
| 247 NetworkPortalDetectorImpl* detector = new NetworkPortalDetectorImpl( |
| 248 g_browser_process->system_request_context(), false); |
| 249 detector->set_portal_test_url(GURL(kRestrictiveProxyURL)); |
| 250 network_portal_detector_.reset(detector); |
| 251 network_portal_detector_->AddObserver(this); |
| 252 network_portal_detector_->Enable(true); |
| 253 } |
| 254 |
| 255 // If cookies clearing was initiated or |dns_clear_task_running_| then auth |
| 256 // extension showing has already been initiated and preloading is pointless. |
| 257 if (signin_screen_handler_->ShouldLoadGaia() && !gaia_silent_load_ && |
| 258 !cookies_cleared_ && !dns_clear_task_running_ && |
| 259 network_state_informer_->state() == NetworkStateInformer::ONLINE) { |
| 260 gaia_silent_load_ = true; |
| 261 gaia_silent_load_network_ = network_state_informer_->network_path(); |
| 262 LoadAuthExtension(true /* force */, false /* offline */); |
| 263 } |
| 264 } |
| 265 |
| 266 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { |
| 267 disable_restrictive_proxy_check_for_test_ = true; |
| 268 } |
| 269 |
| 243 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { | 270 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { |
| 244 base::PostTaskWithTraitsAndReplyWithResult( | 271 base::PostTaskWithTraitsAndReplyWithResult( |
| 245 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 272 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
| 246 base::TaskPriority::BACKGROUND), | 273 base::TaskPriority::BACKGROUND), |
| 247 base::Bind(&version_loader::GetVersion, version_loader::VERSION_SHORT), | 274 base::Bind(&version_loader::GetVersion, version_loader::VERSION_SHORT), |
| 248 base::Bind(&GaiaScreenHandler::LoadGaiaWithVersion, | 275 base::Bind(&GaiaScreenHandler::LoadGaiaWithVersion, |
| 249 weak_factory_.GetWeakPtr(), context)); | 276 weak_factory_.GetWeakPtr(), context)); |
| 250 } | 277 } |
| 251 | 278 |
| 252 void GaiaScreenHandler::LoadGaiaWithVersion( | 279 void GaiaScreenHandler::LoadGaiaWithVersion( |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 if (core_oobe_actor_) { | 913 if (core_oobe_actor_) { |
| 887 PrefService* prefs = g_browser_process->local_state(); | 914 PrefService* prefs = g_browser_process->local_state(); |
| 888 if (prefs->GetBoolean(prefs::kFactoryResetRequested)) { | 915 if (prefs->GetBoolean(prefs::kFactoryResetRequested)) { |
| 889 core_oobe_actor_->ShowDeviceResetScreen(); | 916 core_oobe_actor_->ShowDeviceResetScreen(); |
| 890 } else if (prefs->GetBoolean(prefs::kDebuggingFeaturesRequested)) { | 917 } else if (prefs->GetBoolean(prefs::kDebuggingFeaturesRequested)) { |
| 891 core_oobe_actor_->ShowEnableDebuggingScreen(); | 918 core_oobe_actor_->ShowEnableDebuggingScreen(); |
| 892 } | 919 } |
| 893 } | 920 } |
| 894 } | 921 } |
| 895 | 922 |
| 896 void GaiaScreenHandler::MaybePreloadAuthExtension() { | |
| 897 VLOG(1) << "MaybePreloadAuthExtension"; | |
| 898 | |
| 899 if (!network_portal_detector_) { | |
| 900 NetworkPortalDetectorImpl* detector = new NetworkPortalDetectorImpl( | |
| 901 g_browser_process->system_request_context(), false); | |
| 902 detector->set_portal_test_url(GURL(kRestrictiveProxyURL)); | |
| 903 network_portal_detector_.reset(detector); | |
| 904 network_portal_detector_->AddObserver(this); | |
| 905 network_portal_detector_->Enable(true); | |
| 906 } | |
| 907 | |
| 908 // If cookies clearing was initiated or |dns_clear_task_running_| then auth | |
| 909 // extension showing has already been initiated and preloading is pointless. | |
| 910 if (signin_screen_handler_->ShouldLoadGaia() && | |
| 911 !gaia_silent_load_ && | |
| 912 !cookies_cleared_ && | |
| 913 !dns_clear_task_running_ && | |
| 914 network_state_informer_->state() == NetworkStateInformer::ONLINE) { | |
| 915 gaia_silent_load_ = true; | |
| 916 gaia_silent_load_network_ = network_state_informer_->network_path(); | |
| 917 LoadAuthExtension(true /* force */, false /* offline */); | |
| 918 } | |
| 919 } | |
| 920 | |
| 921 void GaiaScreenHandler::ShowWhitelistCheckFailedError() { | 923 void GaiaScreenHandler::ShowWhitelistCheckFailedError() { |
| 922 base::DictionaryValue params; | 924 base::DictionaryValue params; |
| 923 params.SetBoolean("enterpriseManaged", | 925 params.SetBoolean("enterpriseManaged", |
| 924 g_browser_process->platform_part() | 926 g_browser_process->platform_part() |
| 925 ->browser_policy_connector_chromeos() | 927 ->browser_policy_connector_chromeos() |
| 926 ->IsEnterpriseManaged()); | 928 ->IsEnterpriseManaged()); |
| 927 CallJS("showWhitelistCheckFailedError", true, params); | 929 CallJS("showWhitelistCheckFailedError", true, params); |
| 928 } | 930 } |
| 929 | 931 |
| 930 void GaiaScreenHandler::LoadAuthExtension(bool force, | 932 void GaiaScreenHandler::LoadAuthExtension(bool force, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 | 969 |
| 968 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 970 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 969 return signin_screen_handler_->delegate_; | 971 return signin_screen_handler_->delegate_; |
| 970 } | 972 } |
| 971 | 973 |
| 972 bool GaiaScreenHandler::IsRestrictiveProxy() const { | 974 bool GaiaScreenHandler::IsRestrictiveProxy() const { |
| 973 return !disable_restrictive_proxy_check_for_test_ && | 975 return !disable_restrictive_proxy_check_for_test_ && |
| 974 !IsOnline(captive_portal_status_); | 976 !IsOnline(captive_portal_status_); |
| 975 } | 977 } |
| 976 | 978 |
| 977 void GaiaScreenHandler::DisableRestrictiveProxyCheckForTest() { | |
| 978 disable_restrictive_proxy_check_for_test_ = true; | |
| 979 } | |
| 980 | |
| 981 } // namespace chromeos | 979 } // namespace chromeos |
| OLD | NEW |