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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 } | 1212 } |
1213 | 1213 |
1214 void SigninScreenHandler::FillUserDictionary(User* user, | 1214 void SigninScreenHandler::FillUserDictionary(User* user, |
1215 bool is_owner, | 1215 bool is_owner, |
1216 DictionaryValue* user_dict) { | 1216 DictionaryValue* user_dict) { |
1217 const std::string& email = user->email(); | 1217 const std::string& email = user->email(); |
1218 bool is_public_account = | 1218 bool is_public_account = |
1219 user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT; | 1219 user->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT; |
1220 bool is_locally_managed_user = | 1220 bool is_locally_managed_user = |
1221 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED; | 1221 user->GetType() == User::USER_TYPE_LOCALLY_MANAGED; |
1222 bool signed_in = user == UserManager::Get()->GetLoggedInUser(); | |
1223 | 1222 |
1224 user_dict->SetString(kKeyUsername, email); | 1223 user_dict->SetString(kKeyUsername, email); |
1225 user_dict->SetString(kKeyEmailAddress, user->display_email()); | 1224 user_dict->SetString(kKeyEmailAddress, user->display_email()); |
1226 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); | 1225 user_dict->SetString(kKeyDisplayName, user->GetDisplayName()); |
1227 user_dict->SetBoolean(kKeyPublicAccount, is_public_account); | 1226 user_dict->SetBoolean(kKeyPublicAccount, is_public_account); |
1228 user_dict->SetBoolean(kKeyLocallyManagedUser, is_locally_managed_user); | 1227 user_dict->SetBoolean(kKeyLocallyManagedUser, is_locally_managed_user); |
1229 user_dict->SetInteger(kKeyOauthTokenStatus, user->oauth_token_status()); | 1228 user_dict->SetInteger(kKeyOauthTokenStatus, user->oauth_token_status()); |
1230 user_dict->SetBoolean(kKeySignedIn, signed_in); | 1229 user_dict->SetBoolean(kKeySignedIn, user->is_logged_in()); |
1231 user_dict->SetBoolean(kKeyIsOwner, is_owner); | 1230 user_dict->SetBoolean(kKeyIsOwner, is_owner); |
1232 | 1231 |
1233 if (is_public_account) { | 1232 if (is_public_account) { |
1234 policy::BrowserPolicyConnector* policy_connector = | 1233 policy::BrowserPolicyConnector* policy_connector = |
1235 g_browser_process->browser_policy_connector(); | 1234 g_browser_process->browser_policy_connector(); |
1236 | 1235 |
1237 if (policy_connector->IsEnterpriseManaged()) { | 1236 if (policy_connector->IsEnterpriseManaged()) { |
1238 user_dict->SetString(kKeyEnterpriseDomain, | 1237 user_dict->SetString(kKeyEnterpriseDomain, |
1239 policy_connector->GetEnterpriseDomain()); | 1238 policy_connector->GetEnterpriseDomain()); |
1240 } | 1239 } |
(...skipping 14 matching lines...) Expand all Loading... |
1255 // based on user preferences. http://crbug.com/230862 | 1254 // based on user preferences. http://crbug.com/230862 |
1256 | 1255 |
1257 // TODO(nkostylev): Move to a separate method in UserManager. | 1256 // TODO(nkostylev): Move to a separate method in UserManager. |
1258 // http://crbug.com/230852 | 1257 // http://crbug.com/230852 |
1259 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && | 1258 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && |
1260 UserManager::Get()->IsUserLoggedIn(); | 1259 UserManager::Get()->IsUserLoggedIn(); |
1261 | 1260 |
1262 bool single_user = users.size() == 1; | 1261 bool single_user = users.size() == 1; |
1263 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 1262 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
1264 const std::string& email = (*it)->email(); | 1263 const std::string& email = (*it)->email(); |
1265 if (is_signin_to_add && (*it)->is_logged_in()) { | |
1266 // Skip all users that are already signed in. | |
1267 continue; | |
1268 } | |
1269 | 1264 |
1270 std::string owner; | 1265 std::string owner; |
1271 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 1266 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
1272 bool is_owner = (email == owner); | 1267 bool is_owner = (email == owner); |
1273 | 1268 |
1274 if (non_owner_count < max_non_owner_users || is_owner) { | 1269 if (non_owner_count < max_non_owner_users || is_owner) { |
1275 DictionaryValue* user_dict = new DictionaryValue(); | 1270 DictionaryValue* user_dict = new DictionaryValue(); |
1276 FillUserDictionary(*it, is_owner, user_dict); | 1271 FillUserDictionary(*it, is_owner, user_dict); |
1277 bool is_public_account = | 1272 bool is_public_account = |
1278 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | 1273 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); |
1279 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); | 1274 bool signed_in = (*it)->is_logged_in(); |
1280 // Single user check here is necessary because owner info might not be | 1275 // Single user check here is necessary because owner info might not be |
1281 // available when running into login screen on first boot. | 1276 // available when running into login screen on first boot. |
1282 // See http://crosbug.com/12723 | 1277 // See http://crosbug.com/12723 |
1283 user_dict->SetBoolean(kKeyCanRemove, | 1278 user_dict->SetBoolean(kKeyCanRemove, |
1284 !single_user && | 1279 !single_user && |
1285 !email.empty() && | 1280 !email.empty() && |
1286 !is_owner && | 1281 !is_owner && |
1287 !is_public_account && | 1282 !is_public_account && |
1288 !signed_in && | 1283 !signed_in && |
1289 !is_signin_to_add); | 1284 !is_signin_to_add); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 if (!cros_settings) | 1606 if (!cros_settings) |
1612 return false; | 1607 return false; |
1613 | 1608 |
1614 // Offline login is allowed only when user pods are hidden. | 1609 // Offline login is allowed only when user pods are hidden. |
1615 bool show_pods; | 1610 bool show_pods; |
1616 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); | 1611 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, &show_pods); |
1617 return !show_pods; | 1612 return !show_pods; |
1618 } | 1613 } |
1619 | 1614 |
1620 } // namespace chromeos | 1615 } // namespace chromeos |
OLD | NEW |