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

Convert c/b/policy/cloud/ to OnPrimaryAccountChanged()

Methods OnPrimaryAccountSet/Cleared() are deprecated, so this CL changes
the chrome/browser/password_manager/* to override the method
OnPrimaryAccountChanged().

Bug: 1163126
Change-Id: I5d3439b94ef7214debf58439c46078b70dbfc305
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611245Reviewed-by: default avatarJulian Pastarmov <pastarmovj@chromium.org>
Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
Auto-Submit: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#840601}
parent 5b92d466
...@@ -98,13 +98,21 @@ void UserPolicySigninService::CallPolicyRegistrationCallback( ...@@ -98,13 +98,21 @@ void UserPolicySigninService::CallPolicyRegistrationCallback(
std::move(callback).Run(client->dm_token(), client->client_id()); std::move(callback).Run(client->dm_token(), client->client_id());
} }
void UserPolicySigninService::OnPrimaryAccountSet( void UserPolicySigninService::OnPrimaryAccountChanged(
const CoreAccountInfo& account_info) { const signin::PrimaryAccountChangeEvent& event) {
if (!identity_manager()->HasAccountWithRefreshToken(account_info.account_id)) UserPolicySigninServiceBase::OnPrimaryAccountChanged(event);
if (event.GetEventTypeFor(signin::ConsentLevel::kSync) !=
signin::PrimaryAccountChangeEvent::Type::kSet) {
return; return;
}
// ProfileOAuth2TokenService now has a refresh token for the primary account DCHECK(identity_manager()->HasPrimaryAccount());
// so initialize the UserCloudPolicyManager. if (!identity_manager()->HasPrimaryAccountWithRefreshToken())
return;
// IdentityManager has a refresh token for the primary account, so initialize
// the UserCloudPolicyManager.
TryInitializeForSignedInUser(); TryInitializeForSignedInUser();
} }
......
...@@ -51,7 +51,8 @@ class UserPolicySigninService : public UserPolicySigninServiceBase { ...@@ -51,7 +51,8 @@ class UserPolicySigninService : public UserPolicySigninServiceBase {
// signin::IdentityManager::Observer implementation: // signin::IdentityManager::Observer implementation:
// UserPolicySigninServiceBase is already an observer of IdentityManager. // UserPolicySigninServiceBase is already an observer of IdentityManager.
void OnPrimaryAccountSet(const CoreAccountInfo& account_info) override; void OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) override;
void OnRefreshTokenUpdatedForAccount( void OnRefreshTokenUpdatedForAccount(
const CoreAccountInfo& account_info) override; const CoreAccountInfo& account_info) override;
......
...@@ -73,9 +73,13 @@ void UserPolicySigninServiceBase::FetchPolicyForSignedInUser( ...@@ -73,9 +73,13 @@ void UserPolicySigninServiceBase::FetchPolicyForSignedInUser(
manager->core()->service()->RefreshPolicy(std::move(callback)); manager->core()->service()->RefreshPolicy(std::move(callback));
} }
void UserPolicySigninServiceBase::OnPrimaryAccountCleared( void UserPolicySigninServiceBase::OnPrimaryAccountChanged(
const CoreAccountInfo& previous_primary_account_info) { const signin::PrimaryAccountChangeEvent& event) {
ShutdownUserCloudPolicyManager(); if (event.GetEventTypeFor(signin::ConsentLevel::kSync) ==
signin::PrimaryAccountChangeEvent::Type::kCleared) {
DCHECK(!identity_manager_->HasPrimaryAccount());
ShutdownUserCloudPolicyManager();
}
} }
void UserPolicySigninServiceBase::Observe( void UserPolicySigninServiceBase::Observe(
......
...@@ -85,8 +85,8 @@ class UserPolicySigninServiceBase : public KeyedService, ...@@ -85,8 +85,8 @@ class UserPolicySigninServiceBase : public KeyedService,
PolicyFetchCallback callback); PolicyFetchCallback callback);
// signin::IdentityManager::Observer implementation: // signin::IdentityManager::Observer implementation:
void OnPrimaryAccountCleared( void OnPrimaryAccountChanged(
const CoreAccountInfo& previous_primary_account_info) override; const signin::PrimaryAccountChangeEvent& event_details) override;
// content::NotificationObserver implementation: // content::NotificationObserver implementation:
void Observe(int type, void Observe(int type,
......
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