Commit d22ab991 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

[s13n] Port identity_api.cc away from observing ProfileOAuth2TokenService

... to observing IdentityManager

CL also gets rid of the AccountTrackerService usage, driven-by.

BUG=906579

Change-Id: I1ec47f5817a665995a5c1e4c2a6ed21a49756f3e
Reviewed-on: https://chromium-review.googlesource.com/c/1340890Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#610032}
parent 30e8acd0
......@@ -28,10 +28,9 @@
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/common/extensions/api/identity.h"
#include "chrome/common/url_constants.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_l10n_util.h"
......@@ -104,7 +103,7 @@ const base::Time& IdentityTokenCacheValue::expiration_time() const {
IdentityAPI::IdentityAPI(content::BrowserContext* context)
: profile_(Profile::FromBrowserContext(context)) {
AccountTrackerServiceFactory::GetForProfile(profile_)->AddObserver(this);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->AddObserver(this);
IdentityManagerFactory::GetForProfile(profile_)->AddObserver(this);
}
IdentityAPI::~IdentityAPI() {}
......@@ -147,8 +146,7 @@ const IdentityAPI::CachedTokens& IdentityAPI::GetAllCachedTokens() {
void IdentityAPI::Shutdown() {
on_shutdown_callback_list_.Notify();
AccountTrackerServiceFactory::GetForProfile(profile_)->RemoveObserver(this);
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->RemoveObserver(
this);
IdentityManagerFactory::GetForProfile(profile_)->RemoveObserver(this);
}
static base::LazyInstance<BrowserContextKeyedAPIFactory<IdentityAPI>>::
......@@ -172,11 +170,9 @@ bool IdentityAPI::AreExtensionsRestrictedToPrimaryAccount() {
#endif
}
void IdentityAPI::OnRefreshTokenAvailable(const std::string& account_id) {
const AccountInfo& account_info =
AccountTrackerServiceFactory::GetForProfile(profile_)->GetAccountInfo(
account_id);
void IdentityAPI::OnRefreshTokenUpdatedForAccount(
const AccountInfo& account_info,
bool is_valid) {
// Refresh tokens are sometimes made available in contexts where
// AccountTrackerService is not tracking the account in question (one example
// is SupervisedUserService::InitSync()). Bail out in these cases.
......@@ -214,7 +210,7 @@ void BrowserContextKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies() {
DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
DependsOn(ChromeSigninClientFactory::GetInstance());
DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
DependsOn(IdentityManagerFactory::GetInstance());
}
} // namespace extensions
......@@ -35,6 +35,7 @@
#include "extensions/browser/event_router.h"
#include "google_apis/gaia/oauth2_mint_token_flow.h"
#include "google_apis/gaia/oauth2_token_service.h"
#include "services/identity/public/cpp/identity_manager.h"
namespace content {
class BrowserContext;
......@@ -82,7 +83,7 @@ class IdentityTokenCacheValue {
class IdentityAPI : public BrowserContextKeyedAPI,
public AccountTrackerService::Observer,
public OAuth2TokenService::Observer {
public identity::IdentityManager::Observer {
public:
typedef std::map<ExtensionTokenKey, IdentityTokenCacheValue> CachedTokens;
......@@ -131,8 +132,9 @@ class IdentityAPI : public BrowserContextKeyedAPI,
static const char* service_name() { return "IdentityAPI"; }
static const bool kServiceIsNULLWhileTesting = true;
// OAuth2TokenService::Observer:
void OnRefreshTokenAvailable(const std::string& account_id) override;
// identity::IdentityManager::Observer:
void OnRefreshTokenUpdatedForAccount(const AccountInfo& account_info,
bool is_valid) override;
// AccountTrackerService::Observer:
// NOTE: This class listens for signout events via this callback (which itself
......
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