Move OAuth2TokenService observing out of IdentityProvider
IdentityProvider currently has baked-in knowledge of OAuth2TokenService
for functionality that is shared between ProfileIdentityProvider and
DeviceIdentityProvider. However, as we will be converting
ProfileIdentityProvider to talk to IdentityManager rather than
OAuth2TokenService, this baked-in knowledge needs to be moved out of
IdentityProvider; ultimately, it will end up only in
DeviceIdentityProvider.
As the last step of removing this knowledge from IdentityProvider, this
CL moves IdentityProvider's observing of OAuth2TokenService into its
two derived classes. ProfileIdentityProvider is now ready to be
converted to use IdentityManager; that work will shortly follow.
Bug: 809452
Change-Id: I9beaae509b2aae22308c0bd47f962a42cba93f8d
Reviewed-on: https://chromium-review.googlesource.com/1114855
Commit-Queue: Colin Blundell <[email protected]>
Reviewed-by: Julian Pastarmov <[email protected]>
Reviewed-by: Pavel Yatsuk <[email protected]>
Cr-Commit-Position: refs/heads/master@{#571458}
diff --git a/components/invalidation/impl/profile_identity_provider.cc b/components/invalidation/impl/profile_identity_provider.cc
index 9284a005..6fa8f96 100644
--- a/components/invalidation/impl/profile_identity_provider.cc
+++ b/components/invalidation/impl/profile_identity_provider.cc
@@ -13,18 +13,23 @@
SigninManagerBase* signin_manager,
ProfileOAuth2TokenService* token_service)
: signin_manager_(signin_manager), token_service_(token_service) {
+ // TODO(blundell): Can |token_service_| ever actually be non-null?
+ if (token_service_)
+ token_service_->AddObserver(this);
signin_manager_->AddObserver(this);
}
ProfileIdentityProvider::~ProfileIdentityProvider() {
+ // TODO(blundell): Can |token_service_| ever actually be non-null?
+ if (token_service_)
+ token_service_->RemoveObserver(this);
+
// In unittests |signin_manager_| is allowed to be null.
// TODO(809452): Eliminate this short-circuit when this class is converted to
// take in IdentityManager, at which point the tests can use
// IdentityTestEnvironment.
- if (!signin_manager_)
- return;
-
- signin_manager_->RemoveObserver(this);
+ if (signin_manager_)
+ signin_manager_->RemoveObserver(this);
}
std::string ProfileIdentityProvider::GetActiveAccountId() {
@@ -63,10 +68,6 @@
access_token);
}
-OAuth2TokenService* ProfileIdentityProvider::GetTokenService() {
- return token_service_;
-}
-
void ProfileIdentityProvider::GoogleSigninSucceeded(
const std::string& account_id,
const std::string& username) {
@@ -78,4 +79,14 @@
FireOnActiveAccountLogout();
}
+void ProfileIdentityProvider::OnRefreshTokenAvailable(
+ const std::string& account_id) {
+ ProcessRefreshTokenUpdateForAccount(account_id);
+}
+
+void ProfileIdentityProvider::OnRefreshTokenRevoked(
+ const std::string& account_id) {
+ ProcessRefreshTokenRemovalForAccount(account_id);
+}
+
} // namespace invalidation