Commit de8a3028 authored by Tanmoy Mollik's avatar Tanmoy Mollik Committed by Chromium LUCI CQ

Convert components/signin/p/identity_manager/* code to OnPrimaryAccountChanged

Method OnPrimaryAccountSet/Cleared and
OnUnconsentedPrimaryAccountChanged is deprecated. So this cl changes
these calls to OnPrimaryAccountChanged.

Bug: 1158855
Change-Id: Iecb78851b28f90934fb0127b8210ceac5f886457
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611097Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841430}
parent 3cf788ee
......@@ -77,25 +77,15 @@ void PrimaryAccountAccessTokenFetcher::StartAccessTokenRequest() {
AccessTokenFetcher::Mode::kImmediate);
}
void PrimaryAccountAccessTokenFetcher::OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) {
// When sync consent is not required the signin is handled in
// OnUnconsentedPrimaryAccountChanged() below.
if (consent_ == ConsentLevel::kNotRequired)
return;
DCHECK(!primary_account_info.account_id.empty());
ProcessSigninStateChange();
}
void PrimaryAccountAccessTokenFetcher::OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) {
// This method is called after both SetPrimaryAccount and
// SetUnconsentedPrimaryAccount.
if (consent_ == ConsentLevel::kSync)
return;
// We're only interested when the account is set.
if (primary_account_info.account_id.empty())
void PrimaryAccountAccessTokenFetcher::OnPrimaryAccountChanged(
const PrimaryAccountChangeEvent& event) {
// We're only interested when the account is set for the |consent_|
// consent level.
if (event.GetEventTypeFor(consent_) !=
PrimaryAccountChangeEvent::Type::kSet) {
return;
}
DCHECK(!event.GetCurrentState().primary_account.account_id.empty());
ProcessSigninStateChange();
}
......
......@@ -177,10 +177,7 @@ class PrimaryAccountAccessTokenFetcher : public IdentityManager::Observer {
void StartAccessTokenRequest();
// IdentityManager::Observer implementation.
void OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) override;
void OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) override;
void OnPrimaryAccountChanged(const PrimaryAccountChangeEvent& event) override;
void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override;
......
......@@ -133,25 +133,38 @@ TestIdentityManagerObserver::BatchChangeRecords() const {
}
// IdentityManager::Observer:
void TestIdentityManagerObserver::OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) {
primary_account_from_set_callback_ = primary_account_info;
if (on_primary_account_set_callback_)
std::move(on_primary_account_set_callback_).Run();
}
void TestIdentityManagerObserver::OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) {
primary_account_from_cleared_callback_ = previous_primary_account_info;
if (on_primary_account_cleared_callback_)
std::move(on_primary_account_cleared_callback_).Run();
}
void TestIdentityManagerObserver::OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& unconsented_primary_account_info) {
unconsented_primary_account_from_callback_ = unconsented_primary_account_info;
if (on_unconsented_primary_account_callback_)
std::move(on_unconsented_primary_account_callback_).Run();
void TestIdentityManagerObserver::OnPrimaryAccountChanged(
const PrimaryAccountChangeEvent& event) {
// TODO(https://crbug.com/1158855): Refactor this test observer to
// have a single on_primary_account_changed_callback_ and a single
// on_primary_account_changed_event_.
switch (event.GetEventTypeFor(ConsentLevel::kNotRequired)) {
case PrimaryAccountChangeEvent::Type::kSet:
case PrimaryAccountChangeEvent::Type::kCleared:
unconsented_primary_account_from_callback_ =
event.GetCurrentState().primary_account;
if (on_unconsented_primary_account_callback_)
std::move(on_unconsented_primary_account_callback_).Run();
break;
case PrimaryAccountChangeEvent::Type::kNone:
break;
}
switch (event.GetEventTypeFor(ConsentLevel::kSync)) {
case PrimaryAccountChangeEvent::Type::kSet:
primary_account_from_set_callback_ =
event.GetCurrentState().primary_account;
if (on_primary_account_set_callback_)
std::move(on_primary_account_set_callback_).Run();
break;
case PrimaryAccountChangeEvent::Type::kCleared:
primary_account_from_cleared_callback_ =
event.GetPreviousState().primary_account;
if (on_primary_account_cleared_callback_)
std::move(on_primary_account_cleared_callback_).Run();
break;
case PrimaryAccountChangeEvent::Type::kNone:
break;
}
}
void TestIdentityManagerObserver::OnRefreshTokenUpdatedForAccount(
......
......@@ -64,12 +64,8 @@ class TestIdentityManagerObserver : IdentityManager::Observer {
private:
// IdentityManager::Observer:
void OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) override;
void OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) override;
void OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& unconsented_primary_account_info) override;
void OnPrimaryAccountChanged(
const PrimaryAccountChangeEvent& event_details) override;
void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override;
void OnRefreshTokenRemovedForAccount(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment