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_impl.h" | 5 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 } | 499 } |
500 | 500 |
501 bool ChromeUserManagerImpl::AreEphemeralUsersEnabled() const { | 501 bool ChromeUserManagerImpl::AreEphemeralUsersEnabled() const { |
502 policy::BrowserPolicyConnectorChromeOS* connector = | 502 policy::BrowserPolicyConnectorChromeOS* connector = |
503 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 503 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
504 return GetEphemeralUsersEnabled() && | 504 return GetEphemeralUsersEnabled() && |
505 (connector->IsEnterpriseManaged() || GetOwnerAccountId().is_valid()); | 505 (connector->IsEnterpriseManaged() || GetOwnerAccountId().is_valid()); |
506 } | 506 } |
507 | 507 |
508 void ChromeUserManagerImpl::OnUserRemoved(const AccountId& account_id) { | 508 void ChromeUserManagerImpl::OnUserRemoved(const AccountId& account_id) { |
509 RemoveReportingUser(FullyCanonicalize(account_id.GetUserEmail())); | 509 RemoveReportingUser(account_id); |
510 } | 510 } |
511 | 511 |
512 const std::string& ChromeUserManagerImpl::GetApplicationLocale() const { | 512 const std::string& ChromeUserManagerImpl::GetApplicationLocale() const { |
513 return g_browser_process->GetApplicationLocale(); | 513 return g_browser_process->GetApplicationLocale(); |
514 } | 514 } |
515 | 515 |
516 PrefService* ChromeUserManagerImpl::GetLocalState() const { | 516 PrefService* ChromeUserManagerImpl::GetLocalState() const { |
517 return g_browser_process ? g_browser_process->local_state() : NULL; | 517 return g_browser_process ? g_browser_process->local_state() : NULL; |
518 } | 518 } |
519 | 519 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1143 !system::HasSystemTimezonePolicy()) { | 1143 !system::HasSystemTimezonePolicy()) { |
1144 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); | 1144 g_browser_process->platform_part()->GetTimezoneResolver()->Start(); |
1145 } else { | 1145 } else { |
1146 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); | 1146 g_browser_process->platform_part()->GetTimezoneResolver()->Stop(); |
1147 } | 1147 } |
1148 } | 1148 } |
1149 | 1149 |
1150 void ChromeUserManagerImpl::SetUserAffiliation( | 1150 void ChromeUserManagerImpl::SetUserAffiliation( |
1151 const std::string& user_email, | 1151 const std::string& user_email, |
1152 const AffiliationIDSet& user_affiliation_ids) { | 1152 const AffiliationIDSet& user_affiliation_ids) { |
1153 std::string canonicalized_email = FullyCanonicalize(user_email); | 1153 const AccountId& account_id = |
1154 user_manager::User* user = | 1154 user_manager::UserManager::GetKnownUserAccountId(user_email, |
1155 FindUserAndModify(AccountId::FromUserEmail(canonicalized_email)); | 1155 std::string()); |
1156 user_manager::User* user = FindUserAndModify(account_id); | |
1156 | 1157 |
1157 if (user) { | 1158 if (user) { |
1158 policy::BrowserPolicyConnectorChromeOS const* const connector = | 1159 policy::BrowserPolicyConnectorChromeOS const* const connector = |
1159 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1160 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
1160 const bool is_affiliated = chromeos::IsUserAffiliated( | 1161 const bool is_affiliated = chromeos::IsUserAffiliated( |
1161 user_affiliation_ids, connector->GetDeviceAffiliationIDs(), | 1162 user_affiliation_ids, connector->GetDeviceAffiliationIDs(), |
1162 canonicalized_email, connector->GetEnterpriseDomain()); | 1163 account_id.GetUserEmail(), connector->GetEnterpriseDomain()); |
achuithb
2015/11/23 21:17:39
I assume this will take account_id in the future?
Alexander Alekseev
2015/11/24 06:04:11
Yes.
| |
1163 user->set_affiliation(is_affiliated); | 1164 user->set_affiliation(is_affiliated); |
1164 | 1165 |
1165 if (user->GetType() == user_manager::USER_TYPE_REGULAR) { | 1166 if (user->GetType() == user_manager::USER_TYPE_REGULAR) { |
1166 if (is_affiliated) { | 1167 if (is_affiliated) { |
1167 AddReportingUser(canonicalized_email); | 1168 AddReportingUser(account_id); |
1168 } else { | 1169 } else { |
1169 RemoveReportingUser(canonicalized_email); | 1170 RemoveReportingUser(account_id); |
1170 } | 1171 } |
1171 } | 1172 } |
1172 } | 1173 } |
1173 } | 1174 } |
1174 | 1175 |
1175 bool ChromeUserManagerImpl::ShouldReportUser(const std::string& user_id) const { | 1176 bool ChromeUserManagerImpl::ShouldReportUser(const std::string& user_id) const { |
1176 const base::ListValue& reporting_users = | 1177 const base::ListValue& reporting_users = |
1177 *(GetLocalState()->GetList(kReportingUsers)); | 1178 *(GetLocalState()->GetList(kReportingUsers)); |
1178 base::StringValue user_id_value(FullyCanonicalize(user_id)); | 1179 base::StringValue user_id_value(FullyCanonicalize(user_id)); |
1179 return !(reporting_users.Find(user_id_value) == reporting_users.end()); | 1180 return !(reporting_users.Find(user_id_value) == reporting_users.end()); |
1180 } | 1181 } |
1181 | 1182 |
1182 void ChromeUserManagerImpl::AddReportingUser(const std::string& user_id) { | 1183 void ChromeUserManagerImpl::AddReportingUser(const AccountId& account_id) { |
1183 ListPrefUpdate users_update(GetLocalState(), kReportingUsers); | 1184 ListPrefUpdate users_update(GetLocalState(), kReportingUsers); |
1184 users_update->AppendIfNotPresent( | 1185 users_update->AppendIfNotPresent( |
1185 new base::StringValue(FullyCanonicalize(user_id))); | 1186 new base::StringValue(account_id.GetUserEmail())); |
1186 } | 1187 } |
1187 | 1188 |
1188 void ChromeUserManagerImpl::RemoveReportingUser(const std::string& user_id) { | 1189 void ChromeUserManagerImpl::RemoveReportingUser(const AccountId& account_id) { |
1189 ListPrefUpdate users_update(GetLocalState(), kReportingUsers); | 1190 ListPrefUpdate users_update(GetLocalState(), kReportingUsers); |
1190 users_update->Remove(base::StringValue(FullyCanonicalize(user_id)), NULL); | 1191 users_update->Remove( |
1192 base::StringValue(FullyCanonicalize(account_id.GetUserEmail())), NULL); | |
achuithb
2015/11/23 21:17:39
Is FullyCanonicalize necessary here?
Alexander Alekseev
2015/11/24 06:04:11
I left it here in order not to miss this fact late
| |
1191 } | 1193 } |
1192 | 1194 |
1193 } // namespace chromeos | 1195 } // namespace chromeos |
OLD | NEW |