Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc

Issue 150203002: Public pods move to the beginning of user list on sign-in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 TRACE_EVENT_ASYNC_STEP_INTO0("ui", 1220 TRACE_EVENT_ASYNC_STEP_INTO0("ui",
1221 "ShowLoginWebUI", 1221 "ShowLoginWebUI",
1222 LoginDisplayHostImpl::kShowLoginWebUIid, 1222 LoginDisplayHostImpl::kShowLoginWebUIid,
1223 "SendUserList"); 1223 "SendUserList");
1224 BootTimesLoader::Get()->RecordCurrentStats("login-send-user-list"); 1224 BootTimesLoader::Get()->RecordCurrentStats("login-send-user-list");
1225 1225
1226 size_t max_non_owner_users = kMaxUsers - 1; 1226 size_t max_non_owner_users = kMaxUsers - 1;
1227 size_t non_owner_count = 0; 1227 size_t non_owner_count = 0;
1228 1228
1229 base::ListValue users_list; 1229 base::ListValue users_list;
1230 size_t first_non_public_account_index = 0;
1230 const UserList& users = delegate_->GetUsers(); 1231 const UserList& users = delegate_->GetUsers();
1231 1232
1232 // TODO(nkostylev): Move to a separate method in UserManager. 1233 // TODO(nkostylev): Move to a separate method in UserManager.
1233 // http://crbug.com/230852 1234 // http://crbug.com/230852
1234 bool is_signin_to_add = LoginDisplayHostImpl::default_host() && 1235 bool is_signin_to_add = LoginDisplayHostImpl::default_host() &&
1235 UserManager::Get()->IsUserLoggedIn(); 1236 UserManager::Get()->IsUserLoggedIn();
1236 1237
1237 bool single_user = users.size() == 1; 1238 bool single_user = users.size() == 1;
1239 std::string owner;
1240 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner);
1238 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 1241 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
1239 const std::string& email = (*it)->email(); 1242 const std::string& email = (*it)->email();
1240
1241 std::string owner;
1242 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner);
1243 bool is_owner = (email == owner); 1243 bool is_owner = (email == owner);
1244 1244
1245 if (non_owner_count < max_non_owner_users || is_owner) { 1245 if (non_owner_count < max_non_owner_users || is_owner) {
1246 base::DictionaryValue* user_dict = new base::DictionaryValue(); 1246 base::DictionaryValue* user_dict = new base::DictionaryValue();
1247 FillUserDictionary(*it, is_owner, user_dict); 1247 FillUserDictionary(*it, is_owner, user_dict);
1248 bool is_public_account = 1248 bool is_public_account =
1249 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); 1249 ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT);
1250 bool signed_in = (*it)->is_logged_in(); 1250 bool signed_in = (*it)->is_logged_in();
1251 // Single user check here is necessary because owner info might not be 1251 // Single user check here is necessary because owner info might not be
1252 // available when running into login screen on first boot. 1252 // available when running into login screen on first boot.
1253 // See http://crosbug.com/12723 1253 // See http://crosbug.com/12723
1254 user_dict->SetBoolean(kKeyCanRemove, 1254 user_dict->SetBoolean(kKeyCanRemove,
1255 !single_user && 1255 !single_user &&
1256 !email.empty() && 1256 !email.empty() &&
1257 !is_owner && 1257 !is_owner &&
1258 !is_public_account && 1258 !is_public_account &&
1259 !signed_in && 1259 !signed_in &&
1260 !is_signin_to_add); 1260 !is_signin_to_add);
1261 1261
1262 users_list.Append(user_dict); 1262 // public accounts come first in the list
1263 if (is_public_account)
1264 users_list.Insert(first_non_public_account_index++, user_dict);
1265 else
1266 users_list.Append(user_dict);
1263 if (!is_owner) 1267 if (!is_owner)
1264 ++non_owner_count; 1268 ++non_owner_count;
1265 } 1269 }
1266 } 1270 }
1267 1271
1268 CallJS("login.AccountPickerScreen.loadUsers", users_list, animated, 1272 CallJS("login.AccountPickerScreen.loadUsers", users_list, animated,
1269 delegate_->IsShowGuest()); 1273 delegate_->IsShowGuest());
1270 } 1274 }
1271 1275
1272 void SigninScreenHandler::HandleAccountPickerReady() { 1276 void SigninScreenHandler::HandleAccountPickerReady() {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 DCHECK(gaia_screen_handler_); 1654 DCHECK(gaia_screen_handler_);
1651 return gaia_screen_handler_->frame_state(); 1655 return gaia_screen_handler_->frame_state();
1652 } 1656 }
1653 1657
1654 net::Error SigninScreenHandler::FrameError() const { 1658 net::Error SigninScreenHandler::FrameError() const {
1655 DCHECK(gaia_screen_handler_); 1659 DCHECK(gaia_screen_handler_);
1656 return gaia_screen_handler_->frame_error(); 1660 return gaia_screen_handler_->frame_error();
1657 } 1661 }
1658 1662
1659 } // namespace chromeos 1663 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698