OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_gcm_app_handler.h" | 5 #include "chrome/browser/extensions/extension_gcm_app_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 void ExtensionGCMAppHandler::ShutdownHandler() { | 70 void ExtensionGCMAppHandler::ShutdownHandler() { |
71 #if !defined(OS_ANDROID) | 71 #if !defined(OS_ANDROID) |
72 js_event_router_.reset(); | 72 js_event_router_.reset(); |
73 #endif | 73 #endif |
74 } | 74 } |
75 | 75 |
76 void ExtensionGCMAppHandler::OnMessage( | 76 void ExtensionGCMAppHandler::OnMessage( |
77 const std::string& app_id, | 77 const std::string& app_id, |
78 const gcm::GCMClient::IncomingMessage& message) { | 78 const gcm::IncomingMessage& message) { |
79 #if !defined(OS_ANDROID) | 79 #if !defined(OS_ANDROID) |
80 js_event_router_->OnMessage(app_id, message); | 80 js_event_router_->OnMessage(app_id, message); |
81 #endif | 81 #endif |
82 } | 82 } |
83 | 83 |
84 void ExtensionGCMAppHandler::OnMessagesDeleted(const std::string& app_id) { | 84 void ExtensionGCMAppHandler::OnMessagesDeleted(const std::string& app_id) { |
85 #if !defined(OS_ANDROID) | 85 #if !defined(OS_ANDROID) |
86 js_event_router_->OnMessagesDeleted(app_id); | 86 js_event_router_->OnMessagesDeleted(app_id); |
87 #endif | 87 #endif |
88 } | 88 } |
89 | 89 |
90 void ExtensionGCMAppHandler::OnSendError( | 90 void ExtensionGCMAppHandler::OnSendError( |
91 const std::string& app_id, | 91 const std::string& app_id, |
92 const gcm::GCMClient::SendErrorDetails& send_error_details) { | 92 const gcm::SendErrorDetails& send_error_details) { |
93 #if !defined(OS_ANDROID) | 93 #if !defined(OS_ANDROID) |
94 js_event_router_->OnSendError(app_id, send_error_details); | 94 js_event_router_->OnSendError(app_id, send_error_details); |
95 #endif | 95 #endif |
96 } | 96 } |
97 | 97 |
98 void ExtensionGCMAppHandler::OnExtensionLoaded( | 98 void ExtensionGCMAppHandler::OnExtensionLoaded( |
99 content::BrowserContext* browser_context, | 99 content::BrowserContext* browser_context, |
100 const Extension* extension) { | 100 const Extension* extension) { |
101 if (IsGCMPermissionEnabled(extension)) | 101 if (IsGCMPermissionEnabled(extension)) |
102 GetGCMProfileService()->AddAppHandler(extension->id(), this); | 102 GetGCMProfileService()->AddAppHandler(extension->id(), this); |
(...skipping 21 matching lines...) Expand all Loading... |
124 extension->id())); | 124 extension->id())); |
125 GetGCMProfileService()->RemoveAppHandler(extension->id()); | 125 GetGCMProfileService()->RemoveAppHandler(extension->id()); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 gcm::GCMProfileService* ExtensionGCMAppHandler::GetGCMProfileService() const { | 129 gcm::GCMProfileService* ExtensionGCMAppHandler::GetGCMProfileService() const { |
130 return gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 130 return gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
131 } | 131 } |
132 | 132 |
133 void ExtensionGCMAppHandler::OnUnregisterCompleted( | 133 void ExtensionGCMAppHandler::OnUnregisterCompleted( |
134 const std::string& app_id, gcm::GCMClient::Result result) { | 134 const std::string& app_id, gcm::Result result) { |
135 // Nothing to do. | 135 // Nothing to do. |
136 } | 136 } |
137 | 137 |
138 } // namespace extensions | 138 } // namespace extensions |
OLD | NEW |