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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); | 91 return profile->GetPrefs()->GetBoolean(prefs::kGCMChannelEnabled); |
92 } | 92 } |
93 | 93 |
94 // static | 94 // static |
95 void GCMProfileService::RegisterProfilePrefs( | 95 void GCMProfileService::RegisterProfilePrefs( |
96 user_prefs::PrefRegistrySyncable* registry) { | 96 user_prefs::PrefRegistrySyncable* registry) { |
97 registry->RegisterBooleanPref( | 97 registry->RegisterBooleanPref( |
98 prefs::kGCMChannelEnabled, | 98 prefs::kGCMChannelEnabled, |
99 true, | 99 true, |
100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 100 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 101 PushMessagingServiceImpl::RegisterProfilePrefs(registry); |
101 } | 102 } |
102 | 103 |
103 #if defined(OS_ANDROID) | 104 #if defined(OS_ANDROID) |
104 GCMProfileService::GCMProfileService(Profile* profile) | 105 GCMProfileService::GCMProfileService(Profile* profile) |
105 : profile_(profile), | 106 : profile_(profile), |
106 push_messaging_service_(this) { | 107 push_messaging_service_(this, profile) { |
107 DCHECK(!profile->IsOffTheRecord()); | 108 DCHECK(!profile->IsOffTheRecord()); |
108 | 109 |
109 driver_.reset(new GCMDriverAndroid); | 110 driver_.reset(new GCMDriverAndroid); |
110 } | 111 } |
111 #else | 112 #else |
112 GCMProfileService::GCMProfileService( | 113 GCMProfileService::GCMProfileService( |
113 Profile* profile, | 114 Profile* profile, |
114 scoped_ptr<GCMClientFactory> gcm_client_factory) | 115 scoped_ptr<GCMClientFactory> gcm_client_factory) |
115 : profile_(profile), | 116 : profile_(profile), |
116 push_messaging_service_(this) { | 117 push_messaging_service_(this, profile) { |
117 DCHECK(!profile->IsOffTheRecord()); | 118 DCHECK(!profile->IsOffTheRecord()); |
118 | 119 |
119 driver_ = CreateGCMDriverDesktop( | 120 driver_ = CreateGCMDriverDesktop( |
120 gcm_client_factory.Pass(), | 121 gcm_client_factory.Pass(), |
121 profile_->GetPath().Append(chrome::kGCMStoreDirname), | 122 profile_->GetPath().Append(chrome::kGCMStoreDirname), |
122 profile_->GetRequestContext()); | 123 profile_->GetRequestContext()); |
123 | 124 |
124 identity_observer_.reset(new IdentityObserver(profile, driver_.get())); | 125 identity_observer_.reset(new IdentityObserver(profile, driver_.get())); |
125 } | 126 } |
126 #endif // defined(OS_ANDROID) | 127 #endif // defined(OS_ANDROID) |
127 | 128 |
128 GCMProfileService::GCMProfileService() | 129 GCMProfileService::GCMProfileService() |
129 : profile_(NULL), | 130 : profile_(NULL), |
130 push_messaging_service_(this) { | 131 push_messaging_service_(this, NULL) { |
131 } | 132 } |
132 | 133 |
133 GCMProfileService::~GCMProfileService() { | 134 GCMProfileService::~GCMProfileService() { |
134 } | 135 } |
135 | 136 |
136 void GCMProfileService::AddAppHandler(const std::string& app_id, | 137 void GCMProfileService::AddAppHandler(const std::string& app_id, |
137 GCMAppHandler* handler) { | 138 GCMAppHandler* handler) { |
138 if (driver_) | 139 if (driver_) |
139 driver_->AddAppHandler(app_id, handler); | 140 driver_->AddAppHandler(app_id, handler); |
140 } | 141 } |
(...skipping 28 matching lines...) Expand all Loading... |
169 return identity_observer_ ? identity_observer_->SignedInUserName() | 170 return identity_observer_ ? identity_observer_->SignedInUserName() |
170 : std::string(); | 171 : std::string(); |
171 #endif // defined(OS_ANDROID) | 172 #endif // defined(OS_ANDROID) |
172 } | 173 } |
173 | 174 |
174 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { | 175 void GCMProfileService::SetDriverForTesting(GCMDriver* driver) { |
175 driver_.reset(driver); | 176 driver_.reset(driver); |
176 } | 177 } |
177 | 178 |
178 } // namespace gcm | 179 } // namespace gcm |
OLD | NEW |