diff options
Diffstat (limited to 'chrome/browser/extensions/api/identity/identity_api.cc')
-rw-r--r-- | chrome/browser/extensions/api/identity/identity_api.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc index f60da81..491b65e 100644 --- a/chrome/browser/extensions/api/identity/identity_api.cc +++ b/chrome/browser/extensions/api/identity/identity_api.cc @@ -655,14 +655,20 @@ const base::Time& IdentityTokenCacheValue::expiration_time() const { IdentityAPI::IdentityAPI(Profile* profile) : profile_(profile), - error_(GoogleServiceAuthError::NONE) { - SigninGlobalError::GetForProfile(profile_)->AddProvider(this); - ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->AddObserver(this); + error_(GoogleServiceAuthError::NONE), + initialized_(false) { } IdentityAPI::~IdentityAPI() { } +void IdentityAPI::Initialize() { + SigninGlobalError::GetForProfile(profile_)->AddProvider(this); + ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->AddObserver(this); + + initialized_ = true; +} + IdentityMintRequestQueue* IdentityAPI::mint_queue() { return &mint_queue_; } @@ -714,9 +720,14 @@ void IdentityAPI::ReportAuthError(const GoogleServiceAuthError& error) { } void IdentityAPI::Shutdown() { + if (!initialized_) + return; + SigninGlobalError::GetForProfile(profile_)->RemoveProvider(this); ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> RemoveObserver(this); + + initialized_ = false; } static base::LazyInstance<ProfileKeyedAPIFactory<IdentityAPI> > |