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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1351 | 1355 |
1352 user_pod_button_callback_map_.clear(); | 1356 user_pod_button_callback_map_.clear(); |
1353 user_auth_type_map_.clear(); | 1357 user_auth_type_map_.clear(); |
1354 | 1358 |
1355 bool single_user = users.size() == 1; | 1359 bool single_user = users.size() == 1; |
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 = | |
1362 g_browser_process->platform_part()-> | |
1363 browser_policy_connector_chromeos(); | |
1364 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | |
1365 | 1365 |
1366 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1366 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
1367 const std::string& email = (*it)->email(); | 1367 const std::string& email = (*it)->email(); |
1368 bool is_owner = (email == owner); | 1368 bool is_owner = (email == owner); |
1369 bool is_public_account = | 1369 bool is_public_account = |
1370 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | 1370 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
1371 policy::BrowserPolicyConnectorChromeOS* connector = | |
Nikita (slow)
2014/04/03 11:46:11
You don't need this code move, it seems to be rela
| |
1372 g_browser_process->platform_part()-> | |
1373 browser_policy_connector_chromeos(); | |
1374 bool is_enterprise_managed = connector->IsEnterpriseManaged(); | |
1371 | 1375 |
1372 if ((is_public_account && !is_signin_to_add) || | 1376 if ((is_public_account && !is_signin_to_add) || |
1373 is_owner || | 1377 is_owner || |
1374 (!is_public_account && non_owner_count < max_non_owner_users)) { | 1378 (!is_public_account && non_owner_count < max_non_owner_users)) { |
1375 LoginDisplay::AuthType initial_auth_type = | 1379 LoginDisplay::AuthType initial_auth_type = |
1376 ShouldForceOnlineSignIn(*it) ? LoginDisplay::ONLINE_SIGN_IN | 1380 ShouldForceOnlineSignIn(*it) ? LoginDisplay::ONLINE_SIGN_IN |
1377 : LoginDisplay::OFFLINE_PASSWORD; | 1381 : LoginDisplay::OFFLINE_PASSWORD; |
1378 user_auth_type_map_[email] = initial_auth_type; | 1382 user_auth_type_map_[email] = initial_auth_type; |
1379 | 1383 |
1380 base::DictionaryValue* user_dict = new base::DictionaryValue(); | 1384 base::DictionaryValue* user_dict = new base::DictionaryValue(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1431 } | 1435 } |
1432 | 1436 |
1433 void SigninScreenHandler::HandleWallpaperReady() { | 1437 void SigninScreenHandler::HandleWallpaperReady() { |
1434 if (ScreenLocker::default_screen_locker()) { | 1438 if (ScreenLocker::default_screen_locker()) { |
1435 ScreenLocker::default_screen_locker()->delegate()-> | 1439 ScreenLocker::default_screen_locker()->delegate()-> |
1436 OnLockBackgroundDisplayed(); | 1440 OnLockBackgroundDisplayed(); |
1437 } | 1441 } |
1438 } | 1442 } |
1439 | 1443 |
1440 void SigninScreenHandler::HandleLoginWebuiReady() { | 1444 void SigninScreenHandler::HandleLoginWebuiReady() { |
1445 if (focus_stolen_) { | |
1446 // Set focus to the Gaia page. | |
1447 // TODO(altimofeev): temporary solution, until focus parameters are | |
1448 // implemented on the Gaia side. | |
1449 // Do this only once. Any subsequent call would relod GAIA frame. | |
1450 focus_stolen_ = false; | |
1451 const char code[] = | |
1452 "if (typeof gWindowOnLoad != 'undefined) gWindowOnLoad();"; | |
1453 content::RenderFrameHost* frame = | |
1454 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); | |
1455 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); | |
1456 } | |
1441 if (gaia_silent_load_) { | 1457 if (gaia_silent_load_) { |
1458 focus_stolen_ = true; | |
1459 // Prevent focus stealing by the Gaia page. | |
1460 // TODO(altimofeev): temporary solution, until focus parameters are | |
1461 // implemented on the Gaia side. | |
1462 const char code[] = "var gWindowOnLoad = window.onload; " | |
1463 "window.onload=function() {};"; | |
1464 content::RenderFrameHost* frame = | |
1465 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); | |
1466 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); | |
1442 // As we could miss and window.onload could already be called, restore | 1467 // As we could miss and window.onload could already be called, restore |
1443 // focus to current pod (see crbug/175243). | 1468 // focus to current pod (see crbug/175243). |
1444 RefocusCurrentPod(); | 1469 RefocusCurrentPod(); |
1445 } | 1470 } |
1446 DCHECK(gaia_screen_handler_); | 1471 DCHECK(gaia_screen_handler_); |
1447 gaia_screen_handler_->HandleFrameLoadingCompleted(0); | 1472 gaia_screen_handler_->HandleFrameLoadingCompleted(0); |
1448 | 1473 |
1449 if (test_expects_complete_login_) | 1474 if (test_expects_complete_login_) |
1450 SubmitLoginFormForTest(); | 1475 SubmitLoginFormForTest(); |
1451 } | 1476 } |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1770 DCHECK(gaia_screen_handler_); | 1795 DCHECK(gaia_screen_handler_); |
1771 return gaia_screen_handler_->frame_state(); | 1796 return gaia_screen_handler_->frame_state(); |
1772 } | 1797 } |
1773 | 1798 |
1774 net::Error SigninScreenHandler::FrameError() const { | 1799 net::Error SigninScreenHandler::FrameError() const { |
1775 DCHECK(gaia_screen_handler_); | 1800 DCHECK(gaia_screen_handler_); |
1776 return gaia_screen_handler_->frame_error(); | 1801 return gaia_screen_handler_->frame_error(); |
1777 } | 1802 } |
1778 | 1803 |
1779 } // namespace chromeos | 1804 } // namespace chromeos |
OLD | NEW |