| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/push_messaging/push_messaging_api.h" | 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 void PushMessagingEventRouter::OnMessage(const std::string& extension_id, | 99 void PushMessagingEventRouter::OnMessage(const std::string& extension_id, |
| 100 int subchannel, | 100 int subchannel, |
| 101 const std::string& payload) { | 101 const std::string& payload) { |
| 102 glue::Message message; | 102 glue::Message message; |
| 103 message.subchannel_id = subchannel; | 103 message.subchannel_id = subchannel; |
| 104 message.payload = payload; | 104 message.payload = payload; |
| 105 | 105 |
| 106 scoped_ptr<base::ListValue> args(glue::OnMessage::Create(message)); | 106 scoped_ptr<base::ListValue> args(glue::OnMessage::Create(message)); |
| 107 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 108 event_names::kOnPushMessage, args.Pass())); |
| 109 event->restrict_to_profile = profile_; |
| 107 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 110 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
| 108 extension_id, | 111 extension_id, event.Pass()); |
| 109 event_names::kOnPushMessage, | |
| 110 args.Pass(), | |
| 111 profile_, | |
| 112 GURL()); | |
| 113 } | 112 } |
| 114 | 113 |
| 115 void PushMessagingEventRouter::Observe( | 114 void PushMessagingEventRouter::Observe( |
| 116 int type, | 115 int type, |
| 117 const content::NotificationSource& source, | 116 const content::NotificationSource& source, |
| 118 const content::NotificationDetails& details) { | 117 const content::NotificationDetails& details) { |
| 119 switch (type) { | 118 switch (type) { |
| 120 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 119 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| 121 const Extension* extension = content::Details<Extension>(details).ptr(); | 120 const Extension* extension = content::Details<Extension>(details).ptr(); |
| 122 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { | 121 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // If the error message is blank, see if we can set it from the state. | 283 // If the error message is blank, see if we can set it from the state. |
| 285 if (error_text.empty() && | 284 if (error_text.empty() && |
| 286 (0 != error.state())) { | 285 (0 != error.state())) { |
| 287 error_text = base::IntToString(error.state()); | 286 error_text = base::IntToString(error.state()); |
| 288 } | 287 } |
| 289 | 288 |
| 290 ReportResult(std::string(), error_text); | 289 ReportResult(std::string(), error_text); |
| 291 } | 290 } |
| 292 | 291 |
| 293 } // namespace extensions | 292 } // namespace extensions |
| OLD | NEW |