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 "components/user_manager/user_manager_base.h" | 5 #include "components/user_manager/user_manager_base.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/memory/ptr_util.h" |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
21 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
23 #include "base/task_runner.h" | 24 #include "base/task_runner.h" |
24 #include "base/values.h" | 25 #include "base/values.h" |
25 #include "components/prefs/pref_registry_simple.h" | 26 #include "components/prefs/pref_registry_simple.h" |
26 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
27 #include "components/prefs/scoped_user_pref_update.h" | 28 #include "components/prefs/scoped_user_pref_update.h" |
28 #include "components/session_manager/core/session_manager.h" | 29 #include "components/session_manager/core/session_manager.h" |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 } | 845 } |
845 | 846 |
846 void UserManagerBase::GuestUserLoggedIn() { | 847 void UserManagerBase::GuestUserLoggedIn() { |
847 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 848 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
848 active_user_ = User::CreateGuestUser(GetGuestAccountId()); | 849 active_user_ = User::CreateGuestUser(GetGuestAccountId()); |
849 } | 850 } |
850 | 851 |
851 void UserManagerBase::AddUserRecord(User* user) { | 852 void UserManagerBase::AddUserRecord(User* user) { |
852 // Add the user to the front of the user list. | 853 // Add the user to the front of the user list. |
853 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); | 854 ListPrefUpdate prefs_users_update(GetLocalState(), kRegularUsers); |
854 prefs_users_update->Insert(0, new base::StringValue(user->email())); | 855 prefs_users_update->Insert( |
| 856 0, base::MakeUnique<base::StringValue>(user->email())); |
855 users_.insert(users_.begin(), user); | 857 users_.insert(users_.begin(), user); |
856 } | 858 } |
857 | 859 |
858 void UserManagerBase::RegularUserLoggedIn(const AccountId& account_id) { | 860 void UserManagerBase::RegularUserLoggedIn(const AccountId& account_id) { |
859 // Remove the user from the user list. | 861 // Remove the user from the user list. |
860 active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); | 862 active_user_ = RemoveRegularOrSupervisedUserFromList(account_id); |
861 | 863 |
862 // If the user was not found on the user list, create a new user. | 864 // If the user was not found on the user list, create a new user. |
863 SetIsCurrentUserNew(!active_user_); | 865 SetIsCurrentUserNew(!active_user_); |
864 if (IsCurrentUserNew()) { | 866 if (IsCurrentUserNew()) { |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 } | 1076 } |
1075 | 1077 |
1076 void UserManagerBase::DeleteUser(User* user) { | 1078 void UserManagerBase::DeleteUser(User* user) { |
1077 const bool is_active_user = (user == active_user_); | 1079 const bool is_active_user = (user == active_user_); |
1078 delete user; | 1080 delete user; |
1079 if (is_active_user) | 1081 if (is_active_user) |
1080 active_user_ = nullptr; | 1082 active_user_ = nullptr; |
1081 } | 1083 } |
1082 | 1084 |
1083 } // namespace user_manager | 1085 } // namespace user_manager |
OLD | NEW |