| Index: chrome/browser/supervised_user/child_accounts/child_account_service.cc
|
| diff --git a/chrome/browser/supervised_user/child_accounts/child_account_service.cc b/chrome/browser/supervised_user/child_accounts/child_account_service.cc
|
| index e01f582e936c91a14a922b990a2f178c87920f5d..ebba0fc8293ce60099398660c29e34b8f35fd1a8 100644
|
| --- a/chrome/browser/supervised_user/child_accounts/child_account_service.cc
|
| +++ b/chrome/browser/supervised_user/child_accounts/child_account_service.cc
|
| @@ -27,6 +27,7 @@
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| +#include "components/pref_registry/pref_registry_syncable.h"
|
| #include "components/signin/core/browser/profile_oauth2_token_service.h"
|
| #include "components/signin/core/browser/signin_manager.h"
|
|
|
| @@ -94,6 +95,14 @@ bool ChildAccountService::IsChildAccountDetectionEnabled() {
|
| return group_name == "Enabled";
|
| }
|
|
|
| +void ChildAccountService::RegisterProfilePrefs(
|
| + user_prefs::PrefRegistrySyncable* registry) {
|
| + registry->RegisterBooleanPref(
|
| + prefs::kChildAccountStatusKnown,
|
| + false,
|
| + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
|
| +}
|
| +
|
| void ChildAccountService::SetIsChildAccount(bool is_child_account) {
|
| PropagateChildStatusToUser(is_child_account);
|
| if (profile_->IsChild() == is_child_account)
|
| @@ -120,6 +129,10 @@ void ChildAccountService::Init() {
|
| StartFetchingServiceFlags();
|
| }
|
|
|
| +bool ChildAccountService::IsChildAccountStatusKnown() {
|
| + return profile_->GetPrefs()->GetBoolean(prefs::kChildAccountStatusKnown);
|
| +}
|
| +
|
| void ChildAccountService::Shutdown() {
|
| family_fetcher_.reset();
|
| CancelFetchingServiceFlags();
|
| @@ -128,6 +141,15 @@ void ChildAccountService::Shutdown() {
|
| SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
|
| }
|
|
|
| +
|
| +void ChildAccountService::AddChildStatusReceivedCallback(
|
| + const base::Closure& callback) {
|
| + if (IsChildAccountStatusKnown())
|
| + callback.Run();
|
| + else
|
| + status_received_callback_list_.push_back(callback);
|
| +}
|
| +
|
| bool ChildAccountService::SetActive(bool active) {
|
| if (!profile_->IsChild() && !active_)
|
| return false;
|
| @@ -284,12 +306,6 @@ void ChildAccountService::StartFetchingServiceFlags() {
|
| }
|
| account_id_ = SigninManagerFactory::GetForProfile(profile_)
|
| ->GetAuthenticatedAccountId();
|
| - flag_fetcher_.reset(new AccountServiceFlagFetcher(
|
| - account_id_,
|
| - ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
|
| - profile_->GetRequestContext(),
|
| - base::Bind(&ChildAccountService::OnFlagsFetched,
|
| - weak_ptr_factory_.GetWeakPtr())));
|
| }
|
|
|
| void ChildAccountService::CancelFetchingServiceFlags() {
|
| @@ -324,6 +340,17 @@ void ChildAccountService::OnFlagsFetched(
|
| bool is_child_account =
|
| std::find(flags.begin(), flags.end(),
|
| kIsChildAccountServiceFlagName) != flags.end();
|
| +
|
| + bool status_was_known = profile_->GetPrefs()->GetBoolean(
|
| + prefs::kChildAccountStatusKnown);
|
| + profile_->GetPrefs()->SetBoolean(prefs::kChildAccountStatusKnown, true);
|
| +
|
| + if (!status_was_known) {
|
| + for (auto& callback : status_received_callback_list_)
|
| + callback.Run();
|
| + status_received_callback_list_.clear();
|
| + }
|
| +
|
| SetIsChildAccount(is_child_account);
|
|
|
| ScheduleNextStatusFlagUpdate(
|
|
|