OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/extensions/api/gcm/gcm_api.h" | 5 #include "chrome/browser/extensions/api/gcm/gcm_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 namespace extensions { | 78 namespace extensions { |
79 | 79 |
80 bool GcmApiFunction::RunImpl() { | 80 bool GcmApiFunction::RunImpl() { |
81 if (!IsGcmApiEnabled()) | 81 if (!IsGcmApiEnabled()) |
82 return false; | 82 return false; |
83 | 83 |
84 return DoWork(); | 84 return DoWork(); |
85 } | 85 } |
86 | 86 |
87 bool GcmApiFunction::IsGcmApiEnabled() const { | 87 bool GcmApiFunction::IsGcmApiEnabled() const { |
88 return gcm::GCMProfileService::IsGCMEnabled() && | 88 return gcm::GCMProfileService::IsGCMEnabled( |
89 !GetExtension()->public_key().empty(); | 89 Profile::FromBrowserContext(context())) && |
| 90 !GetExtension()->public_key().empty(); |
90 } | 91 } |
91 | 92 |
92 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const { | 93 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const { |
93 return gcm::GCMProfileServiceFactory::GetForProfile( | 94 return gcm::GCMProfileServiceFactory::GetForProfile( |
94 Profile::FromBrowserContext(context())); | 95 Profile::FromBrowserContext(context())); |
95 } | 96 } |
96 | 97 |
97 GcmRegisterFunction::GcmRegisterFunction() {} | 98 GcmRegisterFunction::GcmRegisterFunction() {} |
98 | 99 |
99 GcmRegisterFunction::~GcmRegisterFunction() {} | 100 GcmRegisterFunction::~GcmRegisterFunction() {} |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 | 213 |
213 scoped_ptr<Event> event(new Event( | 214 scoped_ptr<Event> event(new Event( |
214 api::gcm::OnSendError::kEventName, | 215 api::gcm::OnSendError::kEventName, |
215 api::gcm::OnSendError::Create(error).Pass(), | 216 api::gcm::OnSendError::Create(error).Pass(), |
216 profile_)); | 217 profile_)); |
217 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 218 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
218 app_id, event.Pass()); | 219 app_id, event.Pass()); |
219 } | 220 } |
220 | 221 |
221 } // namespace extensions | 222 } // namespace extensions |
OLD | NEW |