Commit cb9b7020 authored by Sergio Villar Senin's avatar Sergio Villar Senin Committed by Commit Bot

AboutSigninInternals: remove the SigninManagerBase::Observer dependency

It can observe IdentityManager::Observer instead. This is a step
forward in the migration to IdentityManager API.

Most usages of SigninManager were also replaced by their equivalent
IdentityManager API. It's also observing
IdentityManager::DiagnosticsObserver from now on.

BUG: 809539

Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I9e7319a522f298298ab6a1a512bad73675050e70
Reviewed-on: https://chromium-review.googlesource.com/c/1276606Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Sergio Villar <svillar@igalia.com>
Cr-Commit-Position: refs/heads/master@{#609640}
parent 62757da8
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h" #include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h" #include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_manager_factory.h"
...@@ -54,6 +55,7 @@ KeyedService* AboutSigninInternalsFactory::BuildServiceInstanceFor( ...@@ -54,6 +55,7 @@ KeyedService* AboutSigninInternalsFactory::BuildServiceInstanceFor(
AboutSigninInternals* service = new AboutSigninInternals( AboutSigninInternals* service = new AboutSigninInternals(
ProfileOAuth2TokenServiceFactory::GetForProfile(profile), ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
AccountTrackerServiceFactory::GetForProfile(profile), AccountTrackerServiceFactory::GetForProfile(profile),
IdentityManagerFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile), SigninManagerFactory::GetForProfile(profile),
SigninErrorControllerFactory::GetForProfile(profile), SigninErrorControllerFactory::GetForProfile(profile),
GaiaCookieManagerServiceFactory::GetForProfile(profile), GaiaCookieManagerServiceFactory::GetForProfile(profile),
......
...@@ -139,6 +139,7 @@ class DiceResponseHandlerTest : public testing::Test, ...@@ -139,6 +139,7 @@ class DiceResponseHandlerTest : public testing::Test,
&cookie_service_), &cookie_service_),
about_signin_internals_(&token_service_, about_signin_internals_(&token_service_,
&account_tracker_service_, &account_tracker_service_,
identity_test_env_.identity_manager(),
&signin_manager_, &signin_manager_,
&signin_error_controller_, &signin_error_controller_,
&cookie_service_, &cookie_service_,
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "components/signin/core/browser/signin_switches.h" #include "components/signin/core/browser/signin_switches.h"
#include "google_apis/gaia/oauth2_token_service_delegate.h" #include "google_apis/gaia/oauth2_token_service_delegate.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace { namespace {
...@@ -188,12 +189,14 @@ std::string GetAccountConsistencyDescription( ...@@ -188,12 +189,14 @@ std::string GetAccountConsistencyDescription(
AboutSigninInternals::AboutSigninInternals( AboutSigninInternals::AboutSigninInternals(
ProfileOAuth2TokenService* token_service, ProfileOAuth2TokenService* token_service,
AccountTrackerService* account_tracker, AccountTrackerService* account_tracker,
identity::IdentityManager* identity_manager,
SigninManagerBase* signin_manager, SigninManagerBase* signin_manager,
SigninErrorController* signin_error_controller, SigninErrorController* signin_error_controller,
GaiaCookieManagerService* cookie_manager_service, GaiaCookieManagerService* cookie_manager_service,
signin::AccountConsistencyMethod account_consistency) signin::AccountConsistencyMethod account_consistency)
: token_service_(token_service), : token_service_(token_service),
account_tracker_(account_tracker), account_tracker_(account_tracker),
identity_manager_(identity_manager),
signin_manager_(signin_manager), signin_manager_(signin_manager),
client_(nullptr), client_(nullptr),
signin_error_controller_(signin_error_controller), signin_error_controller_(signin_error_controller),
...@@ -308,7 +311,8 @@ void AboutSigninInternals::Initialize(SigninClient* client) { ...@@ -308,7 +311,8 @@ void AboutSigninInternals::Initialize(SigninClient* client) {
RefreshSigninPrefs(); RefreshSigninPrefs();
signin_error_controller_->AddObserver(this); signin_error_controller_->AddObserver(this);
signin_manager_->AddObserver(this); identity_manager_->AddObserver(this);
identity_manager_->AddDiagnosticsObserver(this);
signin_manager_->AddSigninDiagnosticsObserver(this); signin_manager_->AddSigninDiagnosticsObserver(this);
token_service_->AddObserver(this); token_service_->AddObserver(this);
token_service_->AddDiagnosticsObserver(this); token_service_->AddDiagnosticsObserver(this);
...@@ -317,7 +321,8 @@ void AboutSigninInternals::Initialize(SigninClient* client) { ...@@ -317,7 +321,8 @@ void AboutSigninInternals::Initialize(SigninClient* client) {
void AboutSigninInternals::Shutdown() { void AboutSigninInternals::Shutdown() {
signin_error_controller_->RemoveObserver(this); signin_error_controller_->RemoveObserver(this);
signin_manager_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
identity_manager_->RemoveDiagnosticsObserver(this);
signin_manager_->RemoveSigninDiagnosticsObserver(this); signin_manager_->RemoveSigninDiagnosticsObserver(this);
token_service_->RemoveObserver(this); token_service_->RemoveObserver(this);
token_service_->RemoveDiagnosticsObserver(this); token_service_->RemoveDiagnosticsObserver(this);
...@@ -329,7 +334,7 @@ void AboutSigninInternals::NotifyObservers() { ...@@ -329,7 +334,7 @@ void AboutSigninInternals::NotifyObservers() {
return; return;
std::unique_ptr<base::DictionaryValue> signin_status_value = std::unique_ptr<base::DictionaryValue> signin_status_value =
signin_status_.ToValue(account_tracker_, signin_manager_, signin_status_.ToValue(account_tracker_, identity_manager_,
signin_error_controller_, token_service_, signin_error_controller_, token_service_,
cookie_manager_service_, client_, cookie_manager_service_, client_,
account_consistency_); account_consistency_);
...@@ -340,14 +345,14 @@ void AboutSigninInternals::NotifyObservers() { ...@@ -340,14 +345,14 @@ void AboutSigninInternals::NotifyObservers() {
std::unique_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() { std::unique_ptr<base::DictionaryValue> AboutSigninInternals::GetSigninStatus() {
return signin_status_.ToValue( return signin_status_.ToValue(
account_tracker_, signin_manager_, signin_error_controller_, account_tracker_, identity_manager_, signin_error_controller_,
token_service_, cookie_manager_service_, client_, account_consistency_); token_service_, cookie_manager_service_, client_, account_consistency_);
} }
void AboutSigninInternals::OnAccessTokenRequested( void AboutSigninInternals::OnAccessTokenRequested(
const std::string& account_id, const std::string& account_id,
const std::string& consumer_id, const std::string& consumer_id,
const OAuth2TokenService::ScopeSet& scopes) { const identity::ScopeSet& scopes) {
TokenInfo* token = signin_status_.FindToken(account_id, consumer_id, scopes); TokenInfo* token = signin_status_.FindToken(account_id, consumer_id, scopes);
if (token) { if (token) {
*token = TokenInfo(consumer_id, scopes); *token = TokenInfo(consumer_id, scopes);
...@@ -440,18 +445,18 @@ void AboutSigninInternals::OnErrorChanged() { ...@@ -440,18 +445,18 @@ void AboutSigninInternals::OnErrorChanged() {
NotifyObservers(); NotifyObservers();
} }
void AboutSigninInternals::GoogleSigninFailed( void AboutSigninInternals::OnPrimaryAccountSigninFailed(
const GoogleServiceAuthError& error) { const GoogleServiceAuthError& error) {
NotifyObservers(); NotifyObservers();
} }
void AboutSigninInternals::GoogleSigninSucceeded(const std::string& account_id, void AboutSigninInternals::OnPrimaryAccountSet(
const std::string& username) { const AccountInfo& primary_account_info) {
NotifyObservers(); NotifyObservers();
} }
void AboutSigninInternals::GoogleSignedOut(const std::string& account_id, void AboutSigninInternals::OnPrimaryAccountCleared(
const std::string& username) { const AccountInfo& primary_account_info) {
NotifyObservers(); NotifyObservers();
} }
...@@ -589,7 +594,7 @@ void AboutSigninInternals::SigninStatus::AddRefreshTokenEvent( ...@@ -589,7 +594,7 @@ void AboutSigninInternals::SigninStatus::AddRefreshTokenEvent(
std::unique_ptr<base::DictionaryValue> std::unique_ptr<base::DictionaryValue>
AboutSigninInternals::SigninStatus::ToValue( AboutSigninInternals::SigninStatus::ToValue(
AccountTrackerService* account_tracker, AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager, identity::IdentityManager* identity_manager,
SigninErrorController* signin_error_controller, SigninErrorController* signin_error_controller,
ProfileOAuth2TokenService* token_service, ProfileOAuth2TokenService* token_service,
GaiaCookieManagerService* cookie_manager_service, GaiaCookieManagerService* cookie_manager_service,
...@@ -605,15 +610,16 @@ AboutSigninInternals::SigninStatus::ToValue( ...@@ -605,15 +610,16 @@ AboutSigninInternals::SigninStatus::ToValue(
signin_client->GetProductVersion()); signin_client->GetProductVersion());
AddSectionEntry(basic_info, "Account Consistency", AddSectionEntry(basic_info, "Account Consistency",
GetAccountConsistencyDescription(account_consistency)); GetAccountConsistencyDescription(account_consistency));
AddSectionEntry(basic_info, "Signin Status", AddSectionEntry(
signin_manager->IsAuthenticated() ? "Signed In" : "Not Signed In"); basic_info, "Signin Status",
identity_manager->HasPrimaryAccount() ? "Signed In" : "Not Signed In");
OAuth2TokenServiceDelegate::LoadCredentialsState load_tokens_state = OAuth2TokenServiceDelegate::LoadCredentialsState load_tokens_state =
token_service->GetDelegate()->load_credentials_state(); token_service->GetDelegate()->load_credentials_state();
AddSectionEntry(basic_info, "TokenService Load Status", AddSectionEntry(basic_info, "TokenService Load Status",
TokenServiceLoadCredentialsStateToLabel(load_tokens_state)); TokenServiceLoadCredentialsStateToLabel(load_tokens_state));
if (signin_manager->IsAuthenticated()) { if (identity_manager->HasPrimaryAccount()) {
std::string account_id = signin_manager->GetAuthenticatedAccountId(); std::string account_id = identity_manager->GetPrimaryAccountId();
AddSectionEntry(basic_info, AddSectionEntry(basic_info,
SigninStatusFieldToLabel(signin_internals_util::ACCOUNT_ID), SigninStatusFieldToLabel(signin_internals_util::ACCOUNT_ID),
account_id); account_id);
...@@ -622,7 +628,7 @@ AboutSigninInternals::SigninStatus::ToValue( ...@@ -622,7 +628,7 @@ AboutSigninInternals::SigninStatus::ToValue(
account_tracker->GetAccountInfo(account_id).gaia); account_tracker->GetAccountInfo(account_id).gaia);
AddSectionEntry(basic_info, AddSectionEntry(basic_info,
SigninStatusFieldToLabel(signin_internals_util::USERNAME), SigninStatusFieldToLabel(signin_internals_util::USERNAME),
signin_manager->GetAuthenticatedAccountInfo().email); identity_manager->GetPrimaryAccountInfo().email);
if (signin_error_controller->HasError()) { if (signin_error_controller->HasError()) {
const std::string error_account_id = const std::string error_account_id =
signin_error_controller->error_account_id(); signin_error_controller->error_account_id();
......
...@@ -20,6 +20,11 @@ ...@@ -20,6 +20,11 @@
#include "components/signin/core/browser/signin_internals_util.h" #include "components/signin/core/browser/signin_internals_util.h"
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/oauth2_token_service.h" #include "google_apis/gaia/oauth2_token_service.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace identity {
class IdentityManager;
}
class AccountTrackerService; class AccountTrackerService;
class PrefRegistrySimple; class PrefRegistrySimple;
...@@ -38,8 +43,9 @@ class AboutSigninInternals ...@@ -38,8 +43,9 @@ class AboutSigninInternals
public OAuth2TokenService::Observer, public OAuth2TokenService::Observer,
public OAuth2TokenService::DiagnosticsObserver, public OAuth2TokenService::DiagnosticsObserver,
public GaiaCookieManagerService::Observer, public GaiaCookieManagerService::Observer,
SigninManagerBase::Observer, SigninErrorController::Observer,
SigninErrorController::Observer { identity::IdentityManager::Observer,
identity::IdentityManager::DiagnosticsObserver {
public: public:
class Observer { class Observer {
public: public:
...@@ -53,6 +59,7 @@ class AboutSigninInternals ...@@ -53,6 +59,7 @@ class AboutSigninInternals
AboutSigninInternals(ProfileOAuth2TokenService* token_service, AboutSigninInternals(ProfileOAuth2TokenService* token_service,
AccountTrackerService* account_tracker, AccountTrackerService* account_tracker,
identity::IdentityManager* identity_manager,
SigninManagerBase* signin_manager, SigninManagerBase* signin_manager,
SigninErrorController* signin_error_controller, SigninErrorController* signin_error_controller,
GaiaCookieManagerService* cookie_manager_service, GaiaCookieManagerService* cookie_manager_service,
...@@ -181,7 +188,7 @@ class AboutSigninInternals ...@@ -181,7 +188,7 @@ class AboutSigninInternals
// } // }
std::unique_ptr<base::DictionaryValue> ToValue( std::unique_ptr<base::DictionaryValue> ToValue(
AccountTrackerService* account_tracker, AccountTrackerService* account_tracker,
SigninManagerBase* signin_manager, identity::IdentityManager* identity_manager,
SigninErrorController* signin_error_controller, SigninErrorController* signin_error_controller,
ProfileOAuth2TokenService* token_service, ProfileOAuth2TokenService* token_service,
GaiaCookieManagerService* cookie_manager_service_, GaiaCookieManagerService* cookie_manager_service_,
...@@ -194,11 +201,12 @@ class AboutSigninInternals ...@@ -194,11 +201,12 @@ class AboutSigninInternals
const signin_internals_util::TimedSigninStatusField& field, const signin_internals_util::TimedSigninStatusField& field,
const std::string& value) override; const std::string& value) override;
// OAuth2TokenService::DiagnosticsObserver implementations. // IdentityMager::DiagnosticsObserver implementations.
void OnAccessTokenRequested( void OnAccessTokenRequested(const std::string& account_id,
const std::string& account_id,
const std::string& consumer_id, const std::string& consumer_id,
const OAuth2TokenService::ScopeSet& scopes) override; const identity::ScopeSet& scopes) override;
// OAuth2TokenService::DiagnosticsObserver implementations.
void OnFetchAccessTokenComplete(const std::string& account_id, void OnFetchAccessTokenComplete(const std::string& account_id,
const std::string& consumer_id, const std::string& consumer_id,
const OAuth2TokenService::ScopeSet& scopes, const OAuth2TokenService::ScopeSet& scopes,
...@@ -217,12 +225,12 @@ class AboutSigninInternals ...@@ -217,12 +225,12 @@ class AboutSigninInternals
void OnRefreshTokensLoaded() override; void OnRefreshTokensLoaded() override;
void OnEndBatchChanges() override; void OnEndBatchChanges() override;
// SigninManagerBase::Observer implementations. // IdentityManager::Observer implementations.
void GoogleSigninFailed(const GoogleServiceAuthError& error) override; void OnPrimaryAccountSigninFailed(
void GoogleSigninSucceeded(const std::string& account_id, const GoogleServiceAuthError& error) override;
const std::string& username) override; void OnPrimaryAccountSet(const AccountInfo& primary_account_info) override;
void GoogleSignedOut(const std::string& account_id, void OnPrimaryAccountCleared(
const std::string& username) override; const AccountInfo& primary_account_info) override;
void NotifyObservers(); void NotifyObservers();
...@@ -235,6 +243,9 @@ class AboutSigninInternals ...@@ -235,6 +243,9 @@ class AboutSigninInternals
// Weak pointer to the account tracker. // Weak pointer to the account tracker.
AccountTrackerService* account_tracker_; AccountTrackerService* account_tracker_;
// Weak pointer to the identity manager.
identity::IdentityManager* identity_manager_;
// Weak pointer to the signin manager. // Weak pointer to the signin manager.
SigninManagerBase* signin_manager_; SigninManagerBase* signin_manager_;
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/signin/account_tracker_service_factory.h" #include "ios/chrome/browser/signin/account_tracker_service_factory.h"
#include "ios/chrome/browser/signin/gaia_cookie_manager_service_factory.h" #include "ios/chrome/browser/signin/gaia_cookie_manager_service_factory.h"
#include "ios/chrome/browser/signin/identity_manager_factory.h"
#include "ios/chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "ios/chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "ios/chrome/browser/signin/signin_client_factory.h" #include "ios/chrome/browser/signin/signin_client_factory.h"
#include "ios/chrome/browser/signin/signin_error_controller_factory.h" #include "ios/chrome/browser/signin/signin_error_controller_factory.h"
...@@ -28,6 +29,7 @@ AboutSigninInternalsFactory::AboutSigninInternalsFactory() ...@@ -28,6 +29,7 @@ AboutSigninInternalsFactory::AboutSigninInternalsFactory()
DependsOn(AccountTrackerServiceFactory::GetInstance()); DependsOn(AccountTrackerServiceFactory::GetInstance());
DependsOn(GaiaCookieManagerServiceFactory::GetInstance()); DependsOn(GaiaCookieManagerServiceFactory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(SigninClientFactory::GetInstance()); DependsOn(SigninClientFactory::GetInstance());
DependsOn(SigninErrorControllerFactory::GetInstance()); DependsOn(SigninErrorControllerFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance()); DependsOn(SigninManagerFactory::GetInstance());
...@@ -56,6 +58,7 @@ AboutSigninInternalsFactory::BuildServiceInstanceFor( ...@@ -56,6 +58,7 @@ AboutSigninInternalsFactory::BuildServiceInstanceFor(
ProfileOAuth2TokenServiceFactory::GetForBrowserState( ProfileOAuth2TokenServiceFactory::GetForBrowserState(
chrome_browser_state), chrome_browser_state),
AccountTrackerServiceFactory::GetForBrowserState(chrome_browser_state), AccountTrackerServiceFactory::GetForBrowserState(chrome_browser_state),
IdentityManagerFactory::GetForBrowserState(chrome_browser_state),
SigninManagerFactory::GetForBrowserState(chrome_browser_state), SigninManagerFactory::GetForBrowserState(chrome_browser_state),
SigninErrorControllerFactory::GetForBrowserState(chrome_browser_state), SigninErrorControllerFactory::GetForBrowserState(chrome_browser_state),
GaiaCookieManagerServiceFactory::GetForBrowserState(chrome_browser_state), GaiaCookieManagerServiceFactory::GetForBrowserState(chrome_browser_state),
......
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