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 #ifndef EXTENSIONS_BROWSER_EVENT_ROUTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_EVENT_ROUTER_H_ |
6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_ | 6 #define EXTENSIONS_BROWSER_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const std::string& extension_id, | 87 const std::string& extension_id, |
88 const std::string& event_name, | 88 const std::string& event_name, |
89 scoped_ptr<base::ListValue> event_args, | 89 scoped_ptr<base::ListValue> event_args, |
90 UserGestureState user_gesture, | 90 UserGestureState user_gesture, |
91 const EventFilteringInfo& info); | 91 const EventFilteringInfo& info); |
92 | 92 |
93 // An EventRouter is shared between |browser_context| and its associated | 93 // An EventRouter is shared between |browser_context| and its associated |
94 // incognito context. |extension_prefs| may be NULL in tests. | 94 // incognito context. |extension_prefs| may be NULL in tests. |
95 EventRouter(content::BrowserContext* browser_context, | 95 EventRouter(content::BrowserContext* browser_context, |
96 ExtensionPrefs* extension_prefs); | 96 ExtensionPrefs* extension_prefs); |
97 virtual ~EventRouter(); | 97 ~EventRouter() override; |
98 | 98 |
99 // Add or remove an extension as an event listener for |event_name|. | 99 // Add or remove an extension as an event listener for |event_name|. |
100 // | 100 // |
101 // Note that multiple extensions can share a process due to process | 101 // Note that multiple extensions can share a process due to process |
102 // collapsing. Also, a single extension can have 2 processes if it is a split | 102 // collapsing. Also, a single extension can have 2 processes if it is a split |
103 // mode extension. | 103 // mode extension. |
104 void AddEventListener(const std::string& event_name, | 104 void AddEventListener(const std::string& event_name, |
105 content::RenderProcessHost* process, | 105 content::RenderProcessHost* process, |
106 const std::string& extension_id); | 106 const std::string& extension_id); |
107 void RemoveEventListener(const std::string& event_name, | 107 void RemoveEventListener(const std::string& event_name, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // TODO(gdk): Document this. | 201 // TODO(gdk): Document this. |
202 static void DispatchExtensionMessage( | 202 static void DispatchExtensionMessage( |
203 IPC::Sender* ipc_sender, | 203 IPC::Sender* ipc_sender, |
204 void* browser_context_id, | 204 void* browser_context_id, |
205 const std::string& extension_id, | 205 const std::string& extension_id, |
206 const std::string& event_name, | 206 const std::string& event_name, |
207 base::ListValue* event_args, | 207 base::ListValue* event_args, |
208 UserGestureState user_gesture, | 208 UserGestureState user_gesture, |
209 const extensions::EventFilteringInfo& info); | 209 const extensions::EventFilteringInfo& info); |
210 | 210 |
211 virtual void Observe(int type, | 211 void Observe(int type, |
212 const content::NotificationSource& source, | 212 const content::NotificationSource& source, |
213 const content::NotificationDetails& details) override; | 213 const content::NotificationDetails& details) override; |
214 // ExtensionRegistryObserver implementation. | 214 // ExtensionRegistryObserver implementation. |
215 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, | 215 void OnExtensionLoaded(content::BrowserContext* browser_context, |
216 const Extension* extension) override; | 216 const Extension* extension) override; |
217 virtual void OnExtensionUnloaded( | 217 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
218 content::BrowserContext* browser_context, | 218 const Extension* extension, |
219 const Extension* extension, | 219 UnloadedExtensionInfo::Reason reason) override; |
220 UnloadedExtensionInfo::Reason reason) override; | |
221 | 220 |
222 // Returns true if the given listener map contains a event listeners for | 221 // Returns true if the given listener map contains a event listeners for |
223 // the given event. If |extension_id| is non-empty, we also check that that | 222 // the given event. If |extension_id| is non-empty, we also check that that |
224 // extension is one of the listeners. | 223 // extension is one of the listeners. |
225 bool HasEventListenerImpl(const ListenerMap& listeners, | 224 bool HasEventListenerImpl(const ListenerMap& listeners, |
226 const std::string& extension_id, | 225 const std::string& extension_id, |
227 const std::string& event_name); | 226 const std::string& event_name); |
228 | 227 |
229 // Shared by DispatchEvent*. If |restrict_to_extension_id| is empty, the | 228 // Shared by DispatchEvent*. If |restrict_to_extension_id| is empty, the |
230 // event is broadcast. | 229 // event is broadcast. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 | 284 |
286 // static | 285 // static |
287 static void IncrementInFlightEventsOnUI( | 286 static void IncrementInFlightEventsOnUI( |
288 void* browser_context_id, | 287 void* browser_context_id, |
289 const std::string& extension_id); | 288 const std::string& extension_id); |
290 | 289 |
291 void DispatchPendingEvent(const linked_ptr<Event>& event, | 290 void DispatchPendingEvent(const linked_ptr<Event>& event, |
292 ExtensionHost* host); | 291 ExtensionHost* host); |
293 | 292 |
294 // Implementation of EventListenerMap::Delegate. | 293 // Implementation of EventListenerMap::Delegate. |
295 virtual void OnListenerAdded(const EventListener* listener) override; | 294 void OnListenerAdded(const EventListener* listener) override; |
296 virtual void OnListenerRemoved(const EventListener* listener) override; | 295 void OnListenerRemoved(const EventListener* listener) override; |
297 | 296 |
298 content::BrowserContext* browser_context_; | 297 content::BrowserContext* browser_context_; |
299 | 298 |
300 // The ExtensionPrefs associated with |browser_context_|. May be NULL in | 299 // The ExtensionPrefs associated with |browser_context_|. May be NULL in |
301 // tests. | 300 // tests. |
302 ExtensionPrefs* extension_prefs_; | 301 ExtensionPrefs* extension_prefs_; |
303 | 302 |
304 content::NotificationRegistrar registrar_; | 303 content::NotificationRegistrar registrar_; |
305 | 304 |
306 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 305 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 const std::string event_name; | 381 const std::string event_name; |
383 | 382 |
384 const std::string extension_id; | 383 const std::string extension_id; |
385 const GURL listener_url; | 384 const GURL listener_url; |
386 content::BrowserContext* browser_context; | 385 content::BrowserContext* browser_context; |
387 }; | 386 }; |
388 | 387 |
389 } // namespace extensions | 388 } // namespace extensions |
390 | 389 |
391 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_ | 390 #endif // EXTENSIONS_BROWSER_EVENT_ROUTER_H_ |
OLD | NEW |