| Index: chrome/browser/services/gcm/gcm_profile_service.cc
|
| diff --git a/chrome/browser/services/gcm/gcm_profile_service.cc b/chrome/browser/services/gcm/gcm_profile_service.cc
|
| index d4ab7028ab9c9d37dcb7bd9edae2f13c0fb56062..2b0e6b05b7c791a85798a89a372f2f54482da353 100644
|
| --- a/chrome/browser/services/gcm/gcm_profile_service.cc
|
| +++ b/chrome/browser/services/gcm/gcm_profile_service.cc
|
| @@ -60,12 +60,16 @@ GCMProfileService::GCMProfileService(
|
|
|
| driver_ = CreateGCMDriverDesktop(
|
| gcm_client_factory.Pass(),
|
| - scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
|
| - SigninManagerFactory::GetForProfile(profile_),
|
| - ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
|
| - LoginUIServiceFactory::GetForProfile(profile_))),
|
| profile_->GetPath().Append(chrome::kGCMStoreDirname),
|
| profile_->GetRequestContext());
|
| +
|
| + identity_provider_.reset(new ProfileIdentityProvider(
|
| + SigninManagerFactory::GetForProfile(profile_),
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
|
| + LoginUIServiceFactory::GetForProfile(profile_)));
|
| + identity_provider_->AddObserver(this);
|
| +
|
| + OnActiveAccountLogin();
|
| }
|
| #endif // defined(OS_ANDROID)
|
|
|
| @@ -100,6 +104,41 @@ void GCMProfileService::Shutdown() {
|
| driver_->Shutdown();
|
| driver_.reset();
|
| }
|
| +
|
| +#if !defined(OS_ANDROID)
|
| + if (identity_provider_) {
|
| + identity_provider_->RemoveObserver(this);
|
| + identity_provider_.reset();
|
| + }
|
| +#endif // !defined(OS_ANDROID)
|
| +}
|
| +
|
| +#if !defined(OS_ANDROID)
|
| +void GCMProfileService::OnActiveAccountLogin() {
|
| + if (!driver_)
|
| + return;
|
| +
|
| + // This might be called multiple times when the password changes.
|
| + const std::string account_id = identity_provider_->GetActiveAccountId();
|
| + if (account_id == account_id_)
|
| + return;
|
| + account_id_ = account_id;
|
| +
|
| + driver_->SignIn();
|
| +}
|
| +
|
| +void GCMProfileService::OnActiveAccountLogout() {
|
| + if (driver_)
|
| + driver_->Purge();
|
| +}
|
| +#endif // !defined(OS_ANDROID)
|
| +
|
| +std::string GCMProfileService::SignedInUserName() const {
|
| +#if !defined(OS_ANDROID)
|
| + if (driver_ && driver_->IsStarted())
|
| + return account_id_;
|
| +#endif // !defined(OS_ANDROID)
|
| + return std::string();
|
| }
|
|
|
| void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
|
|
|