Index: chrome/browser/extensions/api/gcm/gcm_api.cc |
diff --git a/chrome/browser/extensions/api/gcm/gcm_api.cc b/chrome/browser/extensions/api/gcm/gcm_api.cc |
index 03a9b9abdbd9a10bf7d20ac71b96b9948aaec360..2028ce15b2f49496658601b62a3c3373b7e151b3 100644 |
--- a/chrome/browser/extensions/api/gcm/gcm_api.cc |
+++ b/chrome/browser/extensions/api/gcm/gcm_api.cc |
@@ -15,7 +15,6 @@ |
#include "chrome/browser/services/gcm/gcm_profile_service.h" |
#include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
#include "chrome/common/extensions/api/gcm.h" |
-#include "extensions/browser/event_router.h" |
#include "extensions/browser/extension_system.h" |
#include "extensions/common/extension.h" |
@@ -179,9 +178,18 @@ bool GcmSendFunction::ValidateMessageData( |
return total_size != 0; |
} |
-GcmJsEventRouter::GcmJsEventRouter(Profile* profile) : profile_(profile) {} |
+GcmJsEventRouter::GcmJsEventRouter(Profile* profile) : profile_(profile) { |
+ ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( |
+ this, api::gcm::OnMessage::kEventName); |
+ ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( |
+ this, api::gcm::OnMessagesDeleted::kEventName); |
+ ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( |
+ this, api::gcm::OnSendError::kEventName); |
+} |
-GcmJsEventRouter::~GcmJsEventRouter() {} |
+GcmJsEventRouter::~GcmJsEventRouter() { |
+ ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
+} |
void GcmJsEventRouter::OnMessage( |
const std::string& app_id, |
@@ -223,4 +231,11 @@ void GcmJsEventRouter::OnSendError(const std::string& app_id, |
app_id, event.Pass()); |
} |
+void GcmJsEventRouter::OnListenerAdded(const EventListenerInfo& details) { |
+ if (gcm::GCMProfileService::GetGCMEnabledState(profile_) == |
+ gcm::GCMProfileService::ALWAYS_DISABLED) |
fgorski
2014/03/07 17:56:07
nit: {} would make it more clear, given that if ha
|
+ return; |
+ gcm::GCMProfileServiceFactory::GetForProfile(profile_)->Start(); |
+} |
+ |
} // namespace extensions |