Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5911)

Unified Diff: chrome/browser/supervised_user/child_accounts/child_account_service.cc

Issue 971383002: Removing FRE UI for unicorn accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/supervised_user/child_accounts/child_account_service.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « chrome/browser/supervised_user/child_accounts/child_account_service.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698