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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 SigninScreenHandler::SigninScreenHandler( | 287 SigninScreenHandler::SigninScreenHandler( |
288 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 288 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
289 ErrorScreenActor* error_screen_actor, | 289 ErrorScreenActor* error_screen_actor, |
290 CoreOobeActor* core_oobe_actor, | 290 CoreOobeActor* core_oobe_actor, |
291 GaiaScreenHandler* gaia_screen_handler) | 291 GaiaScreenHandler* gaia_screen_handler) |
292 : ui_state_(UI_STATE_UNKNOWN), | 292 : ui_state_(UI_STATE_UNKNOWN), |
293 delegate_(NULL), | 293 delegate_(NULL), |
294 native_window_delegate_(NULL), | 294 native_window_delegate_(NULL), |
295 show_on_init_(false), | 295 show_on_init_(false), |
296 oobe_ui_(false), | 296 oobe_ui_(false), |
| 297 focus_stolen_(false), |
297 gaia_silent_load_(false), | 298 gaia_silent_load_(false), |
298 is_account_picker_showing_first_time_(false), | 299 is_account_picker_showing_first_time_(false), |
299 dns_cleared_(false), | 300 dns_cleared_(false), |
300 dns_clear_task_running_(false), | 301 dns_clear_task_running_(false), |
301 cookies_cleared_(false), | 302 cookies_cleared_(false), |
302 network_state_informer_(network_state_informer), | 303 network_state_informer_(network_state_informer), |
303 using_saml_api_(false), | 304 using_saml_api_(false), |
304 test_expects_complete_login_(false), | 305 test_expects_complete_login_(false), |
305 weak_factory_(this), | 306 weak_factory_(this), |
306 webui_visible_(false), | 307 webui_visible_(false), |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 | 1046 |
1046 if (!dns_cleared_ || !cookies_cleared_ || !delegate_) | 1047 if (!dns_cleared_ || !cookies_cleared_ || !delegate_) |
1047 return; | 1048 return; |
1048 | 1049 |
1049 std::string active_network_path = network_state_informer_->network_path(); | 1050 std::string active_network_path = network_state_informer_->network_path(); |
1050 if (gaia_silent_load_ && | 1051 if (gaia_silent_load_ && |
1051 (network_state_informer_->state() != NetworkStateInformer::ONLINE || | 1052 (network_state_informer_->state() != NetworkStateInformer::ONLINE || |
1052 gaia_silent_load_network_ != active_network_path)) { | 1053 gaia_silent_load_network_ != active_network_path)) { |
1053 // Network has changed. Force Gaia reload. | 1054 // Network has changed. Force Gaia reload. |
1054 gaia_silent_load_ = false; | 1055 gaia_silent_load_ = false; |
| 1056 // Gaia page will be realoded, so focus isn't stolen anymore. |
| 1057 focus_stolen_ = false; |
1055 } | 1058 } |
1056 | 1059 |
1057 // Note that LoadAuthExtension clears |email_|. | 1060 // Note that LoadAuthExtension clears |email_|. |
1058 if (email_.empty()) | 1061 if (email_.empty()) |
1059 delegate_->LoadSigninWallpaper(); | 1062 delegate_->LoadSigninWallpaper(); |
1060 else | 1063 else |
1061 delegate_->LoadWallpaper(email_); | 1064 delegate_->LoadWallpaper(email_); |
1062 | 1065 |
1063 // Set Least Recently Used input method for the user. | 1066 // Set Least Recently Used input method for the user. |
1064 if (!email_.empty()) | 1067 if (!email_.empty()) |
1065 SetUserInputMethod(email_); | 1068 SetUserInputMethod(email_); |
1066 | 1069 |
1067 LoadAuthExtension(!gaia_silent_load_, false, false); | 1070 LoadAuthExtension(!gaia_silent_load_, false, false); |
1068 UpdateUIState(UI_STATE_GAIA_SIGNIN, NULL); | 1071 UpdateUIState(UI_STATE_GAIA_SIGNIN, NULL); |
1069 | 1072 |
1070 if (gaia_silent_load_) { | 1073 if (gaia_silent_load_) { |
1071 // The variable is assigned to false because silently loaded Gaia page was | 1074 // The variable is assigned to false because silently loaded Gaia page was |
1072 // used. | 1075 // used. |
1073 gaia_silent_load_ = false; | 1076 gaia_silent_load_ = false; |
1074 HandleLoginWebuiReady(); | 1077 if (focus_stolen_) |
| 1078 HandleLoginWebuiReady(); |
1075 } | 1079 } |
1076 | 1080 |
1077 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); | 1081 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); |
1078 } | 1082 } |
1079 | 1083 |
1080 void SigninScreenHandler::LoadAuthExtension( | 1084 void SigninScreenHandler::LoadAuthExtension( |
1081 bool force, bool silent_load, bool offline) { | 1085 bool force, bool silent_load, bool offline) { |
1082 GaiaContext context; | 1086 GaiaContext context; |
1083 context.force_reload = force; | 1087 context.force_reload = force; |
1084 context.is_local = offline; | 1088 context.is_local = offline; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 std::string owner; | 1360 std::string owner; |
1357 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 1361 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
1358 bool has_owner = owner.size() > 0; | 1362 bool has_owner = owner.size() > 0; |
1359 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; | 1363 size_t max_non_owner_users = has_owner ? kMaxUsers - 1 : kMaxUsers; |
1360 size_t non_owner_count = 0; | 1364 size_t non_owner_count = 0; |
1361 policy::BrowserPolicyConnectorChromeOS* connector = | 1365 policy::BrowserPolicyConnectorChromeOS* connector = |
1362 g_browser_process->platform_part()-> | 1366 g_browser_process->platform_part()-> |
1363 browser_policy_connector_chromeos(); | 1367 browser_policy_connector_chromeos(); |
1364 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | 1368 bool is_enterprise_managed = connector->IsEnterpriseManaged(); |
1365 | 1369 |
| 1370 |
1366 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1371 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
1367 const std::string& email = (*it)->email(); | 1372 const std::string& email = (*it)->email(); |
1368 bool is_owner = (email == owner); | 1373 bool is_owner = (email == owner); |
1369 bool is_public_account = | 1374 bool is_public_account = |
1370 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | 1375 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
1371 | 1376 |
1372 if ((is_public_account && !is_signin_to_add) || | 1377 if ((is_public_account && !is_signin_to_add) || |
1373 is_owner || | 1378 is_owner || |
1374 (!is_public_account && non_owner_count < max_non_owner_users)) { | 1379 (!is_public_account && non_owner_count < max_non_owner_users)) { |
1375 LoginDisplay::AuthType initial_auth_type = | 1380 LoginDisplay::AuthType initial_auth_type = |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 } | 1436 } |
1432 | 1437 |
1433 void SigninScreenHandler::HandleWallpaperReady() { | 1438 void SigninScreenHandler::HandleWallpaperReady() { |
1434 if (ScreenLocker::default_screen_locker()) { | 1439 if (ScreenLocker::default_screen_locker()) { |
1435 ScreenLocker::default_screen_locker()->delegate()-> | 1440 ScreenLocker::default_screen_locker()->delegate()-> |
1436 OnLockBackgroundDisplayed(); | 1441 OnLockBackgroundDisplayed(); |
1437 } | 1442 } |
1438 } | 1443 } |
1439 | 1444 |
1440 void SigninScreenHandler::HandleLoginWebuiReady() { | 1445 void SigninScreenHandler::HandleLoginWebuiReady() { |
| 1446 if (focus_stolen_) { |
| 1447 // Set focus to the Gaia page. |
| 1448 // TODO(altimofeev): temporary solution, until focus parameters are |
| 1449 // implemented on the Gaia side. |
| 1450 // Do this only once. Any subsequent call would relod GAIA frame. |
| 1451 focus_stolen_ = false; |
| 1452 const char code[] = |
| 1453 "if (typeof gWindowOnLoad != 'undefined) gWindowOnLoad();"; |
| 1454 content::RenderFrameHost* frame = |
| 1455 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); |
| 1456 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); |
| 1457 } |
1441 if (gaia_silent_load_) { | 1458 if (gaia_silent_load_) { |
| 1459 focus_stolen_ = true; |
| 1460 // Prevent focus stealing by the Gaia page. |
| 1461 // TODO(altimofeev): temporary solution, until focus parameters are |
| 1462 // implemented on the Gaia side. |
| 1463 const char code[] = "var gWindowOnLoad = window.onload; " |
| 1464 "window.onload=function() {};"; |
| 1465 content::RenderFrameHost* frame = |
| 1466 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); |
| 1467 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); |
1442 // As we could miss and window.onload could already be called, restore | 1468 // As we could miss and window.onload could already be called, restore |
1443 // focus to current pod (see crbug/175243). | 1469 // focus to current pod (see crbug/175243). |
1444 RefocusCurrentPod(); | 1470 RefocusCurrentPod(); |
1445 } | 1471 } |
1446 DCHECK(gaia_screen_handler_); | 1472 DCHECK(gaia_screen_handler_); |
1447 gaia_screen_handler_->HandleFrameLoadingCompleted(0); | 1473 gaia_screen_handler_->HandleFrameLoadingCompleted(0); |
1448 | 1474 |
1449 if (test_expects_complete_login_) | 1475 if (test_expects_complete_login_) |
1450 SubmitLoginFormForTest(); | 1476 SubmitLoginFormForTest(); |
1451 } | 1477 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1770 DCHECK(gaia_screen_handler_); | 1796 DCHECK(gaia_screen_handler_); |
1771 return gaia_screen_handler_->frame_state(); | 1797 return gaia_screen_handler_->frame_state(); |
1772 } | 1798 } |
1773 | 1799 |
1774 net::Error SigninScreenHandler::FrameError() const { | 1800 net::Error SigninScreenHandler::FrameError() const { |
1775 DCHECK(gaia_screen_handler_); | 1801 DCHECK(gaia_screen_handler_); |
1776 return gaia_screen_handler_->frame_error(); | 1802 return gaia_screen_handler_->frame_error(); |
1777 } | 1803 } |
1778 | 1804 |
1779 } // namespace chromeos | 1805 } // namespace chromeos |
OLD | NEW |