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 |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 account_id != AccountId::FromUserEmail(last_email) && | 1011 account_id != AccountId::FromUserEmail(last_email) && |
1012 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { | 1012 time_to_login.InSeconds() <= kLogoutToLoginDelayMaxSec) { |
1013 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", | 1013 UMA_HISTOGRAM_CUSTOM_COUNTS("UserManager.LogoutToLoginDelay", |
1014 time_to_login.InSeconds(), 0, | 1014 time_to_login.InSeconds(), 0, |
1015 kLogoutToLoginDelayMaxSec, 50); | 1015 kLogoutToLoginDelayMaxSec, 50); |
1016 } | 1016 } |
1017 } | 1017 } |
1018 | 1018 |
1019 void UserManagerBase::UpdateUserAccountLocale(const AccountId& account_id, | 1019 void UserManagerBase::UpdateUserAccountLocale(const AccountId& account_id, |
1020 const std::string& locale) { | 1020 const std::string& locale) { |
1021 scoped_ptr<std::string> resolved_locale(new std::string()); | 1021 std::unique_ptr<std::string> resolved_locale(new std::string()); |
1022 if (!locale.empty() && locale != GetApplicationLocale()) { | 1022 if (!locale.empty() && locale != GetApplicationLocale()) { |
1023 // base::Passed will nullptr out |resolved_locale|, so cache the underlying | 1023 // base::Passed will nullptr out |resolved_locale|, so cache the underlying |
1024 // ptr. | 1024 // ptr. |
1025 std::string* raw_resolved_locale = resolved_locale.get(); | 1025 std::string* raw_resolved_locale = resolved_locale.get(); |
1026 ScheduleResolveLocale(locale, | 1026 ScheduleResolveLocale(locale, |
1027 base::Bind(&UserManagerBase::DoUpdateAccountLocale, | 1027 base::Bind(&UserManagerBase::DoUpdateAccountLocale, |
1028 weak_factory_.GetWeakPtr(), account_id, | 1028 weak_factory_.GetWeakPtr(), account_id, |
1029 base::Passed(&resolved_locale)), | 1029 base::Passed(&resolved_locale)), |
1030 raw_resolved_locale); | 1030 raw_resolved_locale); |
1031 } else { | 1031 } else { |
1032 resolved_locale.reset(new std::string(locale)); | 1032 resolved_locale.reset(new std::string(locale)); |
1033 DoUpdateAccountLocale(account_id, std::move(resolved_locale)); | 1033 DoUpdateAccountLocale(account_id, std::move(resolved_locale)); |
1034 } | 1034 } |
1035 } | 1035 } |
1036 | 1036 |
1037 void UserManagerBase::DoUpdateAccountLocale( | 1037 void UserManagerBase::DoUpdateAccountLocale( |
1038 const AccountId& account_id, | 1038 const AccountId& account_id, |
1039 scoped_ptr<std::string> resolved_locale) { | 1039 std::unique_ptr<std::string> resolved_locale) { |
1040 User* user = FindUserAndModify(account_id); | 1040 User* user = FindUserAndModify(account_id); |
1041 if (user && resolved_locale) | 1041 if (user && resolved_locale) |
1042 user->SetAccountLocale(*resolved_locale); | 1042 user->SetAccountLocale(*resolved_locale); |
1043 } | 1043 } |
1044 | 1044 |
1045 void UserManagerBase::DeleteUser(User* user) { | 1045 void UserManagerBase::DeleteUser(User* user) { |
1046 const bool is_active_user = (user == active_user_); | 1046 const bool is_active_user = (user == active_user_); |
1047 delete user; | 1047 delete user; |
1048 if (is_active_user) | 1048 if (is_active_user) |
1049 active_user_ = nullptr; | 1049 active_user_ = nullptr; |
1050 } | 1050 } |
1051 | 1051 |
1052 } // namespace user_manager | 1052 } // namespace user_manager |
OLD | NEW |