Skip to content

Commit

Permalink
Correct ChildAccountService child flag retrieval
Browse files Browse the repository at this point in the history
This CL fixes two bugs in ChildAccountService's child flag retrieval:
* When flag fetching is disabled by command-line flag, causing all
  accounts to be marked as non-child, the flag status should be set
  to "known," not "unknown."
* When the flag is retrieved from the cloud, it should be stored
  before notifying callbacks waiting for the retrieval to finish.

This CL is a prerequisite for the test in crbug.com/477145.

BUG=477145
TEST=Tested as part of the new browser test in follow-up CL

Review URL: https://codereview.chromium.org/1051273009

Cr-Commit-Position: refs/heads/master@{#326058}
  • Loading branch information
bartfab authored and Commit bot committed Apr 21, 2015
1 parent 7664f9b commit fa8233a
Showing 1 changed file with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,19 @@ void ChildAccountService::RegisterProfilePrefs(

void ChildAccountService::SetIsChildAccount(bool is_child_account) {
PropagateChildStatusToUser(is_child_account);
if (profile_->IsChild() == is_child_account)
return;

if (is_child_account) {
profile_->GetPrefs()->SetString(prefs::kSupervisedUserId,
supervised_users::kChildAccountSUID);
} else {
profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserId);
if (profile_->IsChild() != is_child_account) {
if (is_child_account) {
profile_->GetPrefs()->SetString(prefs::kSupervisedUserId,
supervised_users::kChildAccountSUID);
} else {
profile_->GetPrefs()->ClearPref(prefs::kSupervisedUserId);
}
}
profile_->GetPrefs()->SetBoolean(prefs::kChildAccountStatusKnown, true);

for (const auto& callback : status_received_callback_list_)
callback.Run();
status_received_callback_list_.clear();
}

void ChildAccountService::Init() {
Expand Down Expand Up @@ -321,16 +325,6 @@ void ChildAccountService::OnFlagsFetched(
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(
Expand Down

0 comments on commit fa8233a

Please sign in to comment.