Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Unified Diff: chrome/renderer/resources/event_bindings.js

Issue 73065: Initial plumbing for sending events from the browser to extension renderers. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/render_thread.cc ('k') | chrome/renderer/resources/extension_process_bindings.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/event_bindings.js
===================================================================
--- chrome/renderer/resources/event_bindings.js (revision 13816)
+++ chrome/renderer/resources/event_bindings.js (working copy)
@@ -8,9 +8,9 @@
// with that name will route through this object's listeners.
//
// Example:
- // chromium.ontabchanged = new Event('tabchanged');
- // chromium.ontabchanged.addListener(function(data) { alert(data); });
- // chromium.Event.dispatch_('tabchanged', 'hi');
+ // chromium.tabs.onTabChanged = new chromium.Event("tab-changed");
+ // chromium.tabs.onTabChanged.addListener(function(data) { alert(data); });
+ // chromium.Event.dispatch_("tab-changed", "hi");
// will result in an alert dialog that says 'hi'.
chromium.Event = function(opt_eventName) {
this.eventName_ = opt_eventName;
@@ -20,21 +20,24 @@
// A map of event names to the event object that is registered to that name.
chromium.Event.attached_ = {};
- // Dispatches a named event with the given JSON data, which is deserialized
- // before dispatch.
- chromium.Event.dispatchJSON_ = function(name, data) {
+ // Dispatches a named event with the given JSON array, which is deserialized
+ // before dispatch. The JSON array is the list of arguments that will be
+ // sent with the event callback.
+ chromium.Event.dispatchJSON_ = function(name, args) {
if (chromium.Event.attached_[name]) {
- if (data) {
- data = goog.json.parse(data);
+ if (args) {
+ args = goog.json.parse(args);
}
- chromium.Event.attached_[name].dispatch(data);
+ chromium.Event.attached_[name].dispatch.apply(
+ chromium.Event.attached_[name], args);
}
};
- // Dispatches a named event with the given object data.
- chromium.Event.dispatch_ = function(name, data) {
+ // Dispatches a named event with the given arguments, supplied as an array.
+ chromium.Event.dispatch_ = function(name, args) {
if (chromium.Event.attached_[name]) {
- chromium.Event.attached_[name].dispatch(data);
+ chromium.Event.attached_[name].dispatch.apply(
+ chromium.Event.attached_[name], args);
}
};
« no previous file with comments | « chrome/renderer/render_thread.cc ('k') | chrome/renderer/resources/extension_process_bindings.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698