| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 void GcmJsEventRouter::OnMessage( | 208 void GcmJsEventRouter::OnMessage( |
| 209 const std::string& app_id, | 209 const std::string& app_id, |
| 210 const gcm::GCMClient::IncomingMessage& message) { | 210 const gcm::GCMClient::IncomingMessage& message) { |
| 211 api::gcm::OnMessage::Message message_arg; | 211 api::gcm::OnMessage::Message message_arg; |
| 212 message_arg.data.additional_properties = message.data; | 212 message_arg.data.additional_properties = message.data; |
| 213 if (!message.sender_id.empty()) | 213 if (!message.sender_id.empty()) |
| 214 message_arg.from.reset(new std::string(message.sender_id)); | 214 message_arg.from.reset(new std::string(message.sender_id)); |
| 215 if (!message.collapse_key.empty()) | 215 if (!message.collapse_key.empty()) |
| 216 message_arg.collapse_key.reset(new std::string(message.collapse_key)); | 216 message_arg.collapse_key.reset(new std::string(message.collapse_key)); |
| 217 | 217 |
| 218 scoped_ptr<Event> event(new Event( | 218 scoped_ptr<Event> event( |
| 219 api::gcm::OnMessage::kEventName, | 219 new Event(events::UNKNOWN, api::gcm::OnMessage::kEventName, |
| 220 api::gcm::OnMessage::Create(message_arg).Pass(), | 220 api::gcm::OnMessage::Create(message_arg).Pass(), profile_)); |
| 221 profile_)); | |
| 222 EventRouter::Get(profile_)->DispatchEventToExtension(app_id, event.Pass()); | 221 EventRouter::Get(profile_)->DispatchEventToExtension(app_id, event.Pass()); |
| 223 } | 222 } |
| 224 | 223 |
| 225 void GcmJsEventRouter::OnMessagesDeleted(const std::string& app_id) { | 224 void GcmJsEventRouter::OnMessagesDeleted(const std::string& app_id) { |
| 226 scoped_ptr<Event> event(new Event( | 225 scoped_ptr<Event> event( |
| 227 api::gcm::OnMessagesDeleted::kEventName, | 226 new Event(events::UNKNOWN, api::gcm::OnMessagesDeleted::kEventName, |
| 228 api::gcm::OnMessagesDeleted::Create().Pass(), | 227 api::gcm::OnMessagesDeleted::Create().Pass(), profile_)); |
| 229 profile_)); | |
| 230 EventRouter::Get(profile_)->DispatchEventToExtension(app_id, event.Pass()); | 228 EventRouter::Get(profile_)->DispatchEventToExtension(app_id, event.Pass()); |
| 231 } | 229 } |
| 232 | 230 |
| 233 void GcmJsEventRouter::OnSendError( | 231 void GcmJsEventRouter::OnSendError( |
| 234 const std::string& app_id, | 232 const std::string& app_id, |
| 235 const gcm::GCMClient::SendErrorDetails& send_error_details) { | 233 const gcm::GCMClient::SendErrorDetails& send_error_details) { |
| 236 api::gcm::OnSendError::Error error; | 234 api::gcm::OnSendError::Error error; |
| 237 error.message_id.reset(new std::string(send_error_details.message_id)); | 235 error.message_id.reset(new std::string(send_error_details.message_id)); |
| 238 error.error_message = GcmResultToError(send_error_details.result); | 236 error.error_message = GcmResultToError(send_error_details.result); |
| 239 error.details.additional_properties = send_error_details.additional_data; | 237 error.details.additional_properties = send_error_details.additional_data; |
| 240 | 238 |
| 241 scoped_ptr<Event> event(new Event( | 239 scoped_ptr<Event> event( |
| 242 api::gcm::OnSendError::kEventName, | 240 new Event(events::UNKNOWN, api::gcm::OnSendError::kEventName, |
| 243 api::gcm::OnSendError::Create(error).Pass(), | 241 api::gcm::OnSendError::Create(error).Pass(), profile_)); |
| 244 profile_)); | |
| 245 EventRouter::Get(profile_)->DispatchEventToExtension(app_id, event.Pass()); | 242 EventRouter::Get(profile_)->DispatchEventToExtension(app_id, event.Pass()); |
| 246 } | 243 } |
| 247 | 244 |
| 248 } // namespace extensions | 245 } // namespace extensions |
| OLD | NEW |