Index: chrome/browser/extensions/api/identity/identity_api.cc |
diff --git a/chrome/browser/extensions/api/identity/identity_api.cc b/chrome/browser/extensions/api/identity/identity_api.cc |
index 890f99443daecfe880f334763e2d1df758a3bb1f..206c91f2cfeb1c5a21a13682826eb7647bdd6c37 100644 |
--- a/chrome/browser/extensions/api/identity/identity_api.cc |
+++ b/chrome/browser/extensions/api/identity/identity_api.cc |
@@ -666,14 +666,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_; |
} |
@@ -725,9 +731,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> > |