Chromium Code Reviews| 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 25eb5ce9e906367e9d6c354caafe7c16257112d4..c578d81a19de6f880ce49c1454040e9a0b34913f 100644 |
| --- a/chrome/browser/supervised_user/child_accounts/child_account_service.cc |
| +++ b/chrome/browser/supervised_user/child_accounts/child_account_service.cc |
| @@ -109,6 +109,16 @@ void ChildAccountService::Shutdown() { |
| SigninManagerFactory::GetForProfile(profile_)->RemoveObserver(this); |
| } |
| +void ChildAccountService::AddFlagFetchingObserver( |
| + FlagsFetchingObserver* observer) { |
| + observer_list_.AddObserver(observer); |
| +} |
| + |
| +void ChildAccountService::RemoveFlagFetchingObserver( |
| + FlagsFetchingObserver* observer) { |
| + observer_list_.RemoveObserver(observer); |
| +} |
| + |
| bool ChildAccountService::SetActive(bool active) { |
| if (!profile_->IsChild() && !active_) |
| return false; |
| @@ -267,12 +277,17 @@ void ChildAccountService::StartFetchingServiceFlags() { |
| profile_->GetRequestContext(), |
| base::Bind(&ChildAccountService::OnFlagsFetched, |
| weak_ptr_factory_.GetWeakPtr()))); |
| + |
| + FOR_EACH_OBSERVER(FlagsFetchingObserver, observer_list_, |
| + OnFlagsFetchingStarted()); |
| } |
| void ChildAccountService::CancelFetchingServiceFlags() { |
| flag_fetcher_.reset(); |
| account_id_.clear(); |
| flag_fetch_timer_.Stop(); |
| + FOR_EACH_OBSERVER(FlagsFetchingObserver, observer_list_, |
| + OnFlagsFetchingCancelled()); |
| } |
| void ChildAccountService::OnFlagsFetched( |
| @@ -293,6 +308,8 @@ void ChildAccountService::OnFlagsFetched( |
| DLOG(WARNING) << "AccountServiceFlagFetcher returned error code " << result; |
| flag_fetch_backoff_.InformOfRequest(false); |
| ScheduleNextStatusFlagUpdate(flag_fetch_backoff_.GetTimeUntilRelease()); |
| + FOR_EACH_OBSERVER(FlagsFetchingObserver, observer_list_, |
| + OnFlagsFetchingError()); |
| return; |
| } |
| @@ -301,6 +318,8 @@ void ChildAccountService::OnFlagsFetched( |
| bool is_child_account = |
| std::find(flags.begin(), flags.end(), |
| kIsChildAccountServiceFlagName) != flags.end(); |
| + FOR_EACH_OBSERVER(FlagsFetchingObserver, observer_list_, |
|
Marc Treib
2015/03/04 09:59:15
I'd only call the observers if is_child_account ac
merkulova
2015/03/04 10:06:27
But we're actually waiting for the fetching to com
Marc Treib
2015/03/04 10:17:53
Right. We'd also want to notify the observers when
merkulova
2015/03/04 14:55:12
Done.
|
| + OnFlagsFetchingCompleted(is_child_account)); |
| SetIsChildAccount(is_child_account); |
| ScheduleNextStatusFlagUpdate( |