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 22 matching lines...) Expand all Loading... |
33 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); | 33 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
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 PushMessagingServiceImpl::RegisterProfilePrefs(registry); |
43 } | 44 } |
44 | 45 |
45 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
46 GCMProfileService::GCMProfileService(Profile* profile) | 47 GCMProfileService::GCMProfileService(Profile* profile) |
47 : profile_(profile), | 48 : profile_(profile), |
48 push_messaging_service_(this) { | 49 push_messaging_service_(this, profile) { |
49 DCHECK(!profile->IsOffTheRecord()); | 50 DCHECK(!profile->IsOffTheRecord()); |
50 | 51 |
51 driver_.reset(new GCMDriverAndroid); | 52 driver_.reset(new GCMDriverAndroid); |
52 } | 53 } |
53 #else | 54 #else |
54 GCMProfileService::GCMProfileService( | 55 GCMProfileService::GCMProfileService( |
55 Profile* profile, | 56 Profile* profile, |
56 scoped_ptr<GCMClientFactory> gcm_client_factory) | 57 scoped_ptr<GCMClientFactory> gcm_client_factory) |
57 : profile_(profile), | 58 : profile_(profile), |
58 push_messaging_service_(this) { | 59 push_messaging_service_(this, profile) { |
59 DCHECK(!profile->IsOffTheRecord()); | 60 DCHECK(!profile->IsOffTheRecord()); |
60 | 61 |
61 driver_ = CreateGCMDriverDesktop( | 62 driver_ = CreateGCMDriverDesktop( |
62 gcm_client_factory.Pass(), | 63 gcm_client_factory.Pass(), |
63 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( | 64 scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( |
64 SigninManagerFactory::GetForProfile(profile_), | 65 SigninManagerFactory::GetForProfile(profile_), |
65 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), | 66 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_), |
66 LoginUIServiceFactory::GetForProfile(profile_))), | 67 LoginUIServiceFactory::GetForProfile(profile_))), |
67 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 68 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
68 profile_->GetRequestContext()); | 69 profile_->GetRequestContext()); |
69 } | 70 } |
70 #endif // defined(OS_ANDROID) | 71 #endif // defined(OS_ANDROID) |
71 | 72 |
72 GCMProfileService::GCMProfileService() | 73 GCMProfileService::GCMProfileService() |
73 : profile_(NULL), | 74 : profile_(NULL), |
74 push_messaging_service_(this) { | 75 push_messaging_service_(this, NULL) { |
75 } | 76 } |
76 | 77 |
77 GCMProfileService::~GCMProfileService() { | 78 GCMProfileService::~GCMProfileService() { |
78 } | 79 } |
79 | 80 |
80 void GCMProfileService::AddAppHandler(const std::string& app_id, | 81 void GCMProfileService::AddAppHandler(const std::string& app_id, |
81 GCMAppHandler* handler) { | 82 GCMAppHandler* handler) { |
82 if (driver_) | 83 if (driver_) |
83 driver_->AddAppHandler(app_id, handler); | 84 driver_->AddAppHandler(app_id, handler); |
84 } | 85 } |
(...skipping 15 matching lines...) Expand all Loading... |
100 driver_->Shutdown(); | 101 driver_->Shutdown(); |
101 driver_.reset(); | 102 driver_.reset(); |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 106 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
106 driver_.reset(driver); | 107 driver_.reset(driver); |
107 } | 108 } |
108 | 109 |
109 } // namespace gcm | 110 } // namespace gcm |
OLD | NEW |