| 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 a14ae00d55bc6f20cf433ab22ab119b7ee6385ae..b681a986d25b7155993ff363e9bf9664e52c34c6 100644
|
| --- a/chrome/browser/services/gcm/gcm_profile_service.cc
|
| +++ b/chrome/browser/services/gcm/gcm_profile_service.cc
|
| @@ -9,12 +9,14 @@
|
| #include "base/prefs/pref_service.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/services/gcm/gcm_driver.h"
|
| #include "chrome/browser/signin/profile_identity_provider.h"
|
| #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
|
| #include "chrome/browser/signin/signin_manager_factory.h"
|
| #include "chrome/common/chrome_constants.h"
|
| #include "chrome/common/chrome_version_info.h"
|
| #include "chrome/common/pref_names.h"
|
| +#include "components/gcm_driver/gcm_client_factory.h"
|
| #include "components/pref_registry/pref_registry_syncable.h"
|
| #include "components/signin/core/browser/signin_manager.h"
|
| #include "google_apis/gaia/identity_provider.h"
|
| @@ -74,42 +76,38 @@ void GCMProfileService::RegisterProfilePrefs(
|
| }
|
|
|
| GCMProfileService::GCMProfileService(Profile* profile)
|
| - : GCMDriver(scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
|
| - SigninManagerFactory::GetForProfile(profile),
|
| - ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
|
| -#if defined(OS_ANDROID)
|
| - NULL))),
|
| -#else
|
| - LoginUIServiceFactory::GetForProfile(profile)))),
|
| -#endif
|
| - profile_(profile) {
|
| + : profile_(profile) {
|
| DCHECK(!profile->IsOffTheRecord());
|
| }
|
|
|
| GCMProfileService::~GCMProfileService() {
|
| }
|
|
|
| -void GCMProfileService::Shutdown() {
|
| - ShutdownService();
|
| -}
|
| +void GCMProfileService::Initialize(
|
| + scoped_ptr<GCMClientFactory> gcm_client_factory) {
|
| + DCHECK(!driver_);
|
|
|
| -std::string GCMProfileService::SignedInUserName() const {
|
| - if (IsStarted())
|
| - return identity_provider_->GetActiveUsername();
|
| - return std::string();
|
| -}
|
| -
|
| -bool GCMProfileService::ShouldStartAutomatically() const {
|
| - return GetGCMEnabledState(profile_) == ALWAYS_ENABLED;
|
| + driver_.reset(new GCMDriver(
|
| + gcm_client_factory.Pass(),
|
| + scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
|
| + SigninManagerFactory::GetForProfile(profile_),
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile_),
|
| +#if defined(OS_ANDROID)
|
| + NULL)),
|
| +#else
|
| + LoginUIServiceFactory::GetForProfile(profile_))),
|
| +#endif
|
| + profile_->GetPath().Append(chrome::kGCMStoreDirname),
|
| + profile_->GetRequestContext()));
|
| }
|
|
|
| -base::FilePath GCMProfileService::GetStorePath() const {
|
| - return profile_->GetPath().Append(chrome::kGCMStoreDirname);
|
| +void GCMProfileService::Shutdown() {
|
| + if (driver_)
|
| + driver_->Shutdown();
|
| }
|
|
|
| -scoped_refptr<net::URLRequestContextGetter>
|
| -GCMProfileService::GetURLRequestContextGetter() const {
|
| - return profile_->GetRequestContext();
|
| +void GCMProfileService::SetDriverForTesting(GCMDriver* driver) {
|
| + driver_.reset(driver);
|
| }
|
|
|
| } // namespace gcm
|
|
|