| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 5 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 void GCMProfileService::RegisterProfilePrefs( | 37 void GCMProfileService::RegisterProfilePrefs( |
| 38 user_prefs::PrefRegistrySyncable* registry) { | 38 user_prefs::PrefRegistrySyncable* registry) { |
| 39 registry->RegisterBooleanPref( | 39 registry->RegisterBooleanPref( |
| 40 prefs::kGCMChannelEnabled, | 40 prefs::kGCMChannelEnabled, |
| 41 true, | 41 true, |
| 42 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 42 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 43 } | 43 } |
| 44 | 44 |
| 45 #if defined(OS_ANDROID) | 45 #if defined(OS_ANDROID) |
| 46 GCMProfileService::GCMProfileService(Profile* profile) | 46 GCMProfileService::GCMProfileService(Profile* profile) |
| 47 : profile_(profile), | 47 : profile_(profile) { |
| 48 push_messaging_service_(this) { | |
| 49 DCHECK(!profile->IsOffTheRecord()); | 48 DCHECK(!profile->IsOffTheRecord()); |
| 50 | 49 |
| 51 driver_.reset(new GCMDriverAndroid); | 50 driver_.reset(new GCMDriverAndroid); |
| 52 } | 51 } |
| 53 #else | 52 #else |
| 54 GCMProfileService::GCMProfileService( | 53 GCMProfileService::GCMProfileService( |
| 55 Profile* profile, | 54 Profile* profile, |
| 56 scoped_ptr<GCMClientFactory> gcm_client_factory) | 55 scoped_ptr<GCMClientFactory> gcm_client_factory) |
| 57 : profile_(profile), | 56 : profile_(profile) { |
| 58 push_messaging_service_(this) { | |
| 59 DCHECK(!profile->IsOffTheRecord()); | 57 DCHECK(!profile->IsOffTheRecord()); |
| 60 | 58 |
| 61 driver_ = CreateGCMDriverDesktop( | 59 driver_ = CreateGCMDriverDesktop( |
| 62 gcm_client_factory.Pass(), | 60 gcm_client_factory.Pass(), |
| 63 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( | 61 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( |
| 64 SigninManagerFactory::GetForProfile(profile_), | 62 SigninManagerFactory::GetForProfile(profile_), |
| 65 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), | 63 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), |
| 66 LoginUIServiceFactory::GetForProfile(profile_))), | 64 LoginUIServiceFactory::GetForProfile(profile_))), |
| 67 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 65 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
| 68 profile_->GetRequestContext()); | 66 profile_->GetRequestContext()); |
| 69 } | 67 } |
| 70 #endif // defined(OS_ANDROID) | 68 #endif // defined(OS_ANDROID) |
| 71 | 69 |
| 72 GCMProfileService::GCMProfileService() | 70 GCMProfileService::GCMProfileService() : profile_(NULL) { |
| 73 : profile_(NULL), | |
| 74 push_messaging_service_(this) { | |
| 75 } | 71 } |
| 76 | 72 |
| 77 GCMProfileService::~GCMProfileService() { | 73 GCMProfileService::~GCMProfileService() { |
| 78 } | 74 } |
| 79 | 75 |
| 80 void GCMProfileService::AddAppHandler(const std::string& app_id, | 76 void GCMProfileService::AddAppHandler(const std::string& app_id, |
| 81 GCMAppHandler* handler) { | 77 GCMAppHandler* handler) { |
| 82 if (driver_) | 78 if (driver_) |
| 83 driver_->AddAppHandler(app_id, handler); | 79 driver_->AddAppHandler(app_id, handler); |
| 84 } | 80 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 100 driver_->Shutdown(); | 96 driver_->Shutdown(); |
| 101 driver_.reset(); | 97 driver_.reset(); |
| 102 } | 98 } |
| 103 } | 99 } |
| 104 | 100 |
| 105 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 101 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
| 106 driver_.reset(driver); | 102 driver_.reset(driver); |
| 107 } | 103 } |
| 108 | 104 |
| 109 } // namespace gcm | 105 } // namespace gcm |
| OLD | NEW |