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

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: Null checks removed. 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
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 1e906124a4b7ba4cd6950fc33d535a2f32049a8e..303f38dfcda3555220151d2b14063e3439d805e3 100644
--- a/chrome/browser/supervised_user/child_accounts/child_account_service.cc
+++ b/chrome/browser/supervised_user/child_accounts/child_account_service.cc
@@ -26,6 +26,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"
@@ -75,6 +76,15 @@ ChildAccountService::ChildAccountService(Profile* profile)
ChildAccountService::~ChildAccountService() {}
+// static
+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)
@@ -101,6 +111,10 @@ void ChildAccountService::Init() {
StartFetchingServiceFlags();
}
+bool ChildAccountService::IsChildAccountStatusKnown() {
+ return profile_->GetPrefs()->GetBoolean(prefs::kChildAccountStatusKnown);
+}
+
void ChildAccountService::Shutdown() {
family_fetcher_.reset();
CancelFetchingServiceFlags();
@@ -109,6 +123,16 @@ void ChildAccountService::Shutdown() {
SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
}
+void ChildAccountService::AddStatusObserver(
+ ChildAccountStatusObserver* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void ChildAccountService::RemoveStatusObserver(
+ ChildAccountStatusObserver* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
bool ChildAccountService::SetActive(bool active) {
if (!profile_->IsChild() && !active_)
return false;
@@ -261,6 +285,12 @@ void ChildAccountService::ScheduleNextFamilyInfoUpdate(base::TimeDelta delay) {
void ChildAccountService::StartFetchingServiceFlags() {
account_id_ = SigninManagerFactory::GetForProfile(profile_)
->GetAuthenticatedAccountId();
+ flag_fetcher_.reset(new AccountServiceFlagFetcher(
Marc Treib 2015/03/10 09:26:17 Don't re-add this code in this CL, please - see ht
merkulova 2015/03/10 09:37:29 Sorry, I think it was re-added on CL rebase.
+ account_id_,
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
+ profile_->GetRequestContext(),
+ base::Bind(&ChildAccountService::OnFlagsFetched,
+ weak_ptr_factory_.GetWeakPtr())));
}
void ChildAccountService::CancelFetchingServiceFlags() {
@@ -295,6 +325,16 @@ 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_EACH_OBSERVER(ChildAccountStatusObserver, observer_list_,
+ OnChildAccountStatusChanged(is_child_account));
+ }
+
SetIsChildAccount(is_child_account);
ScheduleNextStatusFlagUpdate(

Powered by Google App Engine
This is Rietveld 408576698