diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-09 21:11:41 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-09 21:11:41 +0000 |
commit | e1011c9cd18af7ec751bf94d02b3b37a7f64f92f (patch) | |
tree | 6a749a53f2ed1d45cc2ef7362a0b80650b3af646 /chrome/browser/extensions | |
parent | f22fae44c1e8dadee6cf78b7a01a6465dfe33656 (diff) | |
download | chromium_src-e1011c9cd18af7ec751bf94d02b3b37a7f64f92f.zip chromium_src-e1011c9cd18af7ec751bf94d02b3b37a7f64f92f.tar.gz chromium_src-e1011c9cd18af7ec751bf94d02b3b37a7f64f92f.tar.bz2 |
Move ownership of SigninGlobalError from SigninManager to
ProfileOAuth2TokenService.
BUG=249467
Review URL: https://chromiumcodereview.appspot.com/17007003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/api/identity/identity_api.cc | 33 | ||||
-rw-r--r-- | chrome/browser/extensions/api/identity/identity_api.h | 3 |
2 files changed, 20 insertions, 16 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc index 407948f..fcfa7d4a 100644 --- a/chrome/browser/extensions/api/identity/identity_api.cc +++ b/chrome/browser/extensions/api/identity/identity_api.cc @@ -20,8 +20,8 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/policy/browser_policy_connector.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/signin/signin_manager.h" -#include "chrome/browser/signin/signin_manager_factory.h" +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" +#include "chrome/browser/signin/signin_global_error.h" #include "chrome/browser/signin/token_service.h" #include "chrome/browser/signin/token_service_factory.h" #include "chrome/common/chrome_notification_types.h" @@ -639,21 +639,22 @@ const base::Time& IdentityTokenCacheValue::expiration_time() const { IdentityAPI::IdentityAPI(Profile* profile) : profile_(profile), - signin_manager_(NULL), - error_(GoogleServiceAuthError::NONE) { + error_(GoogleServiceAuthError::NONE), + initialized_(false) { } IdentityAPI::~IdentityAPI() { } void IdentityAPI::Initialize() { - signin_manager_ = SigninManagerFactory::GetForProfile(profile_); - signin_manager_->signin_global_error()->AddProvider(this); + SigninGlobalError::GetForProfile(profile_)->AddProvider(this); TokenService* token_service = TokenServiceFactory::GetForProfile(profile_); registrar_.Add(this, chrome::NOTIFICATION_TOKEN_AVAILABLE, content::Source<TokenService>(token_service)); + + initialized_ = true; } IdentityMintRequestQueue* IdentityAPI::mint_queue() { @@ -702,16 +703,18 @@ const IdentityAPI::CachedTokens& IdentityAPI::GetAllCachedTokens() { } void IdentityAPI::ReportAuthError(const GoogleServiceAuthError& error) { - if (!signin_manager_) - Initialize(); - error_ = error; - signin_manager_->signin_global_error()->AuthStatusChanged(); + SigninGlobalError::GetForProfile(profile_)->AuthStatusChanged(); } void IdentityAPI::Shutdown() { - if (signin_manager_) - signin_manager_->signin_global_error()->RemoveProvider(this); + if (!initialized_) + return; + + registrar_.RemoveAll(); + SigninGlobalError::GetForProfile(profile_)->RemoveProvider(this); + + initialized_ = false; } static base::LazyInstance<ProfileKeyedAPIFactory<IdentityAPI> > @@ -735,15 +738,17 @@ void IdentityAPI::Observe(int type, if (token_details->service() == GaiaConstants::kGaiaOAuth2LoginRefreshToken) { error_ = GoogleServiceAuthError::AuthErrorNone(); - signin_manager_->signin_global_error()->AuthStatusChanged(); + SigninGlobalError::GetForProfile(profile_)->AuthStatusChanged(); } } template <> void ProfileKeyedAPIFactory<IdentityAPI>::DeclareFactoryDependencies() { DependsOn(ExtensionSystemFactory::GetInstance()); + // Need dependency on ProfileOAuth2TokenServiceFactory because it owns + // the SigninGlobalError instance. + DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); DependsOn(TokenServiceFactory::GetInstance()); - DependsOn(SigninManagerFactory::GetInstance()); } IdentityAPI::TokenCacheKey::TokenCacheKey(const std::string& extension_id, diff --git a/chrome/browser/extensions/api/identity/identity_api.h b/chrome/browser/extensions/api/identity/identity_api.h index a04a01d..c1afb7e 100644 --- a/chrome/browser/extensions/api/identity/identity_api.h +++ b/chrome/browser/extensions/api/identity/identity_api.h @@ -26,7 +26,6 @@ class GoogleServiceAuthError; class MockGetAuthTokenFunction; class Profile; -class SigninManagerBase; namespace extensions { @@ -288,8 +287,8 @@ class IdentityAPI : public ProfileKeyedAPI, static const bool kServiceIsNULLWhileTesting = true; Profile* profile_; - SigninManagerBase* signin_manager_; GoogleServiceAuthError error_; + bool initialized_; // Used to listen to notifications from the TokenService. content::NotificationRegistrar registrar_; IdentityMintRequestQueue mint_queue_; |