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,
void ResetInternalState();
// IdentityManager::Observer implementation.
void OnPrimaryAccountSet(const CoreAccountInfo& account_info) override;
void OnPrimaryAccountCleared(
const CoreAccountInfo& previous_account_info) override;
void OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event) override;
void OnAccountsInCookieUpdated(
const signin::AccountsInCookieJarInfo& accounts_in_cookie_jar_info,
const GoogleServiceAuthError& error) override;
......
......@@ -556,14 +556,20 @@ void AccountConsistencyService::OnBrowsingDataRemoved() {
identity_manager_->GetAccountsCookieMutator()->ForceTriggerOnCookieChange();
}
void AccountConsistencyService::OnPrimaryAccountSet(
const CoreAccountInfo& account_info) {
AddChromeConnectedCookies();
}
void AccountConsistencyService::OnPrimaryAccountCleared(
const CoreAccountInfo& previous_account_info) {
RemoveAllChromeConnectedCookies(base::OnceClosure());
void AccountConsistencyService::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event) {
switch (event.GetEventTypeFor(signin::ConsentLevel::kSync)) {
case signin::PrimaryAccountChangeEvent::Type::kSet:
AddChromeConnectedCookies();
break;
case signin::PrimaryAccountChangeEvent::Type::kCleared:
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(
......
......@@ -47,10 +47,8 @@ class IdentityManagerObserverBridge : public IdentityManager::Observer {
~IdentityManagerObserverBridge() override;
// IdentityManager::Observer.
void OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) override;
void OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) override;
void OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event) override;
void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override;
void OnRefreshTokenRemovedForAccount(
......
......@@ -21,17 +21,24 @@ IdentityManagerObserverBridge::~IdentityManagerObserverBridge() {
identity_manager_->RemoveObserver(this);
}
void IdentityManagerObserverBridge::OnPrimaryAccountSet(
const CoreAccountInfo& primary_account_info) {
if ([delegate_ respondsToSelector:@selector(onPrimaryAccountSet:)]) {
[delegate_ onPrimaryAccountSet:primary_account_info];
}
}
void IdentityManagerObserverBridge::OnPrimaryAccountCleared(
const CoreAccountInfo& previous_primary_account_info) {
if ([delegate_ respondsToSelector:@selector(onPrimaryAccountCleared:)]) {
[delegate_ onPrimaryAccountCleared:previous_primary_account_info];
void IdentityManagerObserverBridge::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event) {
switch (event.GetEventTypeFor(signin::ConsentLevel::kSync)) {
case signin::PrimaryAccountChangeEvent::Type::kSet:
if ([delegate_ respondsToSelector:@selector(onPrimaryAccountSet:)]) {
[delegate_ onPrimaryAccountSet:event.GetCurrentState().primary_account];
}
break;
case signin::PrimaryAccountChangeEvent::Type::kCleared:
if ([delegate_ respondsToSelector:@selector(onPrimaryAccountCleared:)]) {
[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