Commit 2b8d7478 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[GCM] Port AccountTracker to use IdentityManager

This CL completes the conversion of GCM's production code to talk
to IdentityManager rather than legacy signin classes by converting
AccountTracker. The GCMAccountTracker unittest remains to be fully
converted away from the legacy signin classes; this will be done in a
followup CL.

TBR=rohitrao@chromium.org, rockot@chromium.org

Bug: 809923
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: I1513b33850f52b532d83ac389a78464b68ed1a45
Reviewed-on: https://chromium-review.googlesource.com/1148200Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580101}
parent 71ccff62
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
#include "chrome/browser/gcm/gcm_profile_service_factory.h" #include "chrome/browser/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -46,7 +44,6 @@ ...@@ -46,7 +44,6 @@
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/gcm_driver.h"
#include "components/gcm_driver/gcm_profile_service.h" #include "components/gcm_driver/gcm_profile_service.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
...@@ -216,8 +213,6 @@ class ExtensionGCMAppHandlerTest : public testing::Test { ...@@ -216,8 +213,6 @@ class ExtensionGCMAppHandlerTest : public testing::Test {
chrome::GetChannel(), chrome::GetChannel(),
gcm::GetProductCategoryForSubtypes(profile->GetPrefs()), gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
IdentityManagerFactory::GetForProfile(profile), IdentityManagerFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
base::WrapUnique(new gcm::FakeGCMClientFactory(ui_thread, io_thread)), base::WrapUnique(new gcm::FakeGCMClientFactory(ui_thread, io_thread)),
ui_thread, io_thread, blocking_task_runner); ui_thread, io_thread, blocking_task_runner);
} }
......
...@@ -11,12 +11,9 @@ ...@@ -11,12 +11,9 @@
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "components/gcm_driver/gcm_profile_service.h" #include "components/gcm_driver/gcm_profile_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h" #include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/offline_pages/buildflags/buildflags.h" #include "components/offline_pages/buildflags/buildflags.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
...@@ -59,8 +56,6 @@ GCMProfileServiceFactory::GCMProfileServiceFactory() ...@@ -59,8 +56,6 @@ GCMProfileServiceFactory::GCMProfileServiceFactory()
"GCMProfileService", "GCMProfileService",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
DependsOn(IdentityManagerFactory::GetInstance()); DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
#if BUILDFLAG(ENABLE_OFFLINE_PAGES) #if BUILDFLAG(ENABLE_OFFLINE_PAGES)
DependsOn(offline_pages::PrefetchServiceFactory::GetInstance()); DependsOn(offline_pages::PrefetchServiceFactory::GetInstance());
#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) #endif // BUILDFLAG(ENABLE_OFFLINE_PAGES)
...@@ -90,8 +85,6 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor( ...@@ -90,8 +85,6 @@ KeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
chrome::GetChannel(), chrome::GetChannel(),
gcm::GetProductCategoryForSubtypes(profile->GetPrefs()), gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
IdentityManagerFactory::GetForProfile(profile), IdentityManagerFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
std::unique_ptr<GCMClientFactory>(new GCMClientFactory), std::unique_ptr<GCMClientFactory>(new GCMClientFactory),
content::BrowserThread::GetTaskRunnerForThread( content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI), content::BrowserThread::UI),
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include "chrome/browser/gcm/gcm_product_util.h" #include "chrome/browser/gcm/gcm_product_util.h"
#include "chrome/browser/gcm/gcm_profile_service_factory.h" #include "chrome/browser/gcm/gcm_profile_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/gcm_driver/gcm_profile_service.h" #include "components/gcm_driver/gcm_profile_service.h"
...@@ -31,7 +29,6 @@ ...@@ -31,7 +29,6 @@
#include "components/gcm_driver/gcm_client_factory.h" #include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_driver.h" #include "components/gcm_driver/gcm_driver.h"
#include "components/pref_registry/pref_registry_syncable.h" #include "components/pref_registry/pref_registry_syncable.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
...@@ -59,8 +56,6 @@ std::unique_ptr<KeyedService> BuildGCMProfileService( ...@@ -59,8 +56,6 @@ std::unique_ptr<KeyedService> BuildGCMProfileService(
chrome::GetChannel(), chrome::GetChannel(),
gcm::GetProductCategoryForSubtypes(profile->GetPrefs()), gcm::GetProductCategoryForSubtypes(profile->GetPrefs()),
IdentityManagerFactory::GetForProfile(profile), IdentityManagerFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile),
ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
std::unique_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory( std::unique_ptr<gcm::GCMClientFactory>(new gcm::FakeGCMClientFactory(
content::BrowserThread::GetTaskRunnerForThread( content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI), content::BrowserThread::UI),
......
...@@ -57,7 +57,6 @@ static_library("gcm_driver") { ...@@ -57,7 +57,6 @@ static_library("gcm_driver") {
"//components/os_crypt", "//components/os_crypt",
"//components/pref_registry", "//components/pref_registry",
"//components/prefs", "//components/prefs",
"//components/signin/core/browser",
"//components/sync", "//components/sync",
"//components/version_info", "//components/version_info",
"//google_apis", "//google_apis",
......
...@@ -8,21 +8,17 @@ ...@@ -8,21 +8,17 @@
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/trace_event/trace_event.h" #include "base/trace_event/trace_event.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
namespace gcm { namespace gcm {
AccountTracker::AccountTracker( AccountTracker::AccountTracker(
SigninManagerBase* signin_manager, identity::IdentityManager* identity_manager,
ProfileOAuth2TokenService* token_service,
net::URLRequestContextGetter* request_context_getter) net::URLRequestContextGetter* request_context_getter)
: signin_manager_(signin_manager), : identity_manager_(identity_manager),
token_service_(token_service),
request_context_getter_(request_context_getter), request_context_getter_(request_context_getter),
shutdown_called_(false) { shutdown_called_(false) {
signin_manager_->AddObserver(this); identity_manager_->AddObserver(this);
token_service_->AddObserver(this);
} }
AccountTracker::~AccountTracker() { AccountTracker::~AccountTracker() {
...@@ -32,8 +28,7 @@ AccountTracker::~AccountTracker() { ...@@ -32,8 +28,7 @@ AccountTracker::~AccountTracker() {
void AccountTracker::Shutdown() { void AccountTracker::Shutdown() {
shutdown_called_ = true; shutdown_called_ = true;
user_info_requests_.clear(); user_info_requests_.clear();
token_service_->RemoveObserver(this); identity_manager_->RemoveObserver(this);
signin_manager_->RemoveObserver(this);
} }
bool AccountTracker::IsAllUserInfoFetched() const { bool AccountTracker::IsAllUserInfoFetched() const {
...@@ -50,7 +45,7 @@ void AccountTracker::RemoveObserver(Observer* observer) { ...@@ -50,7 +45,7 @@ void AccountTracker::RemoveObserver(Observer* observer) {
std::vector<AccountIds> AccountTracker::GetAccounts() const { std::vector<AccountIds> AccountTracker::GetAccounts() const {
const std::string active_account_id = const std::string active_account_id =
signin_manager_->GetAuthenticatedAccountId(); identity_manager_->GetPrimaryAccountInfo().account_id;
std::vector<AccountIds> accounts; std::vector<AccountIds> accounts;
for (std::map<std::string, AccountState>::const_iterator it = for (std::map<std::string, AccountState>::const_iterator it =
...@@ -72,43 +67,46 @@ std::vector<AccountIds> AccountTracker::GetAccounts() const { ...@@ -72,43 +67,46 @@ std::vector<AccountIds> AccountTracker::GetAccounts() const {
return accounts; return accounts;
} }
void AccountTracker::OnRefreshTokenAvailable(const std::string& account_id) { void AccountTracker::OnRefreshTokenUpdatedForAccount(
TRACE_EVENT1("identity", "AccountTracker::OnRefreshTokenAvailable", const AccountInfo& account_info,
"account_key", account_id); bool is_valid) {
TRACE_EVENT1("identity", "AccountTracker::OnRefreshTokenUpdatedForAccount",
"account_id", account_info.account_id);
// Ignore refresh tokens if there is no active account ID at all. // Ignore refresh tokens if there is no active account ID at all.
if (signin_manager_->GetAuthenticatedAccountId().empty()) if (!identity_manager_->HasPrimaryAccount())
return; return;
DVLOG(1) << "AVAILABLE " << account_id; DVLOG(1) << "AVAILABLE " << account_info.account_id;
UpdateSignInState(account_id, /*is_signed_in=*/true); UpdateSignInState(account_info.account_id, /*is_signed_in=*/true);
} }
void AccountTracker::OnRefreshTokenRevoked(const std::string& account_id) { void AccountTracker::OnRefreshTokenRemovedForAccount(
TRACE_EVENT1("identity", "AccountTracker::OnRefreshTokenRevoked", const AccountInfo& account_info) {
"account_key", account_id); TRACE_EVENT1("identity", "AccountTracker::OnRefreshTokenRemovedForAccount",
"account_id", account_info.account_id);
DVLOG(1) << "REVOKED " << account_id; DVLOG(1) << "REVOKED " << account_info.account_id;
UpdateSignInState(account_id, /*is_signed_in=*/false); UpdateSignInState(account_info.account_id, /*is_signed_in=*/false);
} }
void AccountTracker::GoogleSigninSucceeded(const std::string& account_id, void AccountTracker::OnPrimaryAccountSet(
const std::string& username) { const AccountInfo& primary_account_info) {
TRACE_EVENT0("identity", "AccountTracker::GoogleSigninSucceeded"); TRACE_EVENT0("identity", "AccountTracker::OnPrimaryAccountSet");
std::vector<std::string> accounts = token_service_->GetAccounts(); std::vector<AccountInfo> accounts =
identity_manager_->GetAccountsWithRefreshTokens();
DVLOG(1) << "LOGIN " << accounts.size() << " accounts available."; DVLOG(1) << "LOGIN " << accounts.size() << " accounts available.";
for (std::vector<std::string>::const_iterator it = accounts.begin(); for (const AccountInfo& account_info : accounts) {
it != accounts.end(); ++it) { UpdateSignInState(account_info.account_id, /*is_signed_in=*/true);
UpdateSignInState(*it, /*is_signed_in=*/true);
} }
} }
void AccountTracker::GoogleSignedOut(const std::string& account_id, void AccountTracker::OnPrimaryAccountCleared(
const std::string& username) { const AccountInfo& previous_primary_account_info) {
TRACE_EVENT0("identity", "AccountTracker::GoogleSignedOut"); TRACE_EVENT0("identity", "AccountTracker::OnPrimaryAccountCleared");
DVLOG(1) << "LOGOUT"; DVLOG(1) << "LOGOUT";
StopTrackingAllAccounts(); StopTrackingAllAccounts();
} }
...@@ -171,7 +169,7 @@ void AccountTracker::StartFetchingUserInfo(const std::string& account_key) { ...@@ -171,7 +169,7 @@ void AccountTracker::StartFetchingUserInfo(const std::string& account_key) {
DVLOG(1) << "StartFetching " << account_key; DVLOG(1) << "StartFetching " << account_key;
AccountIdFetcher* fetcher = new AccountIdFetcher( AccountIdFetcher* fetcher = new AccountIdFetcher(
token_service_, request_context_getter_.get(), this, account_key); identity_manager_, request_context_getter_.get(), this, account_key);
user_info_requests_[account_key] = base::WrapUnique(fetcher); user_info_requests_[account_key] = base::WrapUnique(fetcher);
fetcher->Start(); fetcher->Start();
} }
...@@ -206,12 +204,11 @@ void AccountTracker::DeleteFetcher(AccountIdFetcher* fetcher) { ...@@ -206,12 +204,11 @@ void AccountTracker::DeleteFetcher(AccountIdFetcher* fetcher) {
} }
AccountIdFetcher::AccountIdFetcher( AccountIdFetcher::AccountIdFetcher(
OAuth2TokenService* token_service, identity::IdentityManager* identity_manager,
net::URLRequestContextGetter* request_context_getter, net::URLRequestContextGetter* request_context_getter,
AccountTracker* tracker, AccountTracker* tracker,
const std::string& account_key) const std::string& account_key)
: OAuth2TokenService::Consumer("gaia_account_tracker"), : identity_manager_(identity_manager),
token_service_(token_service),
request_context_getter_(request_context_getter), request_context_getter_(request_context_getter),
tracker_(tracker), tracker_(tracker),
account_key_(account_key) { account_key_(account_key) {
...@@ -226,33 +223,34 @@ AccountIdFetcher::~AccountIdFetcher() { ...@@ -226,33 +223,34 @@ AccountIdFetcher::~AccountIdFetcher() {
void AccountIdFetcher::Start() { void AccountIdFetcher::Start() {
OAuth2TokenService::ScopeSet scopes; OAuth2TokenService::ScopeSet scopes;
scopes.insert("https://www.googleapis.com/auth/userinfo.profile"); scopes.insert("https://www.googleapis.com/auth/userinfo.profile");
login_token_request_ = access_token_fetcher_ = identity_manager_->CreateAccessTokenFetcherForAccount(
token_service_->StartRequest(account_key_, scopes, this); account_key_, "gaia_account_tracker", scopes,
base::BindOnce(&AccountIdFetcher::AccessTokenFetched,
base::Unretained(this)));
} }
void AccountIdFetcher::OnGetTokenSuccess( void AccountIdFetcher::AccessTokenFetched(
const OAuth2TokenService::Request* request, GoogleServiceAuthError error,
const std::string& access_token, identity::AccessTokenInfo access_token_info) {
const base::Time& expiration_time) { access_token_fetcher_.reset();
if (error != GoogleServiceAuthError::AuthErrorNone()) {
TRACE_EVENT_ASYNC_STEP_PAST1("identity", "AccountIdFetcher", this,
"AccessTokenFetched",
"google_service_auth_error", error.ToString());
LOG(ERROR) << "AccessTokenFetched error: " << error.ToString();
tracker_->OnUserInfoFetchFailure(this);
return;
}
TRACE_EVENT_ASYNC_STEP_PAST0("identity", "AccountIdFetcher", this, TRACE_EVENT_ASYNC_STEP_PAST0("identity", "AccountIdFetcher", this,
"OnGetTokenSuccess"); "AccessTokenFetched");
DCHECK_EQ(request, login_token_request_.get());
gaia_oauth_client_.reset(new gaia::GaiaOAuthClient(request_context_getter_)); gaia_oauth_client_.reset(new gaia::GaiaOAuthClient(request_context_getter_));
const int kMaxGetUserIdRetries = 3; const int kMaxGetUserIdRetries = 3;
gaia_oauth_client_->GetUserId(access_token, kMaxGetUserIdRetries, this); gaia_oauth_client_->GetUserId(access_token_info.token, kMaxGetUserIdRetries,
} this);
void AccountIdFetcher::OnGetTokenFailure(
const OAuth2TokenService::Request* request,
const GoogleServiceAuthError& error) {
TRACE_EVENT_ASYNC_STEP_PAST1("identity", "AccountIdFetcher", this,
"OnGetTokenFailure", "google_service_auth_error",
error.ToString());
LOG(ERROR) << "OnGetTokenFailure: " << error.ToString();
DCHECK_EQ(request, login_token_request_.get());
tracker_->OnUserInfoFetchFailure(this);
} }
void AccountIdFetcher::OnGetUserIdResponse(const std::string& gaia_id) { void AccountIdFetcher::OnGetUserIdResponse(const std::string& gaia_id) {
......
...@@ -11,12 +11,11 @@ ...@@ -11,12 +11,11 @@
#include <vector> #include <vector>
#include "base/observer_list.h" #include "base/observer_list.h"
#include "components/signin/core/browser/signin_manager.h"
#include "google_apis/gaia/gaia_oauth_client.h" #include "google_apis/gaia/gaia_oauth_client.h"
#include "google_apis/gaia/oauth2_token_service.h" #include "services/identity/public/cpp/access_token_fetcher.h"
#include "services/identity/public/cpp/identity_manager.h"
class GoogleServiceAuthError; class GoogleServiceAuthError;
class ProfileOAuth2TokenService;
namespace net { namespace net {
class URLRequestContextGetter; class URLRequestContextGetter;
...@@ -41,11 +40,9 @@ class AccountIdFetcher; ...@@ -41,11 +40,9 @@ class AccountIdFetcher;
// 2. Add/Remove and SignIn/SignOut pairs are always generated in order. // 2. Add/Remove and SignIn/SignOut pairs are always generated in order.
// 3. SignIn follows Add, and there will be a SignOut between SignIn & Remove. // 3. SignIn follows Add, and there will be a SignOut between SignIn & Remove.
// 4. If there is no primary account, there are no other accounts. // 4. If there is no primary account, there are no other accounts.
class AccountTracker : public OAuth2TokenService::Observer, class AccountTracker : public identity::IdentityManager::Observer {
public SigninManagerBase::Observer {
public: public:
AccountTracker(SigninManagerBase* signin_manager, AccountTracker(identity::IdentityManager* identity_manager,
ProfileOAuth2TokenService* token_service,
net::URLRequestContextGetter* request_context_getter); net::URLRequestContextGetter* request_context_getter);
~AccountTracker() override; ~AccountTracker() override;
...@@ -77,20 +74,19 @@ class AccountTracker : public OAuth2TokenService::Observer, ...@@ -77,20 +74,19 @@ class AccountTracker : public OAuth2TokenService::Observer,
bool is_signed_in; bool is_signed_in;
}; };
// OAuth2TokenService::Observer implementation. // identity::IdentityManager::Observer implementation.
void OnRefreshTokenAvailable(const std::string& account_key) override; void OnPrimaryAccountSet(const AccountInfo& primary_account_info) override;
void OnRefreshTokenRevoked(const std::string& account_key) override; void OnPrimaryAccountCleared(
const AccountInfo& previous_primary_account_info) override;
void OnRefreshTokenUpdatedForAccount(const AccountInfo& account_info,
bool is_valid) override;
void OnRefreshTokenRemovedForAccount(
const AccountInfo& account_info) override;
void OnUserInfoFetchSuccess(AccountIdFetcher* fetcher, void OnUserInfoFetchSuccess(AccountIdFetcher* fetcher,
const std::string& gaia_id); const std::string& gaia_id);
void OnUserInfoFetchFailure(AccountIdFetcher* fetcher); void OnUserInfoFetchFailure(AccountIdFetcher* fetcher);
// SigninManagerBase::Observer implementation.
void GoogleSigninSucceeded(const std::string& account_id,
const std::string& username) override;
void GoogleSignedOut(const std::string& account_id,
const std::string& username) override;
void NotifySignInChanged(const AccountState& account); void NotifySignInChanged(const AccountState& account);
void UpdateSignInState(const std::string& account_key, bool is_signed_in); void UpdateSignInState(const std::string& account_key, bool is_signed_in);
...@@ -106,8 +102,7 @@ class AccountTracker : public OAuth2TokenService::Observer, ...@@ -106,8 +102,7 @@ class AccountTracker : public OAuth2TokenService::Observer,
void StartFetchingUserInfo(const std::string& account_key); void StartFetchingUserInfo(const std::string& account_key);
void DeleteFetcher(AccountIdFetcher* fetcher); void DeleteFetcher(AccountIdFetcher* fetcher);
SigninManagerBase* signin_manager_; identity::IdentityManager* identity_manager_;
ProfileOAuth2TokenService* token_service_;
scoped_refptr<net::URLRequestContextGetter> request_context_getter_; scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
std::map<std::string, std::unique_ptr<AccountIdFetcher>> user_info_requests_; std::map<std::string, std::unique_ptr<AccountIdFetcher>> user_info_requests_;
std::map<std::string, AccountState> accounts_; std::map<std::string, AccountState> accounts_;
...@@ -115,10 +110,9 @@ class AccountTracker : public OAuth2TokenService::Observer, ...@@ -115,10 +110,9 @@ class AccountTracker : public OAuth2TokenService::Observer,
bool shutdown_called_; bool shutdown_called_;
}; };
class AccountIdFetcher : public OAuth2TokenService::Consumer, class AccountIdFetcher : public gaia::GaiaOAuthClient::Delegate {
public gaia::GaiaOAuthClient::Delegate {
public: public:
AccountIdFetcher(OAuth2TokenService* token_service, AccountIdFetcher(identity::IdentityManager* identity_manager,
net::URLRequestContextGetter* request_context_getter, net::URLRequestContextGetter* request_context_getter,
AccountTracker* tracker, AccountTracker* tracker,
const std::string& account_key); const std::string& account_key);
...@@ -128,12 +122,8 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer, ...@@ -128,12 +122,8 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer,
void Start(); void Start();
// OAuth2TokenService::Consumer implementation. void AccessTokenFetched(GoogleServiceAuthError error,
void OnGetTokenSuccess(const OAuth2TokenService::Request* request, identity::AccessTokenInfo access_token_info);
const std::string& access_token,
const base::Time& expiration_time) override;
void OnGetTokenFailure(const OAuth2TokenService::Request* request,
const GoogleServiceAuthError& error) override;
// gaia::GaiaOAuthClient::Delegate implementation. // gaia::GaiaOAuthClient::Delegate implementation.
void OnGetUserIdResponse(const std::string& gaia_id) override; void OnGetUserIdResponse(const std::string& gaia_id) override;
...@@ -141,12 +131,12 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer, ...@@ -141,12 +131,12 @@ class AccountIdFetcher : public OAuth2TokenService::Consumer,
void OnNetworkError(int response_code) override; void OnNetworkError(int response_code) override;
private: private:
OAuth2TokenService* token_service_; identity::IdentityManager* identity_manager_;
net::URLRequestContextGetter* request_context_getter_; net::URLRequestContextGetter* request_context_getter_;
AccountTracker* tracker_; AccountTracker* tracker_;
const std::string account_key_; const std::string account_key_;
std::unique_ptr<OAuth2TokenService::Request> login_token_request_; std::unique_ptr<identity::AccessTokenFetcher> access_token_fetcher_;
std::unique_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; std::unique_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_;
}; };
......
...@@ -10,29 +10,17 @@ ...@@ -10,29 +10,17 @@
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_profile_oauth2_token_service.h"
#include "components/signin/core/browser/fake_signin_manager.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "google_apis/gaia/fake_oauth2_token_service.h"
#include "google_apis/gaia/gaia_oauth_client.h" #include "google_apis/gaia/gaia_oauth_client.h"
#include "net/http/http_status_code.h" #include "net/http/http_status_code.h"
#include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/test_url_fetcher_factory.h"
#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request_test_util.h" #include "net/url_request/url_request_test_util.h"
#include "services/identity/public/cpp/identity_test_environment.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace { namespace {
#if defined(OS_CHROMEOS)
using SigninManagerForTest = FakeSigninManagerBase;
#else
using SigninManagerForTest = FakeSigninManager;
#endif // OS_CHROMEOS
const char kPrimaryAccountEmail[] = "primary_account@example.com"; const char kPrimaryAccountEmail[] = "primary_account@example.com";
const char kPrimaryAccountGaiaId[] = "primary_account";
enum TrackingEventType { SIGN_IN, SIGN_OUT }; enum TrackingEventType { SIGN_IN, SIGN_OUT };
...@@ -253,25 +241,8 @@ class AccountTrackerTest : public testing::Test { ...@@ -253,25 +241,8 @@ class AccountTrackerTest : public testing::Test {
~AccountTrackerTest() override {} ~AccountTrackerTest() override {}
void SetUp() override { void SetUp() override {
fake_oauth2_token_service_.reset(new FakeProfileOAuth2TokenService());
test_signin_client_.reset(new TestSigninClient(&pref_service_));
#if defined(OS_CHROMEOS)
fake_signin_manager_.reset(new SigninManagerForTest(
test_signin_client_.get(), &account_tracker_service_));
#else
fake_signin_manager_.reset(new SigninManagerForTest(
test_signin_client_.get(), fake_oauth2_token_service_.get(),
&account_tracker_service_, nullptr));
#endif
AccountTrackerService::RegisterPrefs(pref_service_.registry());
SigninManagerBase::RegisterProfilePrefs(pref_service_.registry());
SigninManagerBase::RegisterPrefs(pref_service_.registry());
account_tracker_service_.Initialize(test_signin_client_.get());
account_tracker_.reset(new AccountTracker( account_tracker_.reset(new AccountTracker(
fake_signin_manager_.get(), fake_oauth2_token_service_.get(), identity_test_env_.identity_manager(),
new net::TestURLRequestContextGetter(message_loop_.task_runner()))); new net::TestURLRequestContextGetter(message_loop_.task_runner())));
account_tracker_->AddObserver(&observer_); account_tracker_->AddObserver(&observer_);
} }
...@@ -287,68 +258,48 @@ class AccountTrackerTest : public testing::Test { ...@@ -287,68 +258,48 @@ class AccountTrackerTest : public testing::Test {
// Helpers to pass fake events to the tracker. // Helpers to pass fake events to the tracker.
// Sets the primary account info but carries no guarantee of firing the // Sets the primary account info. Returns the account ID of the
// callback that signin occurred (see NotifyLogin() below if exercising a
// true signin flow in a non-ChromeOS context). Returns the account ID of the
// newly-set account. // newly-set account.
std::string SetActiveAccount(const std::string& gaia_id, // NOTE: On ChromeOS, the login callback is never fired in production (since
const std::string& email) { // the underlying GoogleSigninSucceeded callback is never sent). Tests that
#if defined(OS_CHROMEOS) // exercise functionality dependent on that callback firing are not relevant
fake_signin_manager_->SignIn(email); // on ChromeOS and should simply not run on that platform.
#else std::string SetActiveAccount(const std::string& email) {
fake_signin_manager_->SignIn(gaia_id, email, "" /* password */); return identity_test_env_.SetPrimaryAccount(email).account_id;
#endif
return fake_signin_manager_->GetAuthenticatedAccountId();
} }
// NOTE: On ChromeOS, the login callback is never fired in production (since the // Helpers that go through a logout flow.
// underlying GoogleSigninSucceeded callback is never sent). Tests that // NOTE: On ChromeOS, the logout callback is never fired in production (since
// exercise functionality dependent on that callback firing are not relevant // the underlying GoogleSignedOut callback is never sent). Tests that exercise
// on ChromeOS and should simply not run on that platform. // functionality dependent on that callback firing are not relevant on ChromeOS
// and should simply not run on that platform.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
// Sets the primary account info and fires the callback that signin occurred.
// Returns the account ID of the newly-set account.
std::string NotifyLogin(const std::string& gaia_id,
const std::string& email) {
fake_signin_manager_->SignIn(gaia_id, email, "" /* password */);
return fake_signin_manager_->GetAuthenticatedAccountId();
}
void NotifyLogoutOfPrimaryAccountOnly() { void NotifyLogoutOfPrimaryAccountOnly() {
fake_signin_manager_->SignOutAndKeepAllAccounts( identity_test_env_.ClearPrimaryAccount(
signin_metrics::SIGNOUT_TEST, identity::ClearPrimaryAccountPolicy::KEEP_ALL_ACCOUNTS);
signin_metrics::SignoutDelete::IGNORE_METRIC);
} }
void NotifyLogoutOfAllAccounts() { void NotifyLogoutOfAllAccounts() {
fake_signin_manager_->SignOutAndRemoveAllAccounts( identity_test_env_.ClearPrimaryAccount(
signin_metrics::SIGNOUT_TEST, identity::ClearPrimaryAccountPolicy::REMOVE_ALL_ACCOUNTS);
signin_metrics::SignoutDelete::IGNORE_METRIC);
} }
#endif #endif
std::string AddAccountWithToken(const std::string& gaia, std::string AddAccountWithToken(const std::string& email) {
const std::string& email) { return identity_test_env_.MakeAccountAvailable(email).account_id;
std::string account_id =
account_tracker_service_.SeedAccountInfo(gaia, email);
fake_oauth2_token_service_->UpdateCredentials(account_id,
"fake_refresh_token");
return account_id;
} }
void NotifyTokenAvailable(const std::string& account_id) { void NotifyTokenAvailable(const std::string& account_id) {
fake_oauth2_token_service_->UpdateCredentials(account_id, identity_test_env_.SetRefreshTokenForAccount(account_id);
"fake_refresh_token");
} }
void NotifyTokenRevoked(const std::string& account_id) { void NotifyTokenRevoked(const std::string& account_id) {
fake_oauth2_token_service_->RevokeCredentials(account_id); identity_test_env_.RemoveRefreshTokenForAccount(account_id);
} }
// Helpers to fake access token and user info fetching // Helpers to fake access token and user info fetching
void IssueAccessToken(const std::string& account_id) { void IssueAccessToken(const std::string& account_id) {
fake_oauth2_token_service_->IssueAllTokensForAccount( identity_test_env_.WaitForAccessTokenRequestIfNecessaryAndRespondWithToken(
account_id, "access_token-" + account_id, base::Time::Max()); account_id, "access_token-" + account_id, base::Time::Max());
} }
...@@ -366,8 +317,7 @@ class AccountTrackerTest : public testing::Test { ...@@ -366,8 +317,7 @@ class AccountTrackerTest : public testing::Test {
std::string SetupPrimaryLogin() { std::string SetupPrimaryLogin() {
// Initial setup for tests that start with a signed in profile. // Initial setup for tests that start with a signed in profile.
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
observer()->Clear(); observer()->Clear();
...@@ -378,11 +328,7 @@ class AccountTrackerTest : public testing::Test { ...@@ -378,11 +328,7 @@ class AccountTrackerTest : public testing::Test {
private: private:
base::MessageLoopForIO message_loop_; // net:: stuff needs IO message loop. base::MessageLoopForIO message_loop_; // net:: stuff needs IO message loop.
net::TestURLFetcherFactory test_fetcher_factory_; net::TestURLFetcherFactory test_fetcher_factory_;
sync_preferences::TestingPrefServiceSyncable pref_service_; identity::IdentityTestEnvironment identity_test_env_;
AccountTrackerService account_tracker_service_;
std::unique_ptr<TestSigninClient> test_signin_client_;
std::unique_ptr<SigninManagerForTest> fake_signin_manager_;
std::unique_ptr<FakeProfileOAuth2TokenService> fake_oauth2_token_service_;
std::unique_ptr<AccountTracker> account_tracker_; std::unique_ptr<AccountTracker> account_tracker_;
AccountTrackerObserver observer_; AccountTrackerObserver observer_;
...@@ -417,8 +363,8 @@ void AccountTrackerTest::ReturnOAuthUrlFetchFailure( ...@@ -417,8 +363,8 @@ void AccountTrackerTest::ReturnOAuthUrlFetchFailure(
// Primary tests just involve the Active account // Primary tests just involve the Active account
TEST_F(AccountTrackerTest, PrimaryNoEventsBeforeLogin) { TEST_F(AccountTrackerTest, PrimaryNoEventsBeforeLogin) {
NotifyTokenAvailable("dummy_account_id"); std::string account_id = AddAccountWithToken("me@dummy.com");
NotifyTokenRevoked("dummy_account_id"); NotifyTokenRevoked(account_id);
// Logout is not possible on ChromeOS. // Logout is not possible on ChromeOS.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
...@@ -429,8 +375,7 @@ TEST_F(AccountTrackerTest, PrimaryNoEventsBeforeLogin) { ...@@ -429,8 +375,7 @@ TEST_F(AccountTrackerTest, PrimaryNoEventsBeforeLogin) {
} }
TEST_F(AccountTrackerTest, PrimaryLoginThenTokenAvailable) { TEST_F(AccountTrackerTest, PrimaryLoginThenTokenAvailable) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
...@@ -441,32 +386,29 @@ TEST_F(AccountTrackerTest, PrimaryLoginThenTokenAvailable) { ...@@ -441,32 +386,29 @@ TEST_F(AccountTrackerTest, PrimaryLoginThenTokenAvailable) {
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, PrimaryTokenAvailableThenLogin) { TEST_F(AccountTrackerTest, PrimaryTokenAvailableThenLogin) {
AddAccountWithToken(kPrimaryAccountGaiaId, kPrimaryAccountEmail); AddAccountWithToken(kPrimaryAccountEmail);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyLogin(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
EXPECT_TRUE( EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_IN, primary_account_id))); observer()->CheckEvents(TrackingEvent(SIGN_IN, primary_account_id)));
} }
TEST_F(AccountTrackerTest, PrimaryTokenAvailableAndRevokedThenLogin) { TEST_F(AccountTrackerTest, PrimaryTokenAvailableAndRevokedThenLogin) {
std::string primary_account_id = std::string primary_account_id = AddAccountWithToken(kPrimaryAccountEmail);
AddAccountWithToken(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
NotifyTokenRevoked(primary_account_id); NotifyTokenRevoked(primary_account_id);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
NotifyLogin(kPrimaryAccountGaiaId, kPrimaryAccountEmail); SetActiveAccount(kPrimaryAccountEmail);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
} }
#endif #endif
TEST_F(AccountTrackerTest, PrimaryRevoke) { TEST_F(AccountTrackerTest, PrimaryRevoke) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
observer()->Clear(); observer()->Clear();
...@@ -476,21 +418,22 @@ TEST_F(AccountTrackerTest, PrimaryRevoke) { ...@@ -476,21 +418,22 @@ TEST_F(AccountTrackerTest, PrimaryRevoke) {
observer()->CheckEvents(TrackingEvent(SIGN_OUT, primary_account_id))); observer()->CheckEvents(TrackingEvent(SIGN_OUT, primary_account_id)));
} }
// This test uses a logout flow, not possible on ChromeOS.
#if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, PrimaryRevokeThenLogin) { TEST_F(AccountTrackerTest, PrimaryRevokeThenLogin) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
NotifyTokenRevoked(primary_account_id); NotifyLogoutOfAllAccounts();
observer()->Clear(); observer()->Clear();
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail); SetActiveAccount(kPrimaryAccountEmail);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
} }
#endif
TEST_F(AccountTrackerTest, PrimaryRevokeThenTokenAvailable) { TEST_F(AccountTrackerTest, PrimaryRevokeThenTokenAvailable) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
NotifyTokenRevoked(primary_account_id); NotifyTokenRevoked(primary_account_id);
...@@ -504,8 +447,7 @@ TEST_F(AccountTrackerTest, PrimaryRevokeThenTokenAvailable) { ...@@ -504,8 +447,7 @@ TEST_F(AccountTrackerTest, PrimaryRevokeThenTokenAvailable) {
// These tests exercise true login/logout, which are not possible on ChromeOS. // These tests exercise true login/logout, which are not possible on ChromeOS.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, PrimaryLogoutThenRevoke) { TEST_F(AccountTrackerTest, PrimaryLogoutThenRevoke) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyLogin(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
observer()->Clear(); observer()->Clear();
...@@ -519,14 +461,13 @@ TEST_F(AccountTrackerTest, PrimaryLogoutThenRevoke) { ...@@ -519,14 +461,13 @@ TEST_F(AccountTrackerTest, PrimaryLogoutThenRevoke) {
} }
TEST_F(AccountTrackerTest, PrimaryLogoutFetchCancelAvailable) { TEST_F(AccountTrackerTest, PrimaryLogoutFetchCancelAvailable) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyLogin(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
// TokenAvailable kicks off a fetch. Logout without satisfying it. // TokenAvailable kicks off a fetch. Logout without satisfying it.
NotifyLogoutOfAllAccounts(); NotifyLogoutOfAllAccounts();
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail); SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
EXPECT_TRUE( EXPECT_TRUE(
...@@ -539,7 +480,7 @@ TEST_F(AccountTrackerTest, PrimaryLogoutFetchCancelAvailable) { ...@@ -539,7 +480,7 @@ TEST_F(AccountTrackerTest, PrimaryLogoutFetchCancelAvailable) {
TEST_F(AccountTrackerTest, Available) { TEST_F(AccountTrackerTest, Available) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
ReturnOAuthUrlFetchSuccess(account_id); ReturnOAuthUrlFetchSuccess(account_id);
...@@ -549,7 +490,7 @@ TEST_F(AccountTrackerTest, Available) { ...@@ -549,7 +490,7 @@ TEST_F(AccountTrackerTest, Available) {
TEST_F(AccountTrackerTest, AvailableRevokeAvailable) { TEST_F(AccountTrackerTest, AvailableRevokeAvailable) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id); ReturnOAuthUrlFetchSuccess(account_id);
NotifyTokenRevoked(account_id); NotifyTokenRevoked(account_id);
EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, account_id), EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, account_id),
...@@ -562,7 +503,7 @@ TEST_F(AccountTrackerTest, AvailableRevokeAvailable) { ...@@ -562,7 +503,7 @@ TEST_F(AccountTrackerTest, AvailableRevokeAvailable) {
TEST_F(AccountTrackerTest, AvailableRevokeAvailableWithPendingFetch) { TEST_F(AccountTrackerTest, AvailableRevokeAvailableWithPendingFetch) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
NotifyTokenRevoked(account_id); NotifyTokenRevoked(account_id);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
...@@ -574,7 +515,7 @@ TEST_F(AccountTrackerTest, AvailableRevokeAvailableWithPendingFetch) { ...@@ -574,7 +515,7 @@ TEST_F(AccountTrackerTest, AvailableRevokeAvailableWithPendingFetch) {
TEST_F(AccountTrackerTest, AvailableRevokeRevoke) { TEST_F(AccountTrackerTest, AvailableRevokeRevoke) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id); ReturnOAuthUrlFetchSuccess(account_id);
NotifyTokenRevoked(account_id); NotifyTokenRevoked(account_id);
EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, account_id), EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, account_id),
...@@ -587,7 +528,7 @@ TEST_F(AccountTrackerTest, AvailableRevokeRevoke) { ...@@ -587,7 +528,7 @@ TEST_F(AccountTrackerTest, AvailableRevokeRevoke) {
TEST_F(AccountTrackerTest, AvailableAvailable) { TEST_F(AccountTrackerTest, AvailableAvailable) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id); ReturnOAuthUrlFetchSuccess(account_id);
EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, account_id))); EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, account_id)));
...@@ -598,13 +539,12 @@ TEST_F(AccountTrackerTest, AvailableAvailable) { ...@@ -598,13 +539,12 @@ TEST_F(AccountTrackerTest, AvailableAvailable) {
TEST_F(AccountTrackerTest, TwoAccounts) { TEST_F(AccountTrackerTest, TwoAccounts) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string alpha_account_id = std::string alpha_account_id = AddAccountWithToken("alpha@example.com");
AddAccountWithToken("alpha", "alpha@example.com");
ReturnOAuthUrlFetchSuccess(alpha_account_id); ReturnOAuthUrlFetchSuccess(alpha_account_id);
EXPECT_TRUE( EXPECT_TRUE(
observer()->CheckEvents(TrackingEvent(SIGN_IN, alpha_account_id))); observer()->CheckEvents(TrackingEvent(SIGN_IN, alpha_account_id)));
std::string beta_account_id = AddAccountWithToken("beta", "beta@example.com"); std::string beta_account_id = AddAccountWithToken("beta@example.com");
ReturnOAuthUrlFetchSuccess(beta_account_id); ReturnOAuthUrlFetchSuccess(beta_account_id);
EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, beta_account_id))); EXPECT_TRUE(observer()->CheckEvents(TrackingEvent(SIGN_IN, beta_account_id)));
...@@ -620,7 +560,7 @@ TEST_F(AccountTrackerTest, TwoAccounts) { ...@@ -620,7 +560,7 @@ TEST_F(AccountTrackerTest, TwoAccounts) {
TEST_F(AccountTrackerTest, AvailableTokenFetchFailAvailable) { TEST_F(AccountTrackerTest, AvailableTokenFetchFailAvailable) {
SetupPrimaryLogin(); SetupPrimaryLogin();
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchFailure(account_id); ReturnOAuthUrlFetchFailure(account_id);
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
...@@ -634,10 +574,9 @@ TEST_F(AccountTrackerTest, AvailableTokenFetchFailAvailable) { ...@@ -634,10 +574,9 @@ TEST_F(AccountTrackerTest, AvailableTokenFetchFailAvailable) {
TEST_F(AccountTrackerTest, MultiSignOutSignIn) { TEST_F(AccountTrackerTest, MultiSignOutSignIn) {
std::string primary_account_id = SetupPrimaryLogin(); std::string primary_account_id = SetupPrimaryLogin();
std::string alpha_account_id = std::string alpha_account_id = AddAccountWithToken("alpha@example.com");
AddAccountWithToken("alpha", "alpha@example.com");
ReturnOAuthUrlFetchSuccess(alpha_account_id); ReturnOAuthUrlFetchSuccess(alpha_account_id);
std::string beta_account_id = AddAccountWithToken("beta", "beta@example.com"); std::string beta_account_id = AddAccountWithToken("beta@example.com");
ReturnOAuthUrlFetchSuccess(beta_account_id); ReturnOAuthUrlFetchSuccess(beta_account_id);
observer()->SortEventsByUser(); observer()->SortEventsByUser();
...@@ -655,12 +594,11 @@ TEST_F(AccountTrackerTest, MultiSignOutSignIn) { ...@@ -655,12 +594,11 @@ TEST_F(AccountTrackerTest, MultiSignOutSignIn) {
// No events fire at all while profile is signed out. // No events fire at all while profile is signed out.
NotifyTokenRevoked(alpha_account_id); NotifyTokenRevoked(alpha_account_id);
std::string gamma_account_id = std::string gamma_account_id = AddAccountWithToken("gamma@example.com");
AddAccountWithToken("gamma", "gamma@example.com");
EXPECT_TRUE(observer()->CheckEvents()); EXPECT_TRUE(observer()->CheckEvents());
// Signing the profile in again will resume tracking all accounts. // Signing the profile in again will resume tracking all accounts.
NotifyLogin(kPrimaryAccountGaiaId, kPrimaryAccountEmail); SetActiveAccount(kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(beta_account_id); ReturnOAuthUrlFetchSuccess(beta_account_id);
ReturnOAuthUrlFetchSuccess(gamma_account_id); ReturnOAuthUrlFetchSuccess(gamma_account_id);
...@@ -685,10 +623,10 @@ TEST_F(AccountTrackerTest, MultiSignOutSignIn) { ...@@ -685,10 +623,10 @@ TEST_F(AccountTrackerTest, MultiSignOutSignIn) {
// Primary/non-primary interactions // Primary/non-primary interactions
TEST_F(AccountTrackerTest, MultiNoEventsBeforeLogin) { TEST_F(AccountTrackerTest, MultiNoEventsBeforeLogin) {
NotifyTokenAvailable("dummy_account_id"); std::string account_id1 = AddAccountWithToken("user@example.com");
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id2 = AddAccountWithToken("user2@example.com");
NotifyTokenRevoked(account_id); NotifyTokenRevoked(account_id2);
NotifyTokenRevoked("dummy_account_id"); NotifyTokenRevoked(account_id1);
// Logout is not possible on ChromeOS. // Logout is not possible on ChromeOS.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
...@@ -701,11 +639,10 @@ TEST_F(AccountTrackerTest, MultiNoEventsBeforeLogin) { ...@@ -701,11 +639,10 @@ TEST_F(AccountTrackerTest, MultiNoEventsBeforeLogin) {
// This test exercises true login/logout, which are not possible on ChromeOS. // This test exercises true login/logout, which are not possible on ChromeOS.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
TEST_F(AccountTrackerTest, MultiLogoutRemovesAllAccounts) { TEST_F(AccountTrackerTest, MultiLogoutRemovesAllAccounts) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
NotifyLogin(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id); ReturnOAuthUrlFetchSuccess(account_id);
observer()->Clear(); observer()->Clear();
...@@ -718,11 +655,10 @@ TEST_F(AccountTrackerTest, MultiLogoutRemovesAllAccounts) { ...@@ -718,11 +655,10 @@ TEST_F(AccountTrackerTest, MultiLogoutRemovesAllAccounts) {
#endif #endif
TEST_F(AccountTrackerTest, MultiRevokePrimaryDoesNotRemoveAllAccounts) { TEST_F(AccountTrackerTest, MultiRevokePrimaryDoesNotRemoveAllAccounts) {
std::string primary_account_id = std::string primary_account_id = SetActiveAccount(kPrimaryAccountEmail);
SetActiveAccount(kPrimaryAccountGaiaId, kPrimaryAccountEmail);
NotifyTokenAvailable(primary_account_id); NotifyTokenAvailable(primary_account_id);
ReturnOAuthUrlFetchSuccess(primary_account_id); ReturnOAuthUrlFetchSuccess(primary_account_id);
std::string account_id = AddAccountWithToken("user", "user@example.com"); std::string account_id = AddAccountWithToken("user@example.com");
ReturnOAuthUrlFetchSuccess(account_id); ReturnOAuthUrlFetchSuccess(account_id);
observer()->Clear(); observer()->Clear();
...@@ -749,9 +685,8 @@ TEST_F(AccountTrackerTest, GetAccountsSignedOut) { ...@@ -749,9 +685,8 @@ TEST_F(AccountTrackerTest, GetAccountsSignedOut) {
TEST_F(AccountTrackerTest, GetAccountsOnlyReturnAccountsWithTokens) { TEST_F(AccountTrackerTest, GetAccountsOnlyReturnAccountsWithTokens) {
std::string primary_account_id = SetupPrimaryLogin(); std::string primary_account_id = SetupPrimaryLogin();
std::string alpha_account_id = std::string alpha_account_id = AddAccountWithToken("alpha@example.com");
AddAccountWithToken("alpha", "alpha@example.com"); std::string beta_account_id = AddAccountWithToken("beta@example.com");
std::string beta_account_id = AddAccountWithToken("beta", "beta@example.com");
ReturnOAuthUrlFetchSuccess(beta_account_id); ReturnOAuthUrlFetchSuccess(beta_account_id);
std::vector<AccountIds> ids = account_tracker()->GetAccounts(); std::vector<AccountIds> ids = account_tracker()->GetAccounts();
...@@ -765,10 +700,9 @@ TEST_F(AccountTrackerTest, GetAccountsOnlyReturnAccountsWithTokens) { ...@@ -765,10 +700,9 @@ TEST_F(AccountTrackerTest, GetAccountsOnlyReturnAccountsWithTokens) {
TEST_F(AccountTrackerTest, GetAccountsSortOrder) { TEST_F(AccountTrackerTest, GetAccountsSortOrder) {
std::string primary_account_id = SetupPrimaryLogin(); std::string primary_account_id = SetupPrimaryLogin();
std::string zeta_account_id = AddAccountWithToken("zeta", "zeta@example.com"); std::string zeta_account_id = AddAccountWithToken("zeta@example.com");
ReturnOAuthUrlFetchSuccess(zeta_account_id); ReturnOAuthUrlFetchSuccess(zeta_account_id);
std::string alpha_account_id = std::string alpha_account_id = AddAccountWithToken("alpha@example.com");
AddAccountWithToken("alpha", "alpha@example.com");
ReturnOAuthUrlFetchSuccess(alpha_account_id); ReturnOAuthUrlFetchSuccess(alpha_account_id);
// The primary account will be first in the vector. Remaining accounts // The primary account will be first in the vector. Remaining accounts
...@@ -786,10 +720,9 @@ TEST_F(AccountTrackerTest, GetAccountsSortOrder) { ...@@ -786,10 +720,9 @@ TEST_F(AccountTrackerTest, GetAccountsSortOrder) {
TEST_F(AccountTrackerTest, GetAccountsReturnNothingWhenPrimarySignedOut) { TEST_F(AccountTrackerTest, GetAccountsReturnNothingWhenPrimarySignedOut) {
std::string primary_account_id = SetupPrimaryLogin(); std::string primary_account_id = SetupPrimaryLogin();
std::string zeta_account_id = AddAccountWithToken("zeta", "zeta@example.com"); std::string zeta_account_id = AddAccountWithToken("zeta@example.com");
ReturnOAuthUrlFetchSuccess(zeta_account_id); ReturnOAuthUrlFetchSuccess(zeta_account_id);
std::string alpha_account_id = std::string alpha_account_id = AddAccountWithToken("alpha@example.com");
AddAccountWithToken("alpha", "alpha@example.com");
ReturnOAuthUrlFetchSuccess(alpha_account_id); ReturnOAuthUrlFetchSuccess(alpha_account_id);
NotifyTokenRevoked(primary_account_id); NotifyTokenRevoked(primary_account_id);
......
...@@ -250,7 +250,7 @@ GCMAccountTrackerTest::GCMAccountTrackerTest() { ...@@ -250,7 +250,7 @@ GCMAccountTrackerTest::GCMAccountTrackerTest() {
&account_tracker_service_, fake_gaia_cookie_manager_service_.get()); &account_tracker_service_, fake_gaia_cookie_manager_service_.get());
std::unique_ptr<AccountTracker> gaia_account_tracker(new AccountTracker( std::unique_ptr<AccountTracker> gaia_account_tracker(new AccountTracker(
fake_signin_manager_.get(), fake_token_service_.get(), identity_manager_.get(),
new net::TestURLRequestContextGetter(message_loop_.task_runner()))); new net::TestURLRequestContextGetter(message_loop_.task_runner())));
tracker_.reset(new GCMAccountTracker(std::move(gaia_account_tracker), tracker_.reset(new GCMAccountTracker(std::move(gaia_account_tracker),
......
...@@ -42,8 +42,6 @@ class GCMProfileService::IdentityObserver ...@@ -42,8 +42,6 @@ class GCMProfileService::IdentityObserver
: public identity::IdentityManager::Observer { : public identity::IdentityManager::Observer {
public: public:
IdentityObserver(identity::IdentityManager* identity_manager, IdentityObserver(identity::IdentityManager* identity_manager,
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
net::URLRequestContextGetter* request_context, net::URLRequestContextGetter* request_context,
GCMDriver* driver); GCMDriver* driver);
~IdentityObserver() override; ~IdentityObserver() override;
...@@ -58,8 +56,6 @@ class GCMProfileService::IdentityObserver ...@@ -58,8 +56,6 @@ class GCMProfileService::IdentityObserver
GCMDriver* driver_; GCMDriver* driver_;
identity::IdentityManager* identity_manager_; identity::IdentityManager* identity_manager_;
SigninManagerBase* signin_manager_;
ProfileOAuth2TokenService* token_service_;
std::unique_ptr<GCMAccountTracker> gcm_account_tracker_; std::unique_ptr<GCMAccountTracker> gcm_account_tracker_;
// The account ID that this service is responsible for. Empty when the service // The account ID that this service is responsible for. Empty when the service
...@@ -73,14 +69,10 @@ class GCMProfileService::IdentityObserver ...@@ -73,14 +69,10 @@ class GCMProfileService::IdentityObserver
GCMProfileService::IdentityObserver::IdentityObserver( GCMProfileService::IdentityObserver::IdentityObserver(
identity::IdentityManager* identity_manager, identity::IdentityManager* identity_manager,
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
net::URLRequestContextGetter* request_context, net::URLRequestContextGetter* request_context,
GCMDriver* driver) GCMDriver* driver)
: driver_(driver), : driver_(driver),
identity_manager_(identity_manager), identity_manager_(identity_manager),
signin_manager_(signin_manager),
token_service_(token_service),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
identity_manager_->AddObserver(this); identity_manager_->AddObserver(this);
...@@ -119,7 +111,7 @@ void GCMProfileService::IdentityObserver::StartAccountTracker( ...@@ -119,7 +111,7 @@ void GCMProfileService::IdentityObserver::StartAccountTracker(
return; return;
std::unique_ptr<AccountTracker> gaia_account_tracker( std::unique_ptr<AccountTracker> gaia_account_tracker(
new AccountTracker(signin_manager_, token_service_, request_context)); new AccountTracker(identity_manager_, request_context));
gcm_account_tracker_.reset(new GCMAccountTracker( gcm_account_tracker_.reset(new GCMAccountTracker(
std::move(gaia_account_tracker), identity_manager_, driver_)); std::move(gaia_account_tracker), identity_manager_, driver_));
...@@ -154,15 +146,11 @@ GCMProfileService::GCMProfileService( ...@@ -154,15 +146,11 @@ GCMProfileService::GCMProfileService(
version_info::Channel channel, version_info::Channel channel,
const std::string& product_category_for_subtypes, const std::string& product_category_for_subtypes,
identity::IdentityManager* identity_manager, identity::IdentityManager* identity_manager,
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
std::unique_ptr<GCMClientFactory> gcm_client_factory, std::unique_ptr<GCMClientFactory> gcm_client_factory,
const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner) scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner)
: identity_manager_(identity_manager), : identity_manager_(identity_manager),
signin_manager_(signin_manager),
token_service_(token_service),
request_context_(request_context) { request_context_(request_context) {
driver_ = CreateGCMDriverDesktop( driver_ = CreateGCMDriverDesktop(
std::move(gcm_client_factory), prefs, std::move(gcm_client_factory), prefs,
...@@ -171,8 +159,7 @@ GCMProfileService::GCMProfileService( ...@@ -171,8 +159,7 @@ GCMProfileService::GCMProfileService(
ui_task_runner, io_task_runner, blocking_task_runner); ui_task_runner, io_task_runner, blocking_task_runner);
identity_observer_.reset( identity_observer_.reset(
new IdentityObserver(identity_manager_, signin_manager_, token_service_, new IdentityObserver(identity_manager_, request_context_, driver_.get()));
request_context_, driver_.get()));
} }
#endif // BUILDFLAG(USE_GCM_FROM_PLATFORM) #endif // BUILDFLAG(USE_GCM_FROM_PLATFORM)
...@@ -196,8 +183,7 @@ void GCMProfileService::SetDriverForTesting(std::unique_ptr<GCMDriver> driver) { ...@@ -196,8 +183,7 @@ void GCMProfileService::SetDriverForTesting(std::unique_ptr<GCMDriver> driver) {
#if !BUILDFLAG(USE_GCM_FROM_PLATFORM) #if !BUILDFLAG(USE_GCM_FROM_PLATFORM)
if (identity_observer_) { if (identity_observer_) {
identity_observer_ = std::make_unique<IdentityObserver>( identity_observer_ = std::make_unique<IdentityObserver>(
identity_manager_, signin_manager_, token_service_, request_context_, identity_manager_, request_context_, driver.get());
driver.get());
} }
#endif // !BUILDFLAG(USE_GCM_FROM_PLATFORM) #endif // !BUILDFLAG(USE_GCM_FROM_PLATFORM)
} }
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/gcm_driver/gcm_buildflags.h" #include "components/gcm_driver/gcm_buildflags.h"
#include "components/keyed_service/core/keyed_service.h" #include "components/keyed_service/core/keyed_service.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
class PrefService; class PrefService;
...@@ -59,8 +57,6 @@ class GCMProfileService : public KeyedService { ...@@ -59,8 +57,6 @@ class GCMProfileService : public KeyedService {
version_info::Channel channel, version_info::Channel channel,
const std::string& product_category_for_subtypes, const std::string& product_category_for_subtypes,
identity::IdentityManager* identity_manager, identity::IdentityManager* identity_manager,
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service,
std::unique_ptr<GCMClientFactory> gcm_client_factory, std::unique_ptr<GCMClientFactory> gcm_client_factory,
const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, const scoped_refptr<base::SequencedTaskRunner>& io_task_runner,
...@@ -88,8 +84,6 @@ class GCMProfileService : public KeyedService { ...@@ -88,8 +84,6 @@ class GCMProfileService : public KeyedService {
#if !BUILDFLAG(USE_GCM_FROM_PLATFORM) #if !BUILDFLAG(USE_GCM_FROM_PLATFORM)
identity::IdentityManager* identity_manager_; identity::IdentityManager* identity_manager_;
SigninManagerBase* signin_manager_;
ProfileOAuth2TokenService* token_service_;
net::URLRequestContextGetter* request_context_ = nullptr; net::URLRequestContextGetter* request_context_ = nullptr;
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include "components/signin/core/browser/signin_manager.h" #include "components/signin/core/browser/signin_manager.h"
#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/identity_manager_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/signin_manager_factory.h"
#include "ios/chrome/common/channel_info.h" #include "ios/chrome/common/channel_info.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -48,8 +46,6 @@ IOSChromeGCMProfileServiceFactory::IOSChromeGCMProfileServiceFactory() ...@@ -48,8 +46,6 @@ IOSChromeGCMProfileServiceFactory::IOSChromeGCMProfileServiceFactory()
"GCMProfileService", "GCMProfileService",
BrowserStateDependencyManager::GetInstance()) { BrowserStateDependencyManager::GetInstance()) {
DependsOn(IdentityManagerFactory::GetInstance()); DependsOn(IdentityManagerFactory::GetInstance());
DependsOn(ios::SigninManagerFactory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
} }
IOSChromeGCMProfileServiceFactory::~IOSChromeGCMProfileServiceFactory() {} IOSChromeGCMProfileServiceFactory::~IOSChromeGCMProfileServiceFactory() {}
...@@ -71,8 +67,6 @@ IOSChromeGCMProfileServiceFactory::BuildServiceInstanceFor( ...@@ -71,8 +67,6 @@ IOSChromeGCMProfileServiceFactory::BuildServiceInstanceFor(
browser_state->GetSharedURLLoaderFactory(), ::GetChannel(), browser_state->GetSharedURLLoaderFactory(), ::GetChannel(),
GetProductCategoryForSubtypes(), GetProductCategoryForSubtypes(),
IdentityManagerFactory::GetForBrowserState(browser_state), IdentityManagerFactory::GetForBrowserState(browser_state),
ios::SigninManagerFactory::GetForBrowserState(browser_state),
ProfileOAuth2TokenServiceFactory::GetForBrowserState(browser_state),
base::WrapUnique(new gcm::GCMClientFactory), base::WrapUnique(new gcm::GCMClientFactory),
web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), web::WebThread::GetTaskRunnerForThread(web::WebThread::IO),
......
...@@ -12,11 +12,8 @@ ...@@ -12,11 +12,8 @@
#include "components/gcm_driver/gcm_client_factory.h" #include "components/gcm_driver/gcm_client_factory.h"
#include "components/gcm_driver/gcm_profile_service.h" #include "components/gcm_driver/gcm_profile_service.h"
#include "components/keyed_service/ios/browser_state_dependency_manager.h" #include "components/keyed_service/ios/browser_state_dependency_manager.h"
#include "components/signin/core/browser/signin_manager.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#include "ios/web_view/internal/signin/web_view_identity_manager_factory.h" #include "ios/web_view/internal/signin/web_view_identity_manager_factory.h"
#include "ios/web_view/internal/signin/web_view_oauth2_token_service_factory.h"
#include "ios/web_view/internal/signin/web_view_signin_manager_factory.h"
#include "ios/web_view/internal/web_view_browser_state.h" #include "ios/web_view/internal/web_view_browser_state.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -48,8 +45,6 @@ WebViewGCMProfileServiceFactory::WebViewGCMProfileServiceFactory() ...@@ -48,8 +45,6 @@ WebViewGCMProfileServiceFactory::WebViewGCMProfileServiceFactory()
: BrowserStateKeyedServiceFactory( : BrowserStateKeyedServiceFactory(
"GCMProfileService", "GCMProfileService",
BrowserStateDependencyManager::GetInstance()) { BrowserStateDependencyManager::GetInstance()) {
DependsOn(WebViewSigninManagerFactory::GetInstance());
DependsOn(WebViewOAuth2TokenServiceFactory::GetInstance());
DependsOn(WebViewIdentityManagerFactory::GetInstance()); DependsOn(WebViewIdentityManagerFactory::GetInstance());
} }
...@@ -72,8 +67,6 @@ WebViewGCMProfileServiceFactory::BuildServiceInstanceFor( ...@@ -72,8 +67,6 @@ WebViewGCMProfileServiceFactory::BuildServiceInstanceFor(
browser_state->GetSharedURLLoaderFactory(), browser_state->GetSharedURLLoaderFactory(),
version_info::Channel::UNKNOWN, GetProductCategoryForSubtypes(), version_info::Channel::UNKNOWN, GetProductCategoryForSubtypes(),
WebViewIdentityManagerFactory::GetForBrowserState(browser_state), WebViewIdentityManagerFactory::GetForBrowserState(browser_state),
WebViewSigninManagerFactory::GetForBrowserState(browser_state),
WebViewOAuth2TokenServiceFactory::GetForBrowserState(browser_state),
base::WrapUnique(new gcm::GCMClientFactory), base::WrapUnique(new gcm::GCMClientFactory),
web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), web::WebThread::GetTaskRunnerForThread(web::WebThread::UI),
web::WebThread::GetTaskRunnerForThread(web::WebThread::IO), web::WebThread::GetTaskRunnerForThread(web::WebThread::IO),
......
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