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() { ...@@ -77,25 +77,15 @@ void PrimaryAccountAccessTokenFetcher::StartAccessTokenRequest() {
AccessTokenFetcher::Mode::kImmediate); AccessTokenFetcher::Mode::kImmediate);
} }
void PrimaryAccountAccessTokenFetcher::OnPrimaryAccountSet( void PrimaryAccountAccessTokenFetcher::OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) { const PrimaryAccountChangeEvent& event) {
// When sync consent is not required the signin is handled in // We're only interested when the account is set for the |consent_|
// OnUnconsentedPrimaryAccountChanged() below. // consent level.
if (consent_ == ConsentLevel::kNotRequired) if (event.GetEventTypeFor(consent_) !=
return; PrimaryAccountChangeEvent::Type::kSet) {
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())
return; return;
}
DCHECK(!event.GetCurrentState().primary_account.account_id.empty());
ProcessSigninStateChange(); ProcessSigninStateChange();
} }
......
...@@ -177,10 +177,7 @@ class PrimaryAccountAccessTokenFetcher : public IdentityManager::Observer { ...@@ -177,10 +177,7 @@ class PrimaryAccountAccessTokenFetcher : public IdentityManager::Observer {
void StartAccessTokenRequest(); void StartAccessTokenRequest();
// IdentityManager::Observer implementation. // IdentityManager::Observer implementation.
void OnPrimaryAccountSet( void OnPrimaryAccountChanged(const PrimaryAccountChangeEvent& event) override;
const CoreAccountInfo& primary_account_info) override;
void OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) override;
void OnRefreshTokenUpdatedForAccount( void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override; const CoreAccountInfo& account_info) override;
......
...@@ -133,25 +133,38 @@ TestIdentityManagerObserver::BatchChangeRecords() const { ...@@ -133,25 +133,38 @@ TestIdentityManagerObserver::BatchChangeRecords() const {
} }
// IdentityManager::Observer: // IdentityManager::Observer:
void TestIdentityManagerObserver::OnPrimaryAccountSet( void TestIdentityManagerObserver::OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) { const PrimaryAccountChangeEvent& event) {
primary_account_from_set_callback_ = primary_account_info; // 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_) if (on_primary_account_set_callback_)
std::move(on_primary_account_set_callback_).Run(); std::move(on_primary_account_set_callback_).Run();
} break;
case PrimaryAccountChangeEvent::Type::kCleared:
void TestIdentityManagerObserver::OnPrimaryAccountCleared( primary_account_from_cleared_callback_ =
const CoreAccountInfo& previous_primary_account_info) { event.GetPreviousState().primary_account;
primary_account_from_cleared_callback_ = previous_primary_account_info;
if (on_primary_account_cleared_callback_) if (on_primary_account_cleared_callback_)
std::move(on_primary_account_cleared_callback_).Run(); std::move(on_primary_account_cleared_callback_).Run();
} break;
case PrimaryAccountChangeEvent::Type::kNone:
void TestIdentityManagerObserver::OnUnconsentedPrimaryAccountChanged( break;
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::OnRefreshTokenUpdatedForAccount( void TestIdentityManagerObserver::OnRefreshTokenUpdatedForAccount(
......
...@@ -64,12 +64,8 @@ class TestIdentityManagerObserver : IdentityManager::Observer { ...@@ -64,12 +64,8 @@ class TestIdentityManagerObserver : IdentityManager::Observer {
private: private:
// IdentityManager::Observer: // IdentityManager::Observer:
void OnPrimaryAccountSet( void OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) override; const PrimaryAccountChangeEvent& event_details) override;
void OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) override;
void OnUnconsentedPrimaryAccountChanged(
const CoreAccountInfo& unconsented_primary_account_info) override;
void OnRefreshTokenUpdatedForAccount( void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override; const CoreAccountInfo& account_info) override;
void OnRefreshTokenRemovedForAccount( 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