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

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

Issue 986303002: Re-enable child account detection, now behind a flag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum -> int 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..e01f582e936c91a14a922b990a2f178c87920f5d 100644
--- a/chrome/browser/supervised_user/child_accounts/child_account_service.cc
+++ b/chrome/browser/supervised_user/child_accounts/child_account_service.cc
@@ -9,6 +9,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/message_loop/message_loop.h"
+#include "base/metrics/field_trial.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/values.h"
@@ -34,6 +35,8 @@
#include "components/user_manager/user_manager.h"
#endif
+const char kChildAccountDetectionFieldTrialName[] = "ChildAccountDetection";
+
const char kIsChildAccountServiceFlagName[] = "uca";
// Normally, re-check the child account flag and the family info once per day.
@@ -75,6 +78,22 @@ ChildAccountService::ChildAccountService(Profile* profile)
ChildAccountService::~ChildAccountService() {}
+// static
+bool ChildAccountService::IsChildAccountDetectionEnabled() {
+ // Note: It's important to query the field trial state first, to ensure that
+ // UMA reports the correct group.
+ const std::string group_name =
+ base::FieldTrialList::FindFullName(kChildAccountDetectionFieldTrialName);
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kDisableChildAccountDetection))
+ return false;
+ if (command_line->HasSwitch(switches::kEnableChildAccountDetection))
+ return true;
+
+ return group_name == "Enabled";
+}
+
void ChildAccountService::SetIsChildAccount(bool is_child_account) {
PropagateChildStatusToUser(is_child_account);
if (profile_->IsChild() == is_child_account)
@@ -259,8 +278,18 @@ void ChildAccountService::ScheduleNextFamilyInfoUpdate(base::TimeDelta delay) {
}
void ChildAccountService::StartFetchingServiceFlags() {
+ if (!IsChildAccountDetectionEnabled()) {
+ SetIsChildAccount(false);
+ return;
+ }
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() {

Powered by Google App Engine
This is Rietveld 408576698