| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 namespace extensions { | 90 namespace extensions { |
| 91 | 91 |
| 92 bool GcmApiFunction::RunImpl() { | 92 bool GcmApiFunction::RunImpl() { |
| 93 if (!IsGcmApiEnabled()) | 93 if (!IsGcmApiEnabled()) |
| 94 return false; | 94 return false; |
| 95 | 95 |
| 96 return DoWork(); | 96 return DoWork(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool GcmApiFunction::IsGcmApiEnabled() const { | 99 bool GcmApiFunction::IsGcmApiEnabled() const { |
| 100 return gcm::GCMProfileService::IsGCMEnabled( | 100 Profile* profile = Profile::FromBrowserContext(context()); |
| 101 Profile::FromBrowserContext(context())); | 101 |
| 102 // GCM is not supported in incognito mode. |
| 103 if (profile->IsOffTheRecord()) |
| 104 return false; |
| 105 |
| 106 return gcm::GCMProfileService::GetGCMEnabledState(profile) != |
| 107 gcm::GCMProfileService::ALWAYS_DISABLED; |
| 102 } | 108 } |
| 103 | 109 |
| 104 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const { | 110 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const { |
| 105 return gcm::GCMProfileServiceFactory::GetForProfile( | 111 return gcm::GCMProfileServiceFactory::GetForProfile( |
| 106 Profile::FromBrowserContext(context())); | 112 Profile::FromBrowserContext(context())); |
| 107 } | 113 } |
| 108 | 114 |
| 109 GcmRegisterFunction::GcmRegisterFunction() {} | 115 GcmRegisterFunction::GcmRegisterFunction() {} |
| 110 | 116 |
| 111 GcmRegisterFunction::~GcmRegisterFunction() {} | 117 GcmRegisterFunction::~GcmRegisterFunction() {} |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 231 |
| 226 scoped_ptr<Event> event(new Event( | 232 scoped_ptr<Event> event(new Event( |
| 227 api::gcm::OnSendError::kEventName, | 233 api::gcm::OnSendError::kEventName, |
| 228 api::gcm::OnSendError::Create(error).Pass(), | 234 api::gcm::OnSendError::Create(error).Pass(), |
| 229 profile_)); | 235 profile_)); |
| 230 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 236 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
| 231 app_id, event.Pass()); | 237 app_id, event.Pass()); |
| 232 } | 238 } |
| 233 | 239 |
| 234 } // namespace extensions | 240 } // namespace extensions |
| OLD | NEW |