| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/login/users/chrome_user_manager.h" | 5 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 6 | 6 |
| 7 #include <cstddef> | 7 #include <cstddef> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "ash/multi_profile_uma.h" | 10 #include "ash/multi_profile_uma.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 219 |
| 220 return result; | 220 return result; |
| 221 } | 221 } |
| 222 | 222 |
| 223 user_manager::UserList ChromeUserManager::GetUnlockUsers() const { | 223 user_manager::UserList ChromeUserManager::GetUnlockUsers() const { |
| 224 const user_manager::UserList& logged_in_users = GetLoggedInUsers(); | 224 const user_manager::UserList& logged_in_users = GetLoggedInUsers(); |
| 225 if (logged_in_users.empty()) | 225 if (logged_in_users.empty()) |
| 226 return user_manager::UserList(); | 226 return user_manager::UserList(); |
| 227 | 227 |
| 228 user_manager::UserList unlock_users; | 228 user_manager::UserList unlock_users; |
| 229 Profile* profile = ProfileHelper::Get()->GetProfileByUser(GetPrimaryUser()); | 229 Profile* profile = |
| 230 ProfileHelper::Get()->GetProfileByUserUnsafe(GetPrimaryUser()); |
| 230 std::string primary_behavior = | 231 std::string primary_behavior = |
| 231 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); | 232 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); |
| 232 | 233 |
| 233 // Specific case: only one logged in user or | 234 // Specific case: only one logged in user or |
| 234 // primary user has primary-only multi-profile policy. | 235 // primary user has primary-only multi-profile policy. |
| 235 if (logged_in_users.size() == 1 || | 236 if (logged_in_users.size() == 1 || |
| 236 primary_behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { | 237 primary_behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { |
| 237 if (GetPrimaryUser()->can_lock()) | 238 if (GetPrimaryUser()->can_lock()) |
| 238 unlock_users.push_back(primary_user_); | 239 unlock_users.push_back(primary_user_); |
| 239 } else { | 240 } else { |
| 240 // Fill list of potential unlock users based on multi-profile policy state. | 241 // Fill list of potential unlock users based on multi-profile policy state. |
| 241 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); | 242 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); |
| 242 it != logged_in_users.end(); | 243 it != logged_in_users.end(); |
| 243 ++it) { | 244 ++it) { |
| 244 user_manager::User* user = (*it); | 245 user_manager::User* user = (*it); |
| 245 Profile* profile = ProfileHelper::Get()->GetProfileByUser(user); | 246 Profile* profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
| 246 const std::string behavior = | 247 const std::string behavior = |
| 247 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); | 248 profile->GetPrefs()->GetString(prefs::kMultiProfileUserBehavior); |
| 248 if (behavior == MultiProfileUserController::kBehaviorUnrestricted && | 249 if (behavior == MultiProfileUserController::kBehaviorUnrestricted && |
| 249 user->can_lock()) { | 250 user->can_lock()) { |
| 250 unlock_users.push_back(user); | 251 unlock_users.push_back(user); |
| 251 } else if (behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { | 252 } else if (behavior == MultiProfileUserController::kBehaviorPrimaryOnly) { |
| 252 NOTREACHED() | 253 NOTREACHED() |
| 253 << "Spotted primary-only multi-profile policy for non-primary user"; | 254 << "Spotted primary-only multi-profile policy for non-primary user"; |
| 254 } | 255 } |
| 255 } | 256 } |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 if ((users + GetUsersAdmittedForMultiProfile().size()) > 1) | 1007 if ((users + GetUsersAdmittedForMultiProfile().size()) > 1) |
| 1007 ash::MultiProfileUMA::RecordUserCount(users); | 1008 ash::MultiProfileUMA::RecordUserCount(users); |
| 1008 } | 1009 } |
| 1009 | 1010 |
| 1010 base::debug::SetCrashKeyValue( | 1011 base::debug::SetCrashKeyValue( |
| 1011 crash_keys::kNumberOfUsers, | 1012 crash_keys::kNumberOfUsers, |
| 1012 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); | 1013 base::StringPrintf("%" PRIuS, GetLoggedInUsers().size())); |
| 1013 } | 1014 } |
| 1014 | 1015 |
| 1015 } // namespace chromeos | 1016 } // namespace chromeos |
| OLD | NEW |