| 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 "extensions/browser/event_router.h" | 5 #include "extensions/browser/event_router.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void* browser_context_id, | 96 void* browser_context_id, |
| 97 const std::string& extension_id, | 97 const std::string& extension_id, |
| 98 int event_id, | 98 int event_id, |
| 99 const std::string& event_name, | 99 const std::string& event_name, |
| 100 ListValue* event_args, | 100 ListValue* event_args, |
| 101 UserGestureState user_gesture, | 101 UserGestureState user_gesture, |
| 102 const EventFilteringInfo& info) { | 102 const EventFilteringInfo& info) { |
| 103 NotifyEventDispatched(browser_context_id, extension_id, event_name, | 103 NotifyEventDispatched(browser_context_id, extension_id, event_name, |
| 104 *event_args); | 104 *event_args); |
| 105 | 105 |
| 106 // TODO(chirantan): Make event dispatch a separate IPC so that it doesn't | 106 ExtensionMsg_DispatchEvent_Params params; |
| 107 // piggyback off MessageInvoke, which is used for other things. | 107 params.extension_id = extension_id; |
| 108 ListValue args; | 108 params.event_name = event_name; |
| 109 args.Set(0, new base::StringValue(event_name)); | 109 params.event_id = event_id; |
| 110 args.Set(1, event_args); | 110 params.is_user_gesture = user_gesture == USER_GESTURE_ENABLED; |
| 111 args.Set(2, info.AsValue().release()); | 111 params.filtering_info.Swap(info.AsValue().get()); |
| 112 args.Set(3, new base::FundamentalValue(event_id)); | |
| 113 ipc_sender->Send(new ExtensionMsg_MessageInvoke( | |
| 114 MSG_ROUTING_CONTROL, | |
| 115 extension_id, | |
| 116 kEventBindings, | |
| 117 "dispatchEvent", | |
| 118 args, | |
| 119 user_gesture == USER_GESTURE_ENABLED)); | |
| 120 | 112 |
| 121 // DispatchExtensionMessage does _not_ take ownership of event_args, so we | 113 ipc_sender->Send(new ExtensionMsg_DispatchEvent(params, *event_args)); |
| 122 // must ensure that the destruction of args does not attempt to free it. | |
| 123 std::unique_ptr<base::Value> removed_event_args; | |
| 124 args.Remove(1, &removed_event_args); | |
| 125 ignore_result(removed_event_args.release()); | |
| 126 } | 114 } |
| 127 | 115 |
| 128 // static | 116 // static |
| 129 EventRouter* EventRouter::Get(content::BrowserContext* browser_context) { | 117 EventRouter* EventRouter::Get(content::BrowserContext* browser_context) { |
| 130 return EventRouterFactory::GetForBrowserContext(browser_context); | 118 return EventRouterFactory::GetForBrowserContext(browser_context); |
| 131 } | 119 } |
| 132 | 120 |
| 133 // static | 121 // static |
| 134 std::string EventRouter::GetBaseEventName(const std::string& full_event_name) { | 122 std::string EventRouter::GetBaseEventName(const std::string& full_event_name) { |
| 135 size_t slash_sep = full_event_name.find('/'); | 123 size_t slash_sep = full_event_name.find('/'); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 const std::string& extension_id, | 882 const std::string& extension_id, |
| 895 const GURL& listener_url, | 883 const GURL& listener_url, |
| 896 content::BrowserContext* browser_context) | 884 content::BrowserContext* browser_context) |
| 897 : event_name(event_name), | 885 : event_name(event_name), |
| 898 extension_id(extension_id), | 886 extension_id(extension_id), |
| 899 listener_url(listener_url), | 887 listener_url(listener_url), |
| 900 browser_context(browser_context) { | 888 browser_context(browser_context) { |
| 901 } | 889 } |
| 902 | 890 |
| 903 } // namespace extensions | 891 } // namespace extensions |
| OLD | NEW |