[email protected] | 9e6720a | 2012-01-24 02:30:56 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 7 | |
| 8 | #include <map> |
| 9 | #include <set> |
| 10 | #include <string> |
[email protected] | f3270a0 | 2012-10-26 15:54:05 | [diff] [blame] | 11 | #include <utility> |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 12 | |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 13 | #include "base/callback.h" |
[email protected] | 1790275 | 2011-08-31 22:52:54 | [diff] [blame] | 14 | #include "base/compiler_specific.h" |
[email protected] | cf118b96 | 2012-12-11 03:08:22 | [diff] [blame] | 15 | #include "base/hash_tables.h" |
[email protected] | f72d0c6 | 2011-08-31 16:27:44 | [diff] [blame] | 16 | #include "base/memory/linked_ptr.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 17 | #include "base/memory/ref_counted.h" |
[email protected] | 8a16a03 | 2012-06-18 19:37:31 | [diff] [blame] | 18 | #include "base/values.h" |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 19 | #include "chrome/browser/extensions/event_listener_map.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 20 | #include "content/public/browser/notification_observer.h" |
| 21 | #include "content/public/browser/notification_registrar.h" |
[email protected] | 4b3e192 | 2013-02-12 04:45:58 | [diff] [blame] | 22 | #include "extensions/common/event_filtering_info.h" |
[email protected] | b44f8ad | 2012-06-15 20:52:58 | [diff] [blame] | 23 | #include "ipc/ipc_sender.h" |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 24 | |
| 25 | class GURL; |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 26 | class Profile; |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 27 | |
| 28 | namespace content { |
[email protected] | 7061be9 | 2013-02-18 15:44:02 | [diff] [blame^] | 29 | class BrowserContext; |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 30 | class RenderProcessHost; |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 31 | } |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 32 | |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 33 | namespace extensions { |
[email protected] | c2ed3f69 | 2013-01-31 20:37:36 | [diff] [blame] | 34 | class ActivityLog; |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 35 | class Extension; |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 36 | class ExtensionHost; |
[email protected] | 79cb81bb | 2012-09-20 02:23:31 | [diff] [blame] | 37 | class ExtensionPrefs; |
[email protected] | 3a1dc57 | 2012-07-31 22:25:13 | [diff] [blame] | 38 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 39 | struct Event; |
[email protected] | 954e1349 | 2012-11-15 03:18:23 | [diff] [blame] | 40 | struct EventListenerInfo; |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 41 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 42 | class EventRouter : public content::NotificationObserver, |
| 43 | public EventListenerMap::Delegate { |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 44 | public: |
[email protected] | b085856f | 2012-03-02 04:37:25 | [diff] [blame] | 45 | // These constants convey the state of our knowledge of whether we're in |
| 46 | // a user-caused gesture as part of DispatchEvent. |
| 47 | enum UserGestureState { |
| 48 | USER_GESTURE_UNKNOWN = 0, |
| 49 | USER_GESTURE_ENABLED = 1, |
| 50 | USER_GESTURE_NOT_ENABLED = 2, |
| 51 | }; |
| 52 | |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 53 | // Observers register interest in events with a particular name and are |
| 54 | // notified when a listener is added or removed for that |event_name|. |
| 55 | class Observer { |
| 56 | public: |
| 57 | // Called when a listener is added. |
[email protected] | 954e1349 | 2012-11-15 03:18:23 | [diff] [blame] | 58 | virtual void OnListenerAdded(const EventListenerInfo& details) {} |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 59 | // Called when a listener is removed. |
[email protected] | 954e1349 | 2012-11-15 03:18:23 | [diff] [blame] | 60 | virtual void OnListenerRemoved(const EventListenerInfo& details) {} |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 61 | }; |
| 62 | |
[email protected] | c9bd90f | 2012-08-07 23:58:15 | [diff] [blame] | 63 | // Sends an event via ipc_sender to the given extension. Can be called on any |
| 64 | // thread. |
[email protected] | b44f8ad | 2012-06-15 20:52:58 | [diff] [blame] | 65 | static void DispatchEvent(IPC::Sender* ipc_sender, |
[email protected] | c2ed3f69 | 2013-01-31 20:37:36 | [diff] [blame] | 66 | void* profile_id, |
[email protected] | c357acb4 | 2011-06-09 20:52:42 | [diff] [blame] | 67 | const std::string& extension_id, |
| 68 | const std::string& event_name, |
[email protected] | c9bd90f | 2012-08-07 23:58:15 | [diff] [blame] | 69 | scoped_ptr<base::ListValue> event_args, |
[email protected] | b085856f | 2012-03-02 04:37:25 | [diff] [blame] | 70 | const GURL& event_url, |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 71 | UserGestureState user_gesture, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 72 | const EventFilteringInfo& info); |
[email protected] | 5a7b5eaf | 2010-11-02 20:52:19 | [diff] [blame] | 73 | |
[email protected] | 79cb81bb | 2012-09-20 02:23:31 | [diff] [blame] | 74 | EventRouter(Profile* profile, ExtensionPrefs* extension_prefs); |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 75 | virtual ~EventRouter(); |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 76 | |
[email protected] | a7ab1b78 | 2010-10-21 23:24:16 | [diff] [blame] | 77 | // Add or remove the process/extension pair as a listener for |event_name|. |
| 78 | // Note that multiple extensions can share a process due to process |
| 79 | // collapsing. Also, a single extension can have 2 processes if it is a split |
| 80 | // mode extension. |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 81 | void AddEventListener(const std::string& event_name, |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 82 | content::RenderProcessHost* process, |
[email protected] | a7ab1b78 | 2010-10-21 23:24:16 | [diff] [blame] | 83 | const std::string& extension_id); |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 84 | void RemoveEventListener(const std::string& event_name, |
[email protected] | f3b1a08 | 2011-11-18 00:34:30 | [diff] [blame] | 85 | content::RenderProcessHost* process, |
[email protected] | a7ab1b78 | 2010-10-21 23:24:16 | [diff] [blame] | 86 | const std::string& extension_id); |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 87 | |
[email protected] | f34706be | 2012-09-04 07:32:09 | [diff] [blame] | 88 | EventListenerMap& listeners() { return listeners_; } |
| 89 | |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 90 | // Registers an observer to be notified when an event listener for |
| 91 | // |event_name| is added or removed. There can currently be only one observer |
| 92 | // for each distinct |event_name|. |
| 93 | void RegisterObserver(Observer* observer, |
| 94 | const std::string& event_name); |
| 95 | |
| 96 | // Unregisters an observer from all events. |
| 97 | void UnregisterObserver(Observer* observer); |
| 98 | |
[email protected] | 3653122 | 2012-02-07 19:41:27 | [diff] [blame] | 99 | // Add or remove the extension as having a lazy background page that listens |
| 100 | // to the event. The difference from the above methods is that these will be |
| 101 | // remembered even after the process goes away. We use this list to decide |
| 102 | // which extension pages to load when dispatching an event. |
| 103 | void AddLazyEventListener(const std::string& event_name, |
| 104 | const std::string& extension_id); |
| 105 | void RemoveLazyEventListener(const std::string& event_name, |
| 106 | const std::string& extension_id); |
| 107 | |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 108 | // If |add_lazy_listener| is true also add the lazy version of this listener. |
| 109 | void AddFilteredEventListener(const std::string& event_name, |
| 110 | content::RenderProcessHost* process, |
| 111 | const std::string& extension_id, |
| 112 | const base::DictionaryValue& filter, |
| 113 | bool add_lazy_listener); |
| 114 | |
| 115 | // If |remove_lazy_listener| is true also remove the lazy version of this |
| 116 | // listener. |
| 117 | void RemoveFilteredEventListener(const std::string& event_name, |
| 118 | content::RenderProcessHost* process, |
| 119 | const std::string& extension_id, |
| 120 | const base::DictionaryValue& filter, |
| 121 | bool remove_lazy_listener); |
| 122 | |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 123 | // Returns true if there is at least one listener for the given event. |
| 124 | bool HasEventListener(const std::string& event_name); |
| 125 | |
[email protected] | a7ab1b78 | 2010-10-21 23:24:16 | [diff] [blame] | 126 | // Returns true if the extension is listening to the given event. |
| 127 | bool ExtensionHasEventListener(const std::string& extension_id, |
| 128 | const std::string& event_name); |
| 129 | |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 130 | // Broadcasts an event to every listener registered for that event. |
| 131 | virtual void BroadcastEvent(scoped_ptr<Event> event); |
| 132 | |
| 133 | // Dispatches an event to the given extension. |
| 134 | virtual void DispatchEventToExtension(const std::string& extension_id, |
| 135 | scoped_ptr<Event> event); |
| 136 | |
[email protected] | 8910201 | 2011-11-01 21:23:56 | [diff] [blame] | 137 | // Record the Event Ack from the renderer. (One less event in-flight.) |
[email protected] | 7042b68 | 2012-04-19 22:57:51 | [diff] [blame] | 138 | void OnEventAck(Profile* profile, const std::string& extension_id); |
[email protected] | 8910201 | 2011-11-01 21:23:56 | [diff] [blame] | 139 | |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 140 | private: |
[email protected] | 61f5fc8 | 2012-02-15 20:10:45 | [diff] [blame] | 141 | // The extension and process that contains the event listener for a given |
| 142 | // event. |
| 143 | struct ListenerProcess; |
| 144 | |
| 145 | // A map between an event name and a set of extensions that are listening |
| 146 | // to that event. |
| 147 | typedef std::map<std::string, std::set<ListenerProcess> > ListenerMap; |
[email protected] | a7ab1b78 | 2010-10-21 23:24:16 | [diff] [blame] | 148 | |
[email protected] | f3270a0 | 2012-10-26 15:54:05 | [diff] [blame] | 149 | // An identifier for an event dispatch that is used to prevent double dispatch |
| 150 | // due to race conditions between the direct and lazy dispatch paths. |
| 151 | typedef std::pair<const content::BrowserContext*, std::string> |
| 152 | EventDispatchIdentifier; |
| 153 | |
[email protected] | c2ed3f69 | 2013-01-31 20:37:36 | [diff] [blame] | 154 | // Records an event notification in the extension activity log. Can be |
| 155 | // called from any thread. |
| 156 | static void LogExtensionEventMessage(void* profile_id, |
| 157 | const std::string& extension_id, |
| 158 | const std::string& event_name, |
| 159 | scoped_ptr<ListValue> event_args); |
| 160 | |
[email protected] | c9bd90f | 2012-08-07 23:58:15 | [diff] [blame] | 161 | // TODO(gdk): Document this. |
| 162 | static void DispatchExtensionMessage( |
| 163 | IPC::Sender* ipc_sender, |
[email protected] | c2ed3f69 | 2013-01-31 20:37:36 | [diff] [blame] | 164 | void* profile_id, |
[email protected] | c9bd90f | 2012-08-07 23:58:15 | [diff] [blame] | 165 | const std::string& extension_id, |
| 166 | const std::string& event_name, |
| 167 | base::ListValue* event_args, |
| 168 | const GURL& event_url, |
| 169 | UserGestureState user_gesture, |
| 170 | const extensions::EventFilteringInfo& info); |
| 171 | |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 172 | virtual void Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 173 | const content::NotificationSource& source, |
| 174 | const content::NotificationDetails& details) OVERRIDE; |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 175 | |
[email protected] | 61f5fc8 | 2012-02-15 20:10:45 | [diff] [blame] | 176 | // Returns true if the given listener map contains a event listeners for |
| 177 | // the given event. If |extension_id| is non-empty, we also check that that |
| 178 | // extension is one of the listeners. |
| 179 | bool HasEventListenerImpl(const ListenerMap& listeners, |
| 180 | const std::string& extension_id, |
| 181 | const std::string& event_name); |
| 182 | |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 183 | // Shared by DispatchEvent*. If |restrict_to_extension_id| is empty, the |
| 184 | // event is broadcast. |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 185 | // An event that just came off the pending list may not be delayed again. |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 186 | void DispatchEventImpl(const std::string& restrict_to_extension_id, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 187 | const linked_ptr<Event>& event); |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 188 | |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 189 | // Ensures that all lazy background pages that are interested in the given |
| 190 | // event are loaded, and queues the event if the page is not ready yet. |
[email protected] | f3270a0 | 2012-10-26 15:54:05 | [diff] [blame] | 191 | // Inserts an EventDispatchIdentifier into |already_dispatched| for each lazy |
| 192 | // event dispatch that is queued. |
| 193 | void DispatchLazyEvent(const std::string& extension_id, |
| 194 | const linked_ptr<Event>& event, |
| 195 | std::set<EventDispatchIdentifier>* already_dispatched); |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 196 | |
| 197 | // Dispatches the event to the specified extension running in |process|. |
| 198 | void DispatchEventToProcess(const std::string& extension_id, |
| 199 | content::RenderProcessHost* process, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 200 | const linked_ptr<Event>& event); |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 201 | |
| 202 | // Returns false when the event is scoped to a profile and the listening |
| 203 | // extension does not have access to events from that profile. Also fills |
| 204 | // |event_args| with the proper arguments to send, which may differ if |
| 205 | // the event crosses the incognito boundary. |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 206 | bool CanDispatchEventToProfile(Profile* profile, |
| 207 | const Extension* extension, |
[email protected] | c43ff6a | 2012-12-10 19:36:24 | [diff] [blame] | 208 | const linked_ptr<Event>& event); |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 209 | |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 210 | // Possibly loads given extension's background page in preparation to |
[email protected] | 6b52757 | 2012-10-12 18:00:43 | [diff] [blame] | 211 | // dispatch an event. Returns true if the event was queued for subsequent |
| 212 | // dispatch, false otherwise. |
| 213 | bool MaybeLoadLazyBackgroundPageToDispatchEvent( |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 214 | Profile* profile, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 215 | const Extension* extension, |
| 216 | const linked_ptr<Event>& event); |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 217 | |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 218 | // Track of the number of dispatched events that have not yet sent an |
| 219 | // ACK from the renderer. |
[email protected] | 1c321ee5 | 2012-05-21 03:02:34 | [diff] [blame] | 220 | void IncrementInFlightEvents(Profile* profile, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 221 | const Extension* extension); |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 222 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 223 | void DispatchPendingEvent(const linked_ptr<Event>& event, |
[email protected] | b6536df | 2012-03-16 18:55:23 | [diff] [blame] | 224 | ExtensionHost* host); |
[email protected] | fb6ff23b | 2012-03-13 23:13:42 | [diff] [blame] | 225 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 226 | // Implementation of EventListenerMap::Delegate. |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 227 | virtual void OnListenerAdded(const EventListener* listener) OVERRIDE; |
| 228 | virtual void OnListenerRemoved(const EventListener* listener) OVERRIDE; |
| 229 | |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 230 | Profile* profile_; |
| 231 | |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 232 | content::NotificationRegistrar registrar_; |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 233 | |
[email protected] | d81d3a19 | 2012-11-09 00:32:50 | [diff] [blame] | 234 | EventListenerMap listeners_; |
[email protected] | 58c9095 | 2012-11-09 00:03:30 | [diff] [blame] | 235 | |
[email protected] | cf118b96 | 2012-12-11 03:08:22 | [diff] [blame] | 236 | typedef base::hash_map<std::string, Observer*> ObserverMap; |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 237 | ObserverMap observers_; |
| 238 | |
[email protected] | c2ed3f69 | 2013-01-31 20:37:36 | [diff] [blame] | 239 | ActivityLog* activity_log_; |
| 240 | |
[email protected] | 79cb81bb | 2012-09-20 02:23:31 | [diff] [blame] | 241 | // True if we should dispatch the event signalling that Chrome was updated |
| 242 | // upon loading an extension. |
| 243 | bool dispatch_chrome_updated_event_; |
| 244 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 245 | DISALLOW_COPY_AND_ASSIGN(EventRouter); |
[email protected] | 2c69965 | 2010-10-15 18:22:41 | [diff] [blame] | 246 | }; |
| 247 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 248 | struct Event { |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 249 | typedef base::Callback< |
| 250 | void(Profile*, const Extension*, base::ListValue*)> WillDispatchCallback; |
| 251 | |
| 252 | // The event to dispatch. |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 253 | std::string event_name; |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 254 | |
| 255 | // Arguments to send to the event listener. |
[email protected] | c9bd90f | 2012-08-07 23:58:15 | [diff] [blame] | 256 | scoped_ptr<base::ListValue> event_args; |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 257 | |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 258 | // If non-NULL, then the event will not be sent to other profiles unless the |
| 259 | // extension has permission (e.g. incognito tab update -> normal profile only |
| 260 | // works if extension is allowed incognito access). |
| 261 | Profile* restrict_to_profile; |
| 262 | |
| 263 | // If not empty, the event is only sent to extensions with host permissions |
| 264 | // for this url. |
| 265 | GURL event_url; |
| 266 | |
| 267 | // Whether a user gesture triggered the event. |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 268 | EventRouter::UserGestureState user_gesture; |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 269 | |
| 270 | // Extra information used to filter which events are sent to the listener. |
| 271 | EventFilteringInfo filter_info; |
| 272 | |
| 273 | // If specified, this is called before dispatching an event to each |
| 274 | // extension. The third argument is a mutable reference to event_args, |
| 275 | // allowing the caller to provide different arguments depending on the |
| 276 | // extension and profile. This is guaranteed to be called synchronously with |
| 277 | // DispatchEvent, so callers don't need to worry about lifetime. |
| 278 | WillDispatchCallback will_dispatch_callback; |
| 279 | |
| 280 | Event(const std::string& event_name, |
| 281 | scoped_ptr<base::ListValue> event_args); |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 282 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 283 | Event(const std::string& event_name, |
[email protected] | c9bd90f | 2012-08-07 23:58:15 | [diff] [blame] | 284 | scoped_ptr<base::ListValue> event_args, |
[email protected] | f0eb58a | 2012-12-17 22:10:49 | [diff] [blame] | 285 | Profile* restrict_to_profile); |
| 286 | |
| 287 | Event(const std::string& event_name, |
| 288 | scoped_ptr<base::ListValue> event_args, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 289 | Profile* restrict_to_profile, |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 290 | const GURL& event_url, |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 291 | EventRouter::UserGestureState user_gesture, |
| 292 | const EventFilteringInfo& info); |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 293 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 294 | ~Event(); |
[email protected] | 6e85092 | 2012-12-05 03:22:48 | [diff] [blame] | 295 | |
| 296 | // Makes a deep copy of this instance. Ownership is transferred to the |
| 297 | // caller. |
| 298 | Event* DeepCopy(); |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 299 | }; |
| 300 | |
[email protected] | 954e1349 | 2012-11-15 03:18:23 | [diff] [blame] | 301 | struct EventListenerInfo { |
| 302 | EventListenerInfo(const std::string& event_name, |
| 303 | const std::string& extension_id); |
| 304 | |
| 305 | const std::string event_name; |
| 306 | const std::string extension_id; |
| 307 | }; |
| 308 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 309 | } // namespace extensions |
[email protected] | d9e559d | 2012-07-05 01:04:57 | [diff] [blame] | 310 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 311 | #endif // CHROME_BROWSER_EXTENSIONS_EVENT_ROUTER_H_ |