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/supervised_user/child_accounts/child_account_service.h" | 5 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 } | 197 } |
198 profile_->GetPrefs()->SetBoolean(prefs::kChildAccountStatusKnown, true); | 198 profile_->GetPrefs()->SetBoolean(prefs::kChildAccountStatusKnown, true); |
199 | 199 |
200 for (const auto& callback : status_received_callback_list_) | 200 for (const auto& callback : status_received_callback_list_) |
201 callback.Run(); | 201 callback.Run(); |
202 status_received_callback_list_.clear(); | 202 status_received_callback_list_.clear(); |
203 } | 203 } |
204 | 204 |
205 void ChildAccountService::OnAccountUpdated(const AccountInfo& info) { | 205 void ChildAccountService::OnAccountUpdated(const AccountInfo& info) { |
206 std::string auth_account_id = SigninManagerFactory::GetForProfile(profile_) | |
207 ->GetAuthenticatedAccountId(); | |
208 if (!info.IsValid() || info.account_id != auth_account_id) | |
209 return; | |
210 | |
211 if (!IsChildAccountDetectionEnabled()) { | 206 if (!IsChildAccountDetectionEnabled()) { |
212 SetIsChildAccount(false); | 207 SetIsChildAccount(false); |
213 return; | 208 return; |
214 } | 209 } |
215 | 210 |
| 211 std::string auth_account_id = SigninManagerFactory::GetForProfile(profile_) |
| 212 ->GetAuthenticatedAccountId(); |
| 213 if (info.account_id != auth_account_id) |
| 214 return; |
| 215 |
216 SetIsChildAccount(info.is_child_account); | 216 SetIsChildAccount(info.is_child_account); |
217 } | 217 } |
218 | 218 |
219 void ChildAccountService::OnGetFamilyMembersSuccess( | 219 void ChildAccountService::OnGetFamilyMembersSuccess( |
220 const std::vector<FamilyInfoFetcher::FamilyMember>& members) { | 220 const std::vector<FamilyInfoFetcher::FamilyMember>& members) { |
221 bool hoh_found = false; | 221 bool hoh_found = false; |
222 bool parent_found = false; | 222 bool parent_found = false; |
223 for (const FamilyInfoFetcher::FamilyMember& member : members) { | 223 for (const FamilyInfoFetcher::FamilyMember& member : members) { |
224 if (member.role == FamilyInfoFetcher::HEAD_OF_HOUSEHOLD) { | 224 if (member.role == FamilyInfoFetcher::HEAD_OF_HOUSEHOLD) { |
225 hoh_found = true; | 225 hoh_found = true; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 } | 320 } |
321 | 321 |
322 void ChildAccountService::ClearSecondCustodianPrefs() { | 322 void ChildAccountService::ClearSecondCustodianPrefs() { |
323 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianName); | 323 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianName); |
324 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianEmail); | 324 profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserSecondCustodianEmail); |
325 profile_->GetPrefs()->ClearPref( | 325 profile_->GetPrefs()->ClearPref( |
326 prefs::kSupervisedUserSecondCustodianProfileURL); | 326 prefs::kSupervisedUserSecondCustodianProfileURL); |
327 profile_->GetPrefs()->ClearPref( | 327 profile_->GetPrefs()->ClearPref( |
328 prefs::kSupervisedUserSecondCustodianProfileImageURL); | 328 prefs::kSupervisedUserSecondCustodianProfileImageURL); |
329 } | 329 } |
OLD | NEW |