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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 // preferences from CrosSettings. | 171 // preferences from CrosSettings. |
172 void UpdateAuthParamsFromSettings(DictionaryValue* params, | 172 void UpdateAuthParamsFromSettings(DictionaryValue* params, |
173 const CrosSettings* cros_settings) { | 173 const CrosSettings* cros_settings) { |
174 bool allow_new_user = true; | 174 bool allow_new_user = true; |
175 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 175 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
176 bool allow_guest = true; | 176 bool allow_guest = true; |
177 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 177 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
178 // Account creation depends on Guest sign-in (http://crosbug.com/24570). | 178 // Account creation depends on Guest sign-in (http://crosbug.com/24570). |
179 params->SetBoolean("createAccount", allow_new_user && allow_guest); | 179 params->SetBoolean("createAccount", allow_new_user && allow_guest); |
180 params->SetBoolean("guestSignin", allow_guest); | 180 params->SetBoolean("guestSignin", allow_guest); |
181 // TODO(nkostylev): Allow locally managed user creation only if: | |
182 // 1. Enterprise managed device > is allowed by policy. | |
183 // 2. Consumer device > owner exists. | |
184 // g_browser_process->browser_policy_connector()->IsEnterpriseManaged() | |
185 // const UserList& users = delegate_->GetUsers(); | |
186 // bool single_user = users.size() == 1; | |
187 // chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | |
188 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
189 params->SetBoolean("createLocallyManagedUser", | |
190 command_line->HasSwitch(::switches::kEnableManagedUsers)); | |
191 } | 181 } |
192 | 182 |
193 bool IsOnline(NetworkStateInformer::State state, | 183 bool IsOnline(NetworkStateInformer::State state, |
194 ErrorScreenActor::ErrorReason reason) { | 184 ErrorScreenActor::ErrorReason reason) { |
195 return state == NetworkStateInformer::ONLINE && | 185 return state == NetworkStateInformer::ONLINE && |
196 reason != ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED && | 186 reason != ErrorScreenActor::ERROR_REASON_PORTAL_DETECTED && |
197 reason != ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT; | 187 reason != ErrorScreenActor::ERROR_REASON_LOADING_TIMEOUT; |
198 } | 188 } |
199 | 189 |
200 bool IsUnderCaptivePortal(NetworkStateInformer::State state, | 190 bool IsUnderCaptivePortal(NetworkStateInformer::State state, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 builder->Add("addUser", IDS_ADD_USER_BUTTON); | 383 builder->Add("addUser", IDS_ADD_USER_BUTTON); |
394 builder->Add("browseAsGuest", IDS_GO_INCOGNITO_BUTTON); | 384 builder->Add("browseAsGuest", IDS_GO_INCOGNITO_BUTTON); |
395 builder->Add("cancel", IDS_CANCEL); | 385 builder->Add("cancel", IDS_CANCEL); |
396 builder->Add("signOutUser", IDS_SCREEN_LOCK_SIGN_OUT); | 386 builder->Add("signOutUser", IDS_SCREEN_LOCK_SIGN_OUT); |
397 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); | 387 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); |
398 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); | 388 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); |
399 builder->Add("createLocallyManagedUser", | 389 builder->Add("createLocallyManagedUser", |
400 IDS_CREATE_LOCALLY_MANAGED_USER_HTML); | 390 IDS_CREATE_LOCALLY_MANAGED_USER_HTML); |
401 builder->Add("createManagedUserFeatureName", | 391 builder->Add("createManagedUserFeatureName", |
402 IDS_CREATE_LOCALLY_MANAGED_USER_FEATURE_NAME); | 392 IDS_CREATE_LOCALLY_MANAGED_USER_FEATURE_NAME); |
| 393 builder->Add("createManagedUserNoManagerText", |
| 394 IDS_CREATE_LOCALLY_MANAGED_USER_NO_MANAGER_TEXT); |
403 builder->Add("offlineLogin", IDS_OFFLINE_LOGIN_HTML); | 395 builder->Add("offlineLogin", IDS_OFFLINE_LOGIN_HTML); |
404 builder->Add("ownerUserPattern", IDS_LOGIN_POD_OWNER_USER); | 396 builder->Add("ownerUserPattern", IDS_LOGIN_POD_OWNER_USER); |
405 builder->Add("removeUser", IDS_LOGIN_POD_REMOVE_USER); | 397 builder->Add("removeUser", IDS_LOGIN_POD_REMOVE_USER); |
406 builder->Add("errorTpmFailureTitle", IDS_LOGIN_ERROR_TPM_FAILURE_TITLE); | 398 builder->Add("errorTpmFailureTitle", IDS_LOGIN_ERROR_TPM_FAILURE_TITLE); |
407 builder->Add("errorTpmFailureReboot", IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT); | 399 builder->Add("errorTpmFailureReboot", IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT); |
408 builder->Add("errorTpmFailureRebootButton", | 400 builder->Add("errorTpmFailureRebootButton", |
409 IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT_BUTTON); | 401 IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT_BUTTON); |
410 builder->Add( | 402 builder->Add( |
411 "disabledAddUserTooltip", | 403 "disabledAddUserTooltip", |
412 g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ? | 404 g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ? |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 // used. | 980 // used. |
989 gaia_silent_load_ = false; | 981 gaia_silent_load_ = false; |
990 if (focus_stolen_) | 982 if (focus_stolen_) |
991 HandleLoginWebuiReady(); | 983 HandleLoginWebuiReady(); |
992 } | 984 } |
993 | 985 |
994 UpdateState(network_state_informer_->state(), | 986 UpdateState(network_state_informer_->state(), |
995 ErrorScreenActor::ERROR_REASON_UPDATE); | 987 ErrorScreenActor::ERROR_REASON_UPDATE); |
996 } | 988 } |
997 | 989 |
| 990 |
| 991 void SigninScreenHandler::UpdateAuthParams(DictionaryValue* params) { |
| 992 UpdateAuthParamsFromSettings(params, CrosSettings::Get()); |
| 993 |
| 994 // TODO(nkostylev): Allow locally managed user creation only if: |
| 995 // 1. Enterprise managed device > is allowed by policy. |
| 996 // 2. Consumer device > owner exists. |
| 997 // g_browser_process->browser_policy_connector()->IsEnterpriseManaged() |
| 998 // const UserList& users = delegate_->GetUsers(); |
| 999 // bool single_user = users.size() == 1; |
| 1000 // chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| 1001 |
| 1002 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 1003 bool managed_users_enabled = |
| 1004 command_line->HasSwitch(::switches::kEnableManagedUsers); |
| 1005 bool managed_users_can_create = false; |
| 1006 if (managed_users_enabled) |
| 1007 managed_users_can_create = delegate_->GetUsers().size() > 0; |
| 1008 params->SetBoolean("managedUsersEnabled", managed_users_enabled); |
| 1009 params->SetBoolean("managedUsersCanCreate", managed_users_can_create); |
| 1010 } |
| 1011 |
998 void SigninScreenHandler::LoadAuthExtension( | 1012 void SigninScreenHandler::LoadAuthExtension( |
999 bool force, bool silent_load, bool offline) { | 1013 bool force, bool silent_load, bool offline) { |
1000 DictionaryValue params; | 1014 DictionaryValue params; |
1001 | 1015 |
1002 params.SetBoolean("forceReload", force); | 1016 params.SetBoolean("forceReload", force); |
1003 params.SetBoolean("silentLoad", silent_load); | 1017 params.SetBoolean("silentLoad", silent_load); |
1004 params.SetBoolean("isLocal", offline); | 1018 params.SetBoolean("isLocal", offline); |
1005 params.SetBoolean("passwordChanged", | 1019 params.SetBoolean("passwordChanged", |
1006 !email_.empty() && password_changed_for_.count(email_)); | 1020 !email_.empty() && password_changed_for_.count(email_)); |
1007 if (delegate_) | 1021 if (delegate_) |
1008 params.SetBoolean("isShowUsers", delegate_->IsShowUsers()); | 1022 params.SetBoolean("isShowUsers", delegate_->IsShowUsers()); |
1009 params.SetBoolean("useOffline", offline); | 1023 params.SetBoolean("useOffline", offline); |
1010 params.SetString("email", email_); | 1024 params.SetString("email", email_); |
1011 email_.clear(); | 1025 email_.clear(); |
1012 | 1026 |
1013 UpdateAuthParamsFromSettings(¶ms, CrosSettings::Get()); | 1027 UpdateAuthParams(¶ms); |
1014 | 1028 |
1015 if (!offline) { | 1029 if (!offline) { |
1016 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 1030 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
1017 if (!app_locale.empty()) | 1031 if (!app_locale.empty()) |
1018 params.SetString("hl", app_locale); | 1032 params.SetString("hl", app_locale); |
1019 } else { | 1033 } else { |
1020 base::DictionaryValue *localized_strings = new base::DictionaryValue(); | 1034 base::DictionaryValue *localized_strings = new base::DictionaryValue(); |
1021 localized_strings->SetString("stringEmail", | 1035 localized_strings->SetString("stringEmail", |
1022 l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_EMAIL)); | 1036 l10n_util::GetStringUTF16(IDS_LOGIN_OFFLINE_EMAIL)); |
1023 localized_strings->SetString("stringPassword", | 1037 localized_strings->SetString("stringPassword", |
(...skipping 24 matching lines...) Expand all Loading... |
1048 if (!test_pass_.empty()) { | 1062 if (!test_pass_.empty()) { |
1049 params.SetString("test_password", test_pass_); | 1063 params.SetString("test_password", test_pass_); |
1050 test_pass_.clear(); | 1064 test_pass_.clear(); |
1051 } | 1065 } |
1052 } | 1066 } |
1053 CallJS("login.GaiaSigninScreen.loadAuthExtension", params); | 1067 CallJS("login.GaiaSigninScreen.loadAuthExtension", params); |
1054 } | 1068 } |
1055 | 1069 |
1056 void SigninScreenHandler::UpdateAuthExtension() { | 1070 void SigninScreenHandler::UpdateAuthExtension() { |
1057 DictionaryValue params; | 1071 DictionaryValue params; |
1058 UpdateAuthParamsFromSettings(¶ms, CrosSettings::Get()); | 1072 UpdateAuthParams(¶ms); |
1059 CallJS("login.GaiaSigninScreen.updateAuthExtension", params); | 1073 CallJS("login.GaiaSigninScreen.updateAuthExtension", params); |
1060 } | 1074 } |
1061 | 1075 |
1062 void SigninScreenHandler::UpdateAddButtonStatus() { | 1076 void SigninScreenHandler::UpdateAddButtonStatus() { |
1063 CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus", | 1077 CallJS("cr.ui.login.DisplayManager.updateAddUserButtonStatus", |
1064 AllWhitelistedUsersPresent()); | 1078 AllWhitelistedUsersPresent()); |
1065 } | 1079 } |
1066 | 1080 |
1067 void SigninScreenHandler::HandleCompleteLogin(const std::string& typed_email, | 1081 void SigninScreenHandler::HandleCompleteLogin(const std::string& typed_email, |
1068 const std::string& password) { | 1082 const std::string& password) { |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 if (!cros_settings) | 1603 if (!cros_settings) |
1590 return false; | 1604 return false; |
1591 | 1605 |
1592 // Offline login is allowed only when user pods are hidden. | 1606 // Offline login is allowed only when user pods are hidden. |
1593 bool show_pods; | 1607 bool show_pods; |
1594 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1608 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
1595 return !show_pods; | 1609 return !show_pods; |
1596 } | 1610 } |
1597 | 1611 |
1598 } // namespace chromeos | 1612 } // namespace chromeos |
OLD | NEW |