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 4afc4a265f26dbb501029ad6d4d4d2483c84852c..1803b07a3b08030a141d03ff2410a330c39f2c67 100644 |
--- a/chrome/browser/extensions/extension_event_router.h |
+++ b/chrome/browser/extensions/extension_event_router.h |
@@ -50,22 +50,13 @@ class ExtensionEventRouter : public content::NotificationObserver, |
USER_GESTURE_NOT_ENABLED = 2, |
}; |
- // Sends an event via ipc_sender to the given extension. Can be called on |
- // any thread. |
+ // Sends an event via ipc_sender to the given extension. Can be called on any |
+ // thread. Takes ownership of |event_args|, but can be safely invoked with |
+ // NULL. |
static void DispatchEvent(IPC::Sender* ipc_sender, |
miket_OOO
2012/07/10 22:33:19
Great, makes more sense now. I'd like to see simil
|
const std::string& extension_id, |
const std::string& event_name, |
- const base::Value& event_args, |
- const GURL& event_url, |
- UserGestureState user_gesture, |
- const extensions::EventFilteringInfo& info); |
- |
- // This invocation is deprecated. All future consumers of this API should be |
- // sending Values as event arguments, using the above version. |
- static void DispatchEvent(IPC::Sender* ipc_sender, |
- const std::string& extension_id, |
- const std::string& event_name, |
- const std::string& event_args, |
+ base::ListValue* event_args, |
sky
2012/07/16 22:29:06
Did you consider making this take a const base::Li
|
const GURL& event_url, |
UserGestureState user_gesture, |
const extensions::EventFilteringInfo& info); |
@@ -120,44 +111,39 @@ class ExtensionEventRouter : public content::NotificationObserver, |
// profiles unless the extension has permission (e.g. incognito tab update -> |
// normal profile only works if extension is allowed incognito access). If |
// |event_url| is not empty, the event is only sent to extension with host |
- // permissions for this url. |
+ // permissions for this url. Takes ownership of |event_args|, but can be |
+ // safely invoked with NULL. |
void DispatchEventToRenderers( |
const std::string& event_name, |
- const std::string& event_args, |
+ base::ListValue* event_args, |
Profile* restrict_to_profile, |
const GURL& event_url, |
extensions::EventFilteringInfo info); |
- // As above, but defaults |info| to EventFilteringInfo(). |
+ // As above, but defaults |info| to EventFilteringInfo(). Takes ownership of |
+ // |event_args|, but can be safely invoked with NULL. |
void DispatchEventToRenderers( |
const std::string& event_name, |
- const std::string& event_args, |
+ base::ListValue* event_args, |
Profile* restrict_to_profile, |
const GURL& event_url); |
- // Same as above, except only send the event to the given extension. |
+ // Same as above, except only send the event to the given extension. Takes |
+ // ownership of |event_args|, but can be safely invoked with NULL. |
virtual void DispatchEventToExtension( |
const std::string& extension_id, |
const std::string& event_name, |
- const base::Value& event_args, |
+ base::ListValue* event_args, |
Profile* restrict_to_profile, |
const GURL& event_url); |
- // This invocation is deprecated. The above variant which uses a Value for |
- // event_args is to be used instead. |
+ // Dispatch an event to particular extension. Also include an explicit user |
+ // gesture indicator. Takes ownership of |event_args|, but can be safely |
+ // invoked with NULL. |
virtual void DispatchEventToExtension( |
const std::string& extension_id, |
const std::string& event_name, |
- const std::string& event_args, |
- Profile* restrict_to_profile, |
- const GURL& event_url); |
- |
- // Dispatch an event to particular extension. Also include an |
- // explicit user gesture indicator. |
- virtual void DispatchEventToExtension( |
- const std::string& extension_id, |
- const std::string& event_name, |
- const std::string& event_args, |
+ base::ListValue* event_args, |
Profile* restrict_to_profile, |
const GURL& event_url, |
UserGestureState user_gesture); |
@@ -168,12 +154,14 @@ class ExtensionEventRouter : public content::NotificationObserver, |
// in order to avoid sending 2 events to "spanning" extensions. |
// If |cross_incognito_profile| is non-NULL and different from |
// restrict_to_profile, send the event with cross_incognito_args to the |
- // extensions in that profile that can't cross incognito. |
+ // extensions in that profile that can't cross incognito. Takes ownership of |
+ // |event_args| and |cross_incognito_args|, but can be safely invoked with |
+ // NULL for either. |
void DispatchEventsToRenderersAcrossIncognito( |
const std::string& event_name, |
- const std::string& event_args, |
+ base::ListValue* event_args, |
Profile* restrict_to_profile, |
- const std::string& cross_incognito_args, |
+ base::ListValue* cross_incognito_args, |
const GURL& event_url); |
// Record the Event Ack from the renderer. (One less event in-flight.) |
@@ -217,13 +205,13 @@ class ExtensionEventRouter : public content::NotificationObserver, |
// 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 |
- // |event_args| with the proper arguments to send, which may differ if |
- // the event crosses the incognito boundary. |
+ // |event_args| (if non-NULL) with the proper arguments to send, which may |
+ // differ if the event crosses the incognito boundary. |
bool CanDispatchEventToProfile( |
Profile* profile, |
const extensions::Extension* extension, |
const linked_ptr<ExtensionEvent>& event, |
- const base::Value** event_args); |
+ base::ListValue** event_args); |
// Possibly loads given extension's background page in preparation to |
// dispatch an event. |
@@ -257,40 +245,21 @@ class ExtensionEventRouter : public content::NotificationObserver, |
struct ExtensionEvent { |
std::string event_name; |
- scoped_ptr<Value> event_args; |
+ scoped_ptr<ListValue> event_args; |
GURL event_url; |
Profile* restrict_to_profile; |
- scoped_ptr<Value> cross_incognito_args; |
+ scoped_ptr<ListValue> cross_incognito_args; |
ExtensionEventRouter::UserGestureState user_gesture; |
extensions::EventFilteringInfo info; |
ExtensionEvent(const std::string& event_name, |
- const Value& event_args, |
+ ListValue* event_args, |
const GURL& event_url, |
Profile* restrict_to_profile, |
- const Value& cross_incognito_args, |
+ ListValue* cross_incognito_args, |
ExtensionEventRouter::UserGestureState user_gesture, |
const extensions::EventFilteringInfo& info); |
- |
- // TODO(gdk): This variant should be retired once the callers are switched to |
- // providing Values instead of just strings. |
- 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(const std::string& event_name, |
- const Value& event_args, |
- const GURL& event_url, |
- Profile* restrict_to_profile, |
- ExtensionEventRouter::UserGestureState user_gesture, |
- const extensions::EventFilteringInfo& info); |
- |
~ExtensionEvent(); |
}; |
- |
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_EVENT_ROUTER_H_ |