Commit fd8a3a1f authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Revert "Sync: Use IdentityManager instead of SigninManager"

This reverts commit aab57914.

Reason for revert: Depends on crrev.com/c/1025898 which was reverted

Original change's description:
> Sync: Use IdentityManager instead of SigninManager
> 
> This CL migrates ProfileSyncService to IdentityManager for getting
> info on the primary account. This includes switching from
> SigninManagerBase::Observer to IdentityManager::Observer.
> The only remaining use of SigninManager within PSS it to call
> SignOut() which isn't exposed by IdentityManager yet.
> 
> Bug: 825190
> Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
> Change-Id: Icf9398d63794cab03cb559adba5c767e18c31c0a
> Reviewed-on: https://chromium-review.googlesource.com/983914
> Commit-Queue: Marc Treib <treib@chromium.org>
> Reviewed-by: Mikel Astiz <mastiz@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#553973}

TBR=blundell@chromium.org,treib@chromium.org,mastiz@chromium.org

Change-Id: Ib40dbff0f1c8e5fba95cb9881681361abec5aeec
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 825190, 837201
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Reviewed-on: https://chromium-review.googlesource.com/1030372Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553997}
parent 3551fecc
...@@ -176,7 +176,9 @@ bool ProfileSyncServiceHarness::SetupSync(syncer::ModelTypeSet synced_datatypes, ...@@ -176,7 +176,9 @@ bool ProfileSyncServiceHarness::SetupSync(syncer::ModelTypeSet synced_datatypes,
IdentityManagerFactory::GetForProfile(profile_); IdentityManagerFactory::GetForProfile(profile_);
identity_manager->SetPrimaryAccountSynchronouslyForTests( identity_manager->SetPrimaryAccountSynchronouslyForTests(
gaia_id_, username_, GenerateFakeOAuth2RefreshTokenString()); gaia_id_, username_, GenerateFakeOAuth2RefreshTokenString());
service()->OnPrimaryAccountSet(identity_manager->GetPrimaryAccountInfo()); std::string account_id =
identity_manager->GetPrimaryAccountInfo().account_id;
service()->GoogleSigninSucceeded(account_id, username_);
} else { } else {
LOG(ERROR) << "Unsupported profile signin type."; LOG(ERROR) << "Unsupported profile signin type.";
} }
...@@ -279,7 +281,8 @@ bool ProfileSyncServiceHarness::RestartSyncService() { ...@@ -279,7 +281,8 @@ bool ProfileSyncServiceHarness::RestartSyncService() {
void ProfileSyncServiceHarness::SignoutSyncService() { void ProfileSyncServiceHarness::SignoutSyncService() {
DCHECK(!username_.empty()); DCHECK(!username_.empty());
service()->OnPrimaryAccountCleared(service()->GetAuthenticatedAccountInfo()); service()->GoogleSignedOut(
service()->GetAuthenticatedAccountInfo().account_id, username_);
} }
bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion( bool ProfileSyncServiceHarness::AwaitMutualSyncCycleCompletion(
......
...@@ -345,13 +345,13 @@ void ProfileSyncService::RegisterAuthNotifications() { ...@@ -345,13 +345,13 @@ void ProfileSyncService::RegisterAuthNotifications() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
oauth2_token_service_->AddObserver(this); oauth2_token_service_->AddObserver(this);
if (signin_) if (signin_)
signin_->GetIdentityManager()->AddObserver(this); signin_->GetSigninManager()->AddObserver(this);
} }
void ProfileSyncService::UnregisterAuthNotifications() { void ProfileSyncService::UnregisterAuthNotifications() {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (signin_) if (signin_)
signin_->GetIdentityManager()->RemoveObserver(this); signin_->GetSigninManager()->RemoveObserver(this);
if (oauth2_token_service_) if (oauth2_token_service_)
oauth2_token_service_->RemoveObserver(this); oauth2_token_service_->RemoveObserver(this);
} }
...@@ -1921,8 +1921,8 @@ void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) { ...@@ -1921,8 +1921,8 @@ void ProfileSyncService::OnSyncManagedPrefChange(bool is_sync_managed) {
} }
} }
void ProfileSyncService::OnPrimaryAccountSet( void ProfileSyncService::GoogleSigninSucceeded(const std::string& account_id,
const AccountInfo& primary_account_info) { const std::string& username) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
if (!IsEngineInitialized() || if (!IsEngineInitialized() ||
GetAuthError().state() != GoogleServiceAuthError::NONE) { GetAuthError().state() != GoogleServiceAuthError::NONE) {
...@@ -1930,14 +1930,12 @@ void ProfileSyncService::OnPrimaryAccountSet( ...@@ -1930,14 +1930,12 @@ void ProfileSyncService::OnPrimaryAccountSet(
is_auth_in_progress_ = true; is_auth_in_progress_ = true;
} }
if (oauth2_token_service_->RefreshTokenIsAvailable( if (oauth2_token_service_->RefreshTokenIsAvailable(account_id))
primary_account_info.account_id)) { OnRefreshTokenAvailable(account_id);
OnRefreshTokenAvailable(primary_account_info.account_id);
}
} }
void ProfileSyncService::OnPrimaryAccountCleared( void ProfileSyncService::GoogleSignedOut(const std::string& account_id,
const AccountInfo& previous_primary_account_info) { const std::string& username) {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
sync_disabled_by_admin_ = false; sync_disabled_by_admin_ = false;
UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT, UMA_HISTOGRAM_ENUMERATION("Sync.StopSource", syncer::SIGN_OUT,
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/sync/base/experiments.h" #include "components/sync/base/experiments.h"
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/base/sync_prefs.h" #include "components/sync/base/sync_prefs.h"
...@@ -43,7 +44,6 @@ ...@@ -43,7 +44,6 @@
#include "google_apis/gaia/google_service_auth_error.h" #include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_token_service.h" #include "google_apis/gaia/oauth2_token_service.h"
#include "net/base/backoff_entry.h" #include "net/base/backoff_entry.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "url/gurl.h" #include "url/gurl.h"
class ProfileOAuth2TokenService; class ProfileOAuth2TokenService;
...@@ -168,7 +168,7 @@ class ProfileSyncService : public syncer::SyncServiceBase, ...@@ -168,7 +168,7 @@ class ProfileSyncService : public syncer::SyncServiceBase,
public syncer::DataTypeManagerObserver, public syncer::DataTypeManagerObserver,
public syncer::UnrecoverableErrorHandler, public syncer::UnrecoverableErrorHandler,
public OAuth2TokenService::Observer, public OAuth2TokenService::Observer,
public identity::IdentityManager::Observer, public SigninManagerBase::Observer,
public GaiaCookieManagerService::Observer { public GaiaCookieManagerService::Observer {
public: public:
using Status = syncer::SyncStatus; using Status = syncer::SyncStatus;
...@@ -381,10 +381,11 @@ class ProfileSyncService : public syncer::SyncServiceBase, ...@@ -381,10 +381,11 @@ class ProfileSyncService : public syncer::SyncServiceBase,
bool IsPassphraseRequired() const override; bool IsPassphraseRequired() const override;
syncer::ModelTypeSet GetEncryptedDataTypes() const override; syncer::ModelTypeSet GetEncryptedDataTypes() const override;
// identity::IdentityManager::Observer implementation. // SigninManagerBase::Observer implementation.
void OnPrimaryAccountSet(const AccountInfo& primary_account_info) override; void GoogleSigninSucceeded(const std::string& account_id,
void OnPrimaryAccountCleared( const std::string& username) override;
const AccountInfo& previous_primary_account_info) override; void GoogleSignedOut(const std::string& account_id,
const std::string& username) override;
// GaiaCookieManagerService::Observer implementation. // GaiaCookieManagerService::Observer implementation.
void OnGaiaAccountsInCookieUpdated( void OnGaiaAccountsInCookieUpdated(
......
...@@ -560,8 +560,6 @@ TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) { ...@@ -560,8 +560,6 @@ TEST_F(ProfileSyncServiceTest, EnableSyncAndSignOut) {
signin_manager()->SignOut(signin_metrics::SIGNOUT_TEST, signin_manager()->SignOut(signin_metrics::SIGNOUT_TEST,
signin_metrics::SignoutDelete::IGNORE_METRIC); signin_metrics::SignoutDelete::IGNORE_METRIC);
// Wait for PSS to be notified that the primary account has gone away.
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(service()->IsSyncActive()); EXPECT_FALSE(service()->IsSyncActive());
} }
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
...@@ -729,8 +727,8 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorReturned) { ...@@ -729,8 +727,8 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorReturned) {
std::string primary_account_id = std::string primary_account_id =
signin_manager()->GetAuthenticatedAccountId(); signin_manager()->GetAuthenticatedAccountId();
auth_service()->LoadCredentials(primary_account_id); auth_service()->LoadCredentials(primary_account_id);
// Wait for ProfileSyncService to be notified of the loaded credentials and // Wait for PSS to be notified of the loaded credentials and send an access
// send an access token request. // token request.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
auth_service()->IssueAllTokensForAccount(primary_account_id, "access token", auth_service()->IssueAllTokensForAccount(primary_account_id, "access token",
base::Time::Max()); base::Time::Max());
...@@ -740,7 +738,7 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorReturned) { ...@@ -740,7 +738,7 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorReturned) {
// Emulate Chrome receiving a new, invalid LST. This happens when the user // Emulate Chrome receiving a new, invalid LST. This happens when the user
// signs out of the content area. // signs out of the content area.
auth_service()->UpdateCredentials(primary_account_id, "not a valid token"); auth_service()->UpdateCredentials(primary_account_id, "not a valid token");
// Again, wait for ProfileSyncService to be notified. // Again, wait for PSS to be notified.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
auth_service()->IssueErrorForAllPendingRequests( auth_service()->IssueErrorForAllPendingRequests(
GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
...@@ -774,8 +772,8 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorClearsOnNewToken) { ...@@ -774,8 +772,8 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorClearsOnNewToken) {
std::string primary_account_id = std::string primary_account_id =
signin_manager()->GetAuthenticatedAccountId(); signin_manager()->GetAuthenticatedAccountId();
auth_service()->LoadCredentials(primary_account_id); auth_service()->LoadCredentials(primary_account_id);
// Wait for ProfileSyncService to be notified of the loaded credentials and // Wait for PSS to be notified of the loaded credentials and send an access
// send an access token request. // token request.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
auth_service()->IssueAllTokensForAccount(primary_account_id, "access token", auth_service()->IssueAllTokensForAccount(primary_account_id, "access token",
base::Time::Max()); base::Time::Max());
...@@ -785,8 +783,8 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorClearsOnNewToken) { ...@@ -785,8 +783,8 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorClearsOnNewToken) {
// Emulate Chrome receiving a new, invalid LST. This happens when the user // Emulate Chrome receiving a new, invalid LST. This happens when the user
// signs out of the content area. // signs out of the content area.
auth_service()->UpdateCredentials(primary_account_id, "not a valid token"); auth_service()->UpdateCredentials(primary_account_id, "not a valid token");
// Wait for ProfileSyncService to be notified of the changed credentials and // Wait for PSS to be notified of the changed credentials and send a new
// send a new access token request. // access token request.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
auth_service()->IssueErrorForAllPendingRequests( auth_service()->IssueErrorForAllPendingRequests(
GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS)); GoogleServiceAuthError(GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS));
...@@ -797,7 +795,7 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorClearsOnNewToken) { ...@@ -797,7 +795,7 @@ TEST_F(ProfileSyncServiceTest, CredentialErrorClearsOnNewToken) {
// Now emulate Chrome receiving a new, valid LST. // Now emulate Chrome receiving a new, valid LST.
auth_service()->UpdateCredentials(primary_account_id, "totally valid token"); auth_service()->UpdateCredentials(primary_account_id, "totally valid token");
// Again, wait for ProfileSyncService to be notified. // Again, wait for PSS to be notified.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
auth_service()->IssueTokenForAllPendingRequests( auth_service()->IssueTokenForAllPendingRequests(
"this one works", base::Time::Now() + base::TimeDelta::FromDays(10)); "this one works", base::Time::Now() + base::TimeDelta::FromDays(10));
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "components/sync/driver/signin_manager_wrapper.h" #include "components/sync/driver/signin_manager_wrapper.h"
#include "services/identity/public/cpp/identity_manager.h" #include "components/signin/core/browser/signin_manager_base.h"
SigninManagerWrapper::SigninManagerWrapper( SigninManagerWrapper::SigninManagerWrapper(
identity::IdentityManager* identity_manager, identity::IdentityManager* identity_manager,
...@@ -22,9 +22,9 @@ SigninManagerBase* SigninManagerWrapper::GetSigninManager() { ...@@ -22,9 +22,9 @@ SigninManagerBase* SigninManagerWrapper::GetSigninManager() {
} }
std::string SigninManagerWrapper::GetEffectiveUsername() const { std::string SigninManagerWrapper::GetEffectiveUsername() const {
return identity_manager_->GetPrimaryAccountInfo().email; return signin_manager_->GetAuthenticatedAccountInfo().email;
} }
std::string SigninManagerWrapper::GetAccountIdToUse() const { std::string SigninManagerWrapper::GetAccountIdToUse() const {
return identity_manager_->GetPrimaryAccountInfo().account_id; return signin_manager_->GetAuthenticatedAccountId();
} }
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
#include "base/syslog_logging.h" #include "base/syslog_logging.h"
#include "components/invalidation/public/invalidation_service.h" #include "components/invalidation/public/invalidation_service.h"
#include "components/signin/core/browser/account_info.h" #include "components/signin/core/browser/account_info.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/sync/base/report_unrecoverable_error.h" #include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/device_info/local_device_info_provider.h" #include "components/sync/device_info/local_device_info_provider.h"
#include "components/sync/driver/sync_driver_switches.h" #include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/engine/engine_components_factory_impl.h" #include "components/sync/engine/engine_components_factory_impl.h"
#include "components/sync/engine/polling_constants.h" #include "components/sync/engine/polling_constants.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace syncer { namespace syncer {
...@@ -86,7 +86,7 @@ bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const { ...@@ -86,7 +86,7 @@ bool SyncServiceBase::HasObserver(const SyncServiceObserver* observer) const {
AccountInfo SyncServiceBase::GetAuthenticatedAccountInfo() const { AccountInfo SyncServiceBase::GetAuthenticatedAccountInfo() const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
return signin_ ? signin_->GetIdentityManager()->GetPrimaryAccountInfo() return signin_ ? signin_->GetSigninManager()->GetAuthenticatedAccountInfo()
: AccountInfo(); : AccountInfo();
} }
......
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