Commit db6f3cec authored by Mihai Sardarescu's avatar Mihai Sardarescu Committed by Chromium LUCI CQ

Convert components/signin/ios/* to OnPrimaryAccountChanged()

Methods OnPrimaryAccountSet/Cleared() are deprecated, so this CL changes
the components/signin/ios/* to override the method
OnPrimaryAccountChanged().

Bug: 1158855
Change-Id: Ie61a2fe12aed8cd863bfcc20064f84903a599ee1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2624607Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842716}
parent 489ea26b
...@@ -113,9 +113,8 @@ class AccountConsistencyService : public KeyedService, ...@@ -113,9 +113,8 @@ class AccountConsistencyService : public KeyedService,
void ResetInternalState(); void ResetInternalState();
// IdentityManager::Observer implementation. // IdentityManager::Observer implementation.
void OnPrimaryAccountSet(const CoreAccountInfo& account_info) override; void OnPrimaryAccountChanged(
void OnPrimaryAccountCleared( const signin::PrimaryAccountChangeEvent& event) override;
const CoreAccountInfo& previous_account_info) override;
void OnAccountsInCookieUpdated( void OnAccountsInCookieUpdated(
const signin::AccountsInCookieJarInfo& accounts_in_cookie_jar_info, const signin::AccountsInCookieJarInfo& accounts_in_cookie_jar_info,
const GoogleServiceAuthError& error) override; const GoogleServiceAuthError& error) override;
......
...@@ -556,14 +556,20 @@ void AccountConsistencyService::OnBrowsingDataRemoved() { ...@@ -556,14 +556,20 @@ void AccountConsistencyService::OnBrowsingDataRemoved() {
identity_manager_->GetAccountsCookieMutator()->ForceTriggerOnCookieChange(); identity_manager_->GetAccountsCookieMutator()->ForceTriggerOnCookieChange();
} }
void AccountConsistencyService::OnPrimaryAccountSet( void AccountConsistencyService::OnPrimaryAccountChanged(
const CoreAccountInfo& account_info) { const signin::PrimaryAccountChangeEvent& event) {
AddChromeConnectedCookies(); switch (event.GetEventTypeFor(signin::ConsentLevel::kSync)) {
} case signin::PrimaryAccountChangeEvent::Type::kSet:
AddChromeConnectedCookies();
void AccountConsistencyService::OnPrimaryAccountCleared( break;
const CoreAccountInfo& previous_account_info) { case signin::PrimaryAccountChangeEvent::Type::kCleared:
RemoveAllChromeConnectedCookies(base::OnceClosure()); RemoveAllChromeConnectedCookies(base::OnceClosure());
break;
case signin::PrimaryAccountChangeEvent::Type::kNone:
NOTREACHED() << "ConsentLevel::kNotRequired is not yet supported on iOS. "
"This code needs to be updated when it is supported.";
break;
}
} }
void AccountConsistencyService::OnAccountsInCookieUpdated( void AccountConsistencyService::OnAccountsInCookieUpdated(
......
...@@ -47,10 +47,8 @@ class IdentityManagerObserverBridge : public IdentityManager::Observer { ...@@ -47,10 +47,8 @@ class IdentityManagerObserverBridge : public IdentityManager::Observer {
~IdentityManagerObserverBridge() override; ~IdentityManagerObserverBridge() override;
// IdentityManager::Observer. // IdentityManager::Observer.
void OnPrimaryAccountSet( void OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) override; const signin::PrimaryAccountChangeEvent& event) override;
void OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) override;
void OnRefreshTokenUpdatedForAccount( void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override; const CoreAccountInfo& account_info) override;
void OnRefreshTokenRemovedForAccount( void OnRefreshTokenRemovedForAccount(
......
...@@ -21,17 +21,24 @@ IdentityManagerObserverBridge::~IdentityManagerObserverBridge() { ...@@ -21,17 +21,24 @@ IdentityManagerObserverBridge::~IdentityManagerObserverBridge() {
identity_manager_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
} }
void IdentityManagerObserverBridge::OnPrimaryAccountSet( void IdentityManagerObserverBridge::OnPrimaryAccountChanged(
const CoreAccountInfo& primary_account_info) { const signin::PrimaryAccountChangeEvent& event) {
if ([delegate_ respondsToSelector:@selector(onPrimaryAccountSet:)]) { switch (event.GetEventTypeFor(signin::ConsentLevel::kSync)) {
[delegate_ onPrimaryAccountSet:primary_account_info]; case signin::PrimaryAccountChangeEvent::Type::kSet:
} if ([delegate_ respondsToSelector:@selector(onPrimaryAccountSet:)]) {
} [delegate_ onPrimaryAccountSet:event.GetCurrentState().primary_account];
}
void IdentityManagerObserverBridge::OnPrimaryAccountCleared( break;
const CoreAccountInfo& previous_primary_account_info) { case signin::PrimaryAccountChangeEvent::Type::kCleared:
if ([delegate_ respondsToSelector:@selector(onPrimaryAccountCleared:)]) { if ([delegate_ respondsToSelector:@selector(onPrimaryAccountCleared:)]) {
[delegate_ onPrimaryAccountCleared:previous_primary_account_info]; [delegate_
onPrimaryAccountCleared:event.GetPreviousState().primary_account];
}
break;
case signin::PrimaryAccountChangeEvent::Type::kNone:
NOTREACHED() << "ConsentLevel::kNotRequired is not yet supported on iOS. "
"This code needs to be updated when it is supported.";
break;
} }
} }
......
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