Index: chrome/browser/extensions/extension_event_router.h |
diff --git a/chrome/browser/extensions/extension_event_router.h b/chrome/browser/extensions/extension_event_router.h |
index 42a649cfd9a77c7c128f3724cacc9f15ca652cbd..418909b8b283e17795522b7c07233dbe77dc6850 100644 |
--- a/chrome/browser/extensions/extension_event_router.h |
+++ b/chrome/browser/extensions/extension_event_router.h |
@@ -13,6 +13,8 @@ |
#include "base/compiler_specific.h" |
#include "base/memory/linked_ptr.h" |
#include "base/memory/ref_counted.h" |
+#include "chrome/browser/extensions/event_listener_map.h" |
+#include "chrome/common/extensions/event_filtering_info.h" |
#include "content/public/browser/notification_observer.h" |
#include "content/public/browser/notification_registrar.h" |
#include "ipc/ipc_message.h" |
@@ -22,6 +24,10 @@ class ExtensionHost; |
class ExtensionDevToolsManager; |
class Profile; |
+namespace base { |
+class DictionaryValue; |
+} |
+ |
namespace content { |
class RenderProcessHost; |
} |
@@ -47,7 +53,8 @@ class ExtensionEventRouter : public content::NotificationObserver { |
const std::string& event_name, |
const std::string& event_args, |
const GURL& event_url, |
- UserGestureState user_gesture); |
+ UserGestureState user_gesture, |
+ extensions::EventFilteringInfo info); |
battre
2012/06/13 09:21:54
make |info| pass by const-ref?
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
|
explicit ExtensionEventRouter(Profile* profile); |
virtual ~ExtensionEventRouter(); |
@@ -72,6 +79,18 @@ class ExtensionEventRouter : public content::NotificationObserver { |
void RemoveLazyEventListener(const std::string& event_name, |
const std::string& extension_id); |
+ void AddFilteredEventListener(const std::string& event_name, |
+ content::RenderProcessHost* process, |
+ const std::string& extension_id, |
+ const base::DictionaryValue& filter, |
+ bool lazy); |
battre
2012/06/13 09:21:54
what's lazy?
koz (OOO until 15th September)
2012/06/14 02:15:55
Actually, as this flag controls whether an extra,
|
+ |
+ void RemoveFilteredEventListener(const std::string& event_name, |
+ content::RenderProcessHost* process, |
+ const std::string& extension_id, |
+ const base::DictionaryValue& filter, |
+ bool lazy); |
+ |
// Returns true if there is at least one listener for the given event. |
bool HasEventListener(const std::string& event_name); |
@@ -89,7 +108,8 @@ class ExtensionEventRouter : public content::NotificationObserver { |
const std::string& event_name, |
const std::string& event_args, |
Profile* restrict_to_profile, |
- const GURL& event_url); |
+ const GURL& event_url, |
+ extensions::EventFilteringInfo info); |
Matt Perry
2012/06/13 01:24:27
what about the other Dispatch methods?
koz (OOO until 15th September)
2012/06/14 02:15:55
I was thinking of introducing some datatype to enc
|
// Same as above, except only send the event to the given extension. |
virtual void DispatchEventToExtension( |
@@ -127,9 +147,6 @@ class ExtensionEventRouter : public content::NotificationObserver { |
void OnEventAck(Profile* profile, const std::string& extension_id); |
private: |
- // The details of an event to be dispatched. |
- struct ExtensionEvent; |
- |
// The extension and process that contains the event listener for a given |
// event. |
struct ListenerProcess; |
@@ -156,9 +173,17 @@ class ExtensionEventRouter : public content::NotificationObserver { |
void DispatchEventImpl(const std::string& extension_id, |
const linked_ptr<ExtensionEvent>& event); |
- // Dispatches the event to a single listener process. |
- void DispatchEventToListener(const ListenerProcess& listener, |
- const linked_ptr<ExtensionEvent>& event); |
+ // Ensures that all lazy background pages that are interested in the given |
+ // event are loaded, and queues the event if the page is not ready yet. |
+ // If |extension_id| is non-empty, we load only that extension's page |
Matt Perry
2012/06/13 01:24:27
comment needs updating
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
|
+ // (assuming it is interested in the event). |
+ void DispatchLazyEvent(const linked_ptr<EventListener>& listener, |
+ const linked_ptr<ExtensionEvent>& event); |
+ |
+ // Dispatches the event to the specified extension running in |process|. |
+ void DispatchEventToExtension(const std::string& extension_id, |
Matt Perry
2012/06/13 01:24:27
We already have 2 DispatchEventToExtension functio
koz (OOO until 15th September)
2012/06/14 02:15:55
Done.
|
+ content::RenderProcessHost* process, |
+ const linked_ptr<ExtensionEvent>& event); |
// Returns false when the event is scoped to a profile and the listening |
// extension does not have access to events from that profile. Also fills |
@@ -170,20 +195,13 @@ class ExtensionEventRouter : public content::NotificationObserver { |
const linked_ptr<ExtensionEvent>& event, |
const std::string** event_args); |
- // Ensures that all lazy background pages that are interested in the given |
- // event are loaded, and queues the event if the page is not ready yet. |
- // If |extension_id| is non-empty, we load only that extension's page |
- // (assuming it is interested in the event). |
- void LoadLazyBackgroundPagesForEvent( |
- const std::string& extension_id, |
- const linked_ptr<ExtensionEvent>& event); |
- |
// Possibly loads given extension's background page in preparation to |
// dispatch an event. |
void MaybeLoadLazyBackgroundPage( |
Profile* profile, |
const extensions::Extension* extension, |
- const linked_ptr<ExtensionEvent>& event); |
+ const linked_ptr<ExtensionEvent>& event, |
+ const linked_ptr<EventListener>& listener); |
// Track of the number of dispatched events that have not yet sent an |
// ACK from the renderer. |
@@ -191,23 +209,41 @@ class ExtensionEventRouter : public content::NotificationObserver { |
const extensions::Extension* extension); |
void DispatchPendingEvent(const linked_ptr<ExtensionEvent>& event, |
+ const linked_ptr<EventListener>& listener, |
ExtensionHost* host); |
+ // Called when a listener is removed. |
+ void OnListenerRemoved(const EventListener* listener); |
+ |
Profile* profile_; |
content::NotificationRegistrar registrar_; |
scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; |
- // The list of active extension processes that are listening to events. |
- ListenerMap listeners_; |
- |
- // The list of all the lazy (non-persistent) background pages that are |
- // listening to events. This is just a cache of the real list, which is |
- // stored on disk in the extension prefs. |
- ListenerMap lazy_listeners_; |
+ EventListenerMap listeners_; |
DISALLOW_COPY_AND_ASSIGN(ExtensionEventRouter); |
}; |
+struct ExtensionEvent { |
+ std::string event_name; |
+ std::string event_args; |
+ GURL event_url; |
+ Profile* restrict_to_profile; |
+ std::string cross_incognito_args; |
+ ExtensionEventRouter::UserGestureState user_gesture; |
+ extensions::EventFilteringInfo info; |
+ |
+ ExtensionEvent(const std::string& event_name, |
+ const std::string& event_args, |
+ const GURL& event_url, |
+ Profile* restrict_to_profile, |
+ const std::string& cross_incognito_args, |
+ ExtensionEventRouter::UserGestureState user_gesture, |
+ const extensions::EventFilteringInfo& info); |
+ ~ExtensionEvent(); |
+}; |
+ |
+ |
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ |