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_;
}; };
......
...@@ -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