blob: e93110d3f7c7f8544faf8bcb02fb2f09097529b1 [file] [log] [blame]
[email protected]9e6720a2012-01-24 02:30:561// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]2c699652010-10-15 18:22:412// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]34423532013-11-21 18:13:105#ifndef EXTENSIONS_BROWSER_EVENT_ROUTER_H_
6#define EXTENSIONS_BROWSER_EVENT_ROUTER_H_
[email protected]2c699652010-10-15 18:22:417
8#include <map>
9#include <set>
10#include <string>
[email protected]f3270a02012-10-26 15:54:0511#include <utility>
[email protected]2c699652010-10-15 18:22:4112
[email protected]6e850922012-12-05 03:22:4813#include "base/callback.h"
[email protected]17902752011-08-31 22:52:5414#include "base/compiler_specific.h"
[email protected]14c1c232013-06-11 17:52:4415#include "base/containers/hash_tables.h"
avic9cec102015-12-23 00:39:2616#include "base/macros.h"
[email protected]f72d0c62011-08-31 16:27:4417#include "base/memory/linked_ptr.h"
[email protected]3b63f8f42011-03-28 01:54:1518#include "base/memory/ref_counted.h"
[email protected]4243f9a2014-08-04 18:53:1219#include "base/scoped_observer.h"
[email protected]8a16a032012-06-18 19:37:3120#include "base/values.h"
juncaicf523332015-06-04 00:14:0421#include "components/keyed_service/core/keyed_service.h"
[email protected]6c2381d2011-10-19 02:52:5322#include "content/public/browser/notification_observer.h"
23#include "content/public/browser/notification_registrar.h"
amistry69e9ee422015-05-22 07:40:2524#include "content/public/browser/render_process_host_observer.h"
[email protected]a0e26d42013-11-20 07:04:0425#include "extensions/browser/event_listener_map.h"
kalmanf1b4d782015-06-24 21:14:0526#include "extensions/browser/extension_event_histogram_value.h"
[email protected]4243f9a2014-08-04 18:53:1227#include "extensions/browser/extension_registry_observer.h"
[email protected]4b3e1922013-02-12 04:45:5828#include "extensions/common/event_filtering_info.h"
[email protected]b44f8ad2012-06-15 20:52:5829#include "ipc/ipc_sender.h"
kalmana9f6e67a2015-08-11 00:22:5030#include "url/gurl.h"
[email protected]2c699652010-10-15 18:22:4131
32class GURL;
[email protected]45fd94172013-11-13 03:29:5233class PrefService;
[email protected]f3b1a082011-11-18 00:34:3034
35namespace content {
[email protected]7061be92013-02-18 15:44:0236class BrowserContext;
[email protected]2c699652010-10-15 18:22:4137class RenderProcessHost;
[email protected]f3b1a082011-11-18 00:34:3038}
[email protected]2c699652010-10-15 18:22:4139
[email protected]1c321ee52012-05-21 03:02:3440namespace extensions {
[email protected]c2ed3f692013-01-31 20:37:3641class ActivityLog;
[email protected]1c321ee52012-05-21 03:02:3442class Extension;
[email protected]3a1dc572012-07-31 22:25:1343class ExtensionHost;
[email protected]79cb81bb2012-09-20 02:23:3144class ExtensionPrefs;
[email protected]4243f9a2014-08-04 18:53:1245class ExtensionRegistry;
[email protected]3a1dc572012-07-31 22:25:1346
[email protected]5a38dfd2012-07-23 23:22:1047struct Event;
[email protected]72e280f92013-11-20 02:02:3448struct EventDispatchInfo;
[email protected]954e13492012-11-15 03:18:2349struct EventListenerInfo;
[email protected]1c321ee52012-05-21 03:02:3450
juncaicf523332015-06-04 00:14:0451class EventRouter : public KeyedService,
52 public content::NotificationObserver,
[email protected]4243f9a2014-08-04 18:53:1253 public ExtensionRegistryObserver,
amistry69e9ee422015-05-22 07:40:2554 public EventListenerMap::Delegate,
55 public content::RenderProcessHostObserver {
[email protected]2c699652010-10-15 18:22:4156 public:
[email protected]b085856f2012-03-02 04:37:2557 // These constants convey the state of our knowledge of whether we're in
58 // a user-caused gesture as part of DispatchEvent.
59 enum UserGestureState {
60 USER_GESTURE_UNKNOWN = 0,
61 USER_GESTURE_ENABLED = 1,
62 USER_GESTURE_NOT_ENABLED = 2,
63 };
64
[email protected]e74d43c72013-05-17 19:01:4165 // The pref key for the list of event names for which an extension has
66 // registered from its lazy background page.
67 static const char kRegisteredEvents[];
68
[email protected]c4dc5cc2012-11-09 08:48:3969 // Observers register interest in events with a particular name and are
[email protected]c761a962013-11-20 04:19:4170 // notified when a listener is added or removed. Observers are matched by
71 // the base name of the event (e.g. adding an event listener for event name
72 // "foo.onBar/123" will trigger observers registered for "foo.onBar").
[email protected]c4dc5cc2012-11-09 08:48:3973 class Observer {
74 public:
75 // Called when a listener is added.
[email protected]954e13492012-11-15 03:18:2376 virtual void OnListenerAdded(const EventListenerInfo& details) {}
[email protected]c4dc5cc2012-11-09 08:48:3977 // Called when a listener is removed.
[email protected]954e13492012-11-15 03:18:2378 virtual void OnListenerRemoved(const EventListenerInfo& details) {}
[email protected]c4dc5cc2012-11-09 08:48:3979 };
80
[email protected]3a368a22014-03-26 19:29:1981 // Gets the EventRouter for |browser_context|.
[email protected]3a368a22014-03-26 19:29:1982 static EventRouter* Get(content::BrowserContext* browser_context);
83
[email protected]c761a962013-11-20 04:19:4184 // Converts event names like "foo.onBar/123" into "foo.onBar". Event names
85 // without a "/" are returned unchanged.
86 static std::string GetBaseEventName(const std::string& full_event_name);
87
[email protected]c9bd90f2012-08-07 23:58:1588 // Sends an event via ipc_sender to the given extension. Can be called on any
89 // thread.
kalmana9f6e67a2015-08-11 00:22:5090 //
91 // It is very rare to call this function directly. Instead use the instance
92 // methods BroadcastEvent or DispatchEventToExtension.
93 static void DispatchEventToSender(IPC::Sender* ipc_sender,
94 void* browser_context_id,
95 const std::string& extension_id,
96 events::HistogramValue histogram_value,
97 const std::string& event_name,
98 scoped_ptr<base::ListValue> event_args,
99 UserGestureState user_gesture,
100 const EventFilteringInfo& info);
[email protected]5a7b5eaf2010-11-02 20:52:19101
[email protected]45fd94172013-11-13 03:29:52102 // An EventRouter is shared between |browser_context| and its associated
103 // incognito context. |extension_prefs| may be NULL in tests.
104 EventRouter(content::BrowserContext* browser_context,
105 ExtensionPrefs* extension_prefs);
dcheng9168b2f2014-10-21 12:38:24106 ~EventRouter() override;
[email protected]2c699652010-10-15 18:22:41107
[email protected]c1abb3232014-07-30 18:28:39108 // Add or remove an extension as an event listener for |event_name|.
109 //
[email protected]a7ab1b782010-10-21 23:24:16110 // Note that multiple extensions can share a process due to process
111 // collapsing. Also, a single extension can have 2 processes if it is a split
112 // mode extension.
[email protected]2c699652010-10-15 18:22:41113 void AddEventListener(const std::string& event_name,
[email protected]f3b1a082011-11-18 00:34:30114 content::RenderProcessHost* process,
[email protected]a7ab1b782010-10-21 23:24:16115 const std::string& extension_id);
[email protected]2c699652010-10-15 18:22:41116 void RemoveEventListener(const std::string& event_name,
[email protected]f3b1a082011-11-18 00:34:30117 content::RenderProcessHost* process,
[email protected]a7ab1b782010-10-21 23:24:16118 const std::string& extension_id);
[email protected]2c699652010-10-15 18:22:41119
[email protected]c1abb3232014-07-30 18:28:39120 // Add or remove a URL as an event listener for |event_name|.
121 void AddEventListenerForURL(const std::string& event_name,
122 content::RenderProcessHost* process,
123 const GURL& listener_url);
124 void RemoveEventListenerForURL(const std::string& event_name,
125 content::RenderProcessHost* process,
126 const GURL& listener_url);
127
[email protected]f34706be2012-09-04 07:32:09128 EventListenerMap& listeners() { return listeners_; }
129
[email protected]c4dc5cc2012-11-09 08:48:39130 // Registers an observer to be notified when an event listener for
131 // |event_name| is added or removed. There can currently be only one observer
132 // for each distinct |event_name|.
133 void RegisterObserver(Observer* observer,
134 const std::string& event_name);
135
136 // Unregisters an observer from all events.
137 void UnregisterObserver(Observer* observer);
138
[email protected]36531222012-02-07 19:41:27139 // Add or remove the extension as having a lazy background page that listens
140 // to the event. The difference from the above methods is that these will be
141 // remembered even after the process goes away. We use this list to decide
142 // which extension pages to load when dispatching an event.
143 void AddLazyEventListener(const std::string& event_name,
144 const std::string& extension_id);
145 void RemoveLazyEventListener(const std::string& event_name,
146 const std::string& extension_id);
147
[email protected]d9e559d2012-07-05 01:04:57148 // If |add_lazy_listener| is true also add the lazy version of this listener.
149 void AddFilteredEventListener(const std::string& event_name,
150 content::RenderProcessHost* process,
151 const std::string& extension_id,
152 const base::DictionaryValue& filter,
153 bool add_lazy_listener);
154
155 // If |remove_lazy_listener| is true also remove the lazy version of this
156 // listener.
157 void RemoveFilteredEventListener(const std::string& event_name,
158 content::RenderProcessHost* process,
159 const std::string& extension_id,
160 const base::DictionaryValue& filter,
161 bool remove_lazy_listener);
162
[email protected]2c699652010-10-15 18:22:41163 // Returns true if there is at least one listener for the given event.
164 bool HasEventListener(const std::string& event_name);
165
[email protected]a7ab1b782010-10-21 23:24:16166 // Returns true if the extension is listening to the given event.
asargentd50b18c2016-04-21 01:17:16167 virtual bool ExtensionHasEventListener(const std::string& extension_id,
168 const std::string& event_name);
[email protected]a7ab1b782010-10-21 23:24:16169
[email protected]e74d43c72013-05-17 19:01:41170 // Return or set the list of events for which the given extension has
171 // registered.
172 std::set<std::string> GetRegisteredEvents(const std::string& extension_id);
173 void SetRegisteredEvents(const std::string& extension_id,
174 const std::set<std::string>& events);
175
[email protected]6e850922012-12-05 03:22:48176 // Broadcasts an event to every listener registered for that event.
177 virtual void BroadcastEvent(scoped_ptr<Event> event);
178
179 // Dispatches an event to the given extension.
180 virtual void DispatchEventToExtension(const std::string& extension_id,
181 scoped_ptr<Event> event);
182
[email protected]42d24742013-07-23 05:25:55183 // Dispatches |event| to the given extension as if the extension has a lazy
184 // listener for it. NOTE: This should be used rarely, for dispatching events
185 // to extensions that haven't had a chance to add their own listeners yet, eg:
186 // newly installed extensions.
187 void DispatchEventWithLazyListener(const std::string& extension_id,
188 scoped_ptr<Event> event);
189
[email protected]89102012011-11-01 21:23:56190 // Record the Event Ack from the renderer. (One less event in-flight.)
[email protected]45fd94172013-11-13 03:29:52191 void OnEventAck(content::BrowserContext* context,
192 const std::string& extension_id);
[email protected]89102012011-11-01 21:23:56193
kalmana9f6e67a2015-08-11 00:22:50194 // Reports UMA for an event dispatched to |extension| with histogram value
195 // |histogram_value|. Must be called on the UI thread.
196 //
197 // |did_enqueue| should be true if the event was queued waiting for a process
198 // to start, like an event page.
199 void ReportEvent(events::HistogramValue histogram_value,
200 const Extension* extension,
201 bool did_enqueue);
202
[email protected]fb6ff23b2012-03-13 23:13:42203 private:
[email protected]c1abb3232014-07-30 18:28:39204 friend class EventRouterTest;
[email protected]c761a962013-11-20 04:19:41205
[email protected]61f5fc82012-02-15 20:10:45206 // The extension and process that contains the event listener for a given
207 // event.
208 struct ListenerProcess;
209
210 // A map between an event name and a set of extensions that are listening
211 // to that event.
212 typedef std::map<std::string, std::set<ListenerProcess> > ListenerMap;
[email protected]a7ab1b782010-10-21 23:24:16213
[email protected]f3270a02012-10-26 15:54:05214 // An identifier for an event dispatch that is used to prevent double dispatch
215 // due to race conditions between the direct and lazy dispatch paths.
216 typedef std::pair<const content::BrowserContext*, std::string>
217 EventDispatchIdentifier;
218
[email protected]c9bd90f2012-08-07 23:58:15219 // TODO(gdk): Document this.
220 static void DispatchExtensionMessage(
221 IPC::Sender* ipc_sender,
[email protected]513b8032013-11-18 07:47:49222 void* browser_context_id,
[email protected]c9bd90f2012-08-07 23:58:15223 const std::string& extension_id,
chirantan669993c2015-03-05 23:38:33224 int event_id,
[email protected]c9bd90f2012-08-07 23:58:15225 const std::string& event_name,
226 base::ListValue* event_args,
[email protected]c9bd90f2012-08-07 23:58:15227 UserGestureState user_gesture,
228 const extensions::EventFilteringInfo& info);
229
dcheng9168b2f2014-10-21 12:38:24230 void Observe(int type,
231 const content::NotificationSource& source,
232 const content::NotificationDetails& details) override;
[email protected]4243f9a2014-08-04 18:53:12233 // ExtensionRegistryObserver implementation.
dcheng9168b2f2014-10-21 12:38:24234 void OnExtensionLoaded(content::BrowserContext* browser_context,
235 const Extension* extension) override;
236 void OnExtensionUnloaded(content::BrowserContext* browser_context,
237 const Extension* extension,
238 UnloadedExtensionInfo::Reason reason) override;
[email protected]2c699652010-10-15 18:22:41239
[email protected]61f5fc82012-02-15 20:10:45240 // Returns true if the given listener map contains a event listeners for
241 // the given event. If |extension_id| is non-empty, we also check that that
242 // extension is one of the listeners.
243 bool HasEventListenerImpl(const ListenerMap& listeners,
244 const std::string& extension_id,
245 const std::string& event_name);
246
kalmana9f6e67a2015-08-11 00:22:50247 // Shared by all event dispatch methods. If |restrict_to_extension_id| is
248 // empty, the event is broadcast. An event that just came off the pending
249 // list may not be delayed again.
[email protected]d9e559d2012-07-05 01:04:57250 void DispatchEventImpl(const std::string& restrict_to_extension_id,
[email protected]5a38dfd2012-07-23 23:22:10251 const linked_ptr<Event>& event);
[email protected]fb6ff23b2012-03-13 23:13:42252
[email protected]d9e559d2012-07-05 01:04:57253 // Ensures that all lazy background pages that are interested in the given
254 // event are loaded, and queues the event if the page is not ready yet.
[email protected]f3270a02012-10-26 15:54:05255 // Inserts an EventDispatchIdentifier into |already_dispatched| for each lazy
256 // event dispatch that is queued.
257 void DispatchLazyEvent(const std::string& extension_id,
258 const linked_ptr<Event>& event,
lionel.g.landwerlinb87f1c9c2015-07-27 16:53:14259 std::set<EventDispatchIdentifier>* already_dispatched,
260 const base::DictionaryValue* listener_filter);
[email protected]d9e559d2012-07-05 01:04:57261
[email protected]c1abb3232014-07-30 18:28:39262 // Dispatches the event to the specified extension or URL running in
263 // |process|.
[email protected]d9e559d2012-07-05 01:04:57264 void DispatchEventToProcess(const std::string& extension_id,
[email protected]c1abb3232014-07-30 18:28:39265 const GURL& listener_url,
[email protected]d9e559d2012-07-05 01:04:57266 content::RenderProcessHost* process,
lionel.g.landwerlinb87f1c9c2015-07-27 16:53:14267 const linked_ptr<Event>& event,
kalmana9f6e67a2015-08-11 00:22:50268 const base::DictionaryValue* listener_filter,
269 bool did_enqueue);
[email protected]fb6ff23b2012-03-13 23:13:42270
[email protected]45fd94172013-11-13 03:29:52271 // Returns false when the event is scoped to a context and the listening
272 // extension does not have access to events from that context. Also fills
[email protected]fb6ff23b2012-03-13 23:13:42273 // |event_args| with the proper arguments to send, which may differ if
274 // the event crosses the incognito boundary.
[email protected]45fd94172013-11-13 03:29:52275 bool CanDispatchEventToBrowserContext(content::BrowserContext* context,
276 const Extension* extension,
277 const linked_ptr<Event>& event);
[email protected]fb6ff23b2012-03-13 23:13:42278
[email protected]fb6ff23b2012-03-13 23:13:42279 // Possibly loads given extension's background page in preparation to
[email protected]6b527572012-10-12 18:00:43280 // dispatch an event. Returns true if the event was queued for subsequent
281 // dispatch, false otherwise.
282 bool MaybeLoadLazyBackgroundPageToDispatchEvent(
[email protected]45fd94172013-11-13 03:29:52283 content::BrowserContext* context,
[email protected]5a38dfd2012-07-23 23:22:10284 const Extension* extension,
lionel.g.landwerlinb87f1c9c2015-07-27 16:53:14285 const linked_ptr<Event>& event,
286 const base::DictionaryValue* listener_filter);
[email protected]fb6ff23b2012-03-13 23:13:42287
[email protected]e74d43c72013-05-17 19:01:41288 // Adds a filter to an event.
289 void AddFilterToEvent(const std::string& event_name,
290 const std::string& extension_id,
291 const base::DictionaryValue* filter);
292
293 // Removes a filter from an event.
294 void RemoveFilterFromEvent(const std::string& event_name,
295 const std::string& extension_id,
296 const base::DictionaryValue* filter);
297
298 // Returns the dictionary of event filters that the given extension has
299 // registered.
300 const base::DictionaryValue* GetFilteredEvents(
301 const std::string& extension_id);
302
chirantan669993c2015-03-05 23:38:33303 // Track the dispatched events that have not yet sent an ACK from the
304 // renderer.
[email protected]45fd94172013-11-13 03:29:52305 void IncrementInFlightEvents(content::BrowserContext* context,
chirantan669993c2015-03-05 23:38:33306 const Extension* extension,
307 int event_id,
308 const std::string& event_name);
[email protected]fb6ff23b2012-03-13 23:13:42309
[email protected]db9f2142013-05-27 22:56:16310 // static
kalmana9f6e67a2015-08-11 00:22:50311 static void DoDispatchEventToSenderBookkeepingOnUI(
312 void* browser_context_id,
313 const std::string& extension_id,
314 int event_id,
315 events::HistogramValue histogram_value,
316 const std::string& event_name);
[email protected]db9f2142013-05-27 22:56:16317
[email protected]5a38dfd2012-07-23 23:22:10318 void DispatchPendingEvent(const linked_ptr<Event>& event,
[email protected]b6536df2012-03-16 18:55:23319 ExtensionHost* host);
[email protected]fb6ff23b2012-03-13 23:13:42320
[email protected]5a38dfd2012-07-23 23:22:10321 // Implementation of EventListenerMap::Delegate.
dcheng9168b2f2014-10-21 12:38:24322 void OnListenerAdded(const EventListener* listener) override;
323 void OnListenerRemoved(const EventListener* listener) override;
[email protected]d9e559d2012-07-05 01:04:57324
amistry69e9ee422015-05-22 07:40:25325 // RenderProcessHostObserver implementation.
326 void RenderProcessExited(content::RenderProcessHost* host,
327 base::TerminationStatus status,
328 int exit_code) override;
329 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
330
[email protected]45fd94172013-11-13 03:29:52331 content::BrowserContext* browser_context_;
332
[email protected]513b8032013-11-18 07:47:49333 // The ExtensionPrefs associated with |browser_context_|. May be NULL in
334 // tests.
[email protected]45fd94172013-11-13 03:29:52335 ExtensionPrefs* extension_prefs_;
[email protected]2c699652010-10-15 18:22:41336
[email protected]6c2381d2011-10-19 02:52:53337 content::NotificationRegistrar registrar_;
[email protected]2c699652010-10-15 18:22:41338
[email protected]4243f9a2014-08-04 18:53:12339 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
340 extension_registry_observer_;
341
[email protected]d81d3a192012-11-09 00:32:50342 EventListenerMap listeners_;
[email protected]58c90952012-11-09 00:03:30343
[email protected]c761a962013-11-20 04:19:41344 // Map from base event name to observer.
[email protected]cf118b962012-12-11 03:08:22345 typedef base::hash_map<std::string, Observer*> ObserverMap;
[email protected]c4dc5cc2012-11-09 08:48:39346 ObserverMap observers_;
347
amistry69e9ee422015-05-22 07:40:25348 std::set<content::RenderProcessHost*> observed_process_set_;
349
[email protected]5a38dfd2012-07-23 23:22:10350 DISALLOW_COPY_AND_ASSIGN(EventRouter);
[email protected]2c699652010-10-15 18:22:41351};
352
[email protected]5a38dfd2012-07-23 23:22:10353struct Event {
reillyg5464e7e2014-12-11 00:35:08354 // This callback should return true if the event should be dispatched to the
355 // given context and extension, and false otherwise.
356 typedef base::Callback<bool(content::BrowserContext*,
[email protected]45fd94172013-11-13 03:29:52357 const Extension*,
lionel.g.landwerlin7b464ad2015-08-11 20:59:09358 Event*,
lionel.g.landwerlinb87f1c9c2015-07-27 16:53:14359 const base::DictionaryValue*)>
360 WillDispatchCallback;
[email protected]6e850922012-12-05 03:22:48361
kalmanf1b4d782015-06-24 21:14:05362 // The identifier for the event, for histograms. In most cases this
363 // correlates 1:1 with |event_name|, in some cases events will generate
364 // their own names, but they cannot generate their own identifier.
365 events::HistogramValue histogram_value;
366
[email protected]6e850922012-12-05 03:22:48367 // The event to dispatch.
[email protected]d9e559d2012-07-05 01:04:57368 std::string event_name;
[email protected]6e850922012-12-05 03:22:48369
370 // Arguments to send to the event listener.
[email protected]c9bd90f2012-08-07 23:58:15371 scoped_ptr<base::ListValue> event_args;
[email protected]6e850922012-12-05 03:22:48372
[email protected]45fd94172013-11-13 03:29:52373 // If non-NULL, then the event will not be sent to other BrowserContexts
374 // unless the extension has permission (e.g. incognito tab update -> normal
375 // tab only works if extension is allowed incognito access).
376 content::BrowserContext* restrict_to_browser_context;
[email protected]6e850922012-12-05 03:22:48377
378 // If not empty, the event is only sent to extensions with host permissions
379 // for this url.
380 GURL event_url;
381
382 // Whether a user gesture triggered the event.
[email protected]5a38dfd2012-07-23 23:22:10383 EventRouter::UserGestureState user_gesture;
[email protected]6e850922012-12-05 03:22:48384
385 // Extra information used to filter which events are sent to the listener.
386 EventFilteringInfo filter_info;
387
388 // If specified, this is called before dispatching an event to each
389 // extension. The third argument is a mutable reference to event_args,
390 // allowing the caller to provide different arguments depending on the
391 // extension and profile. This is guaranteed to be called synchronously with
392 // DispatchEvent, so callers don't need to worry about lifetime.
[email protected]2c6e3b04c2014-07-24 12:48:09393 //
394 // NOTE: the Extension argument to this may be NULL because it's possible for
395 // this event to be dispatched to non-extension processes, like WebUI.
[email protected]6e850922012-12-05 03:22:48396 WillDispatchCallback will_dispatch_callback;
397
kalmanf1b4d782015-06-24 21:14:05398 Event(events::HistogramValue histogram_value,
399 const std::string& event_name,
[email protected]6e850922012-12-05 03:22:48400 scoped_ptr<base::ListValue> event_args);
[email protected]d9e559d2012-07-05 01:04:57401
kalmanf1b4d782015-06-24 21:14:05402 Event(events::HistogramValue histogram_value,
403 const std::string& event_name,
[email protected]c9bd90f2012-08-07 23:58:15404 scoped_ptr<base::ListValue> event_args,
[email protected]45fd94172013-11-13 03:29:52405 content::BrowserContext* restrict_to_browser_context);
[email protected]f0eb58a2012-12-17 22:10:49406
kalmanf1b4d782015-06-24 21:14:05407 Event(events::HistogramValue histogram_value,
408 const std::string& event_name,
[email protected]f0eb58a2012-12-17 22:10:49409 scoped_ptr<base::ListValue> event_args,
[email protected]45fd94172013-11-13 03:29:52410 content::BrowserContext* restrict_to_browser_context,
[email protected]6e850922012-12-05 03:22:48411 const GURL& event_url,
[email protected]5a38dfd2012-07-23 23:22:10412 EventRouter::UserGestureState user_gesture,
413 const EventFilteringInfo& info);
[email protected]d9e559d2012-07-05 01:04:57414
[email protected]5a38dfd2012-07-23 23:22:10415 ~Event();
[email protected]6e850922012-12-05 03:22:48416
417 // Makes a deep copy of this instance. Ownership is transferred to the
418 // caller.
419 Event* DeepCopy();
[email protected]d9e559d2012-07-05 01:04:57420};
421
[email protected]954e13492012-11-15 03:18:23422struct EventListenerInfo {
423 EventListenerInfo(const std::string& event_name,
[email protected]c761a962013-11-20 04:19:41424 const std::string& extension_id,
[email protected]c1abb3232014-07-30 18:28:39425 const GURL& listener_url,
[email protected]c761a962013-11-20 04:19:41426 content::BrowserContext* browser_context);
427 // The event name including any sub-event, e.g. "runtime.onStartup" or
428 // "webRequest.onCompleted/123".
[email protected]954e13492012-11-15 03:18:23429 const std::string event_name;
[email protected]c761a962013-11-20 04:19:41430
[email protected]954e13492012-11-15 03:18:23431 const std::string extension_id;
[email protected]c1abb3232014-07-30 18:28:39432 const GURL listener_url;
[email protected]c761a962013-11-20 04:19:41433 content::BrowserContext* browser_context;
[email protected]954e13492012-11-15 03:18:23434};
435
[email protected]5a38dfd2012-07-23 23:22:10436} // namespace extensions
[email protected]d9e559d2012-07-05 01:04:57437
[email protected]34423532013-11-21 18:13:10438#endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_