#ifndef CHROME_BROWSER_CONTEXTUAL_TASKS_ENTRY_POINT_ELIGIBILITY_MANAGER_H_
#define CHROME_BROWSER_CONTEXTUAL_TASKS_ENTRY_POINT_ELIGIBILITY_MANAGER_H_
#include "base/callback_list.h"
#include "base/scoped_observation.h"
#include "components/prefs/pref_member.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "ui/base/unowned_user_data/scoped_unowned_user_data.h"
class BrowserWindowInterface;
class Profile;
namespace signin {
class PrimaryAccountChangeEvent;
}
namespace contextual_tasks {
class EntryPointEligibilityManager : public signin::IdentityManager::Observer {
public:
DECLARE_USER_DATA(EntryPointEligibilityManager);
explicit EntryPointEligibilityManager(
BrowserWindowInterface* browser_window_interface);
~EntryPointEligibilityManager() override;
static EntryPointEligibilityManager* From(
BrowserWindowInterface* browser_window_interface);
void OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) override;
void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override;
void OnRefreshTokenRemovedForAccount(
const CoreAccountId& account_id) override;
void OnErrorStateOfRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info,
const GoogleServiceAuthError& error,
signin_metrics::SourceForRefreshTokenOperation token_operation_source)
override;
void OnAccountsInCookieUpdated(
const signin::AccountsInCookieJarInfo& accounts_in_cookie_jar_info,
const GoogleServiceAuthError& error) override;
void OnAccountsCookieDeletedByUserAction() override;
bool AreEntryPointsEligible();
static bool IsEligible(Profile* profile);
using EntryPointEligibilityChangeCallbackList =
base::RepeatingCallbackList<void(bool)>;
base::CallbackListSubscription RegisterOnEntryPointEligibilityChanged(
EntryPointEligibilityChangeCallbackList::CallbackType callback);
private:
void OnAimPolicyChanged();
void MaybeNotifyEntryPointEligibilityChanged();
bool entry_points_are_eligible_ = false;
raw_ptr<Profile> profile_ = nullptr;
IntegerPrefMember aim_policy_;
ui::ScopedUnownedUserData<EntryPointEligibilityManager>
scoped_unowned_user_data_;
base::CallbackListSubscription aim_eligibility_callback_subscription_;
base::ScopedObservation<signin::IdentityManager,
signin::IdentityManager::Observer>
identity_manager_observation_{this};
EntryPointEligibilityChangeCallbackList
entry_point_eligibility_change_callback_list_;
};
}
#endif