Chromium Code Reviews| Index: chrome/renderer/resources/extensions/event.js |
| diff --git a/chrome/renderer/resources/extensions/event.js b/chrome/renderer/resources/extensions/event.js |
| index 6c344c8f49ef3c67fdb4f5ded8830a797db814e2..2bd3649af218d291c97f65f4295facc3faf2e4e2 100644 |
| --- a/chrome/renderer/resources/extensions/event.js |
| +++ b/chrome/renderer/resources/extensions/event.js |
| @@ -15,6 +15,7 @@ |
| var sendRequest = require('sendRequest').sendRequest; |
| var utils = require('utils'); |
| var validate = require('schemaUtils').validate; |
| + var unloadEvent = require('unload_event'); |
| var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| var chrome = requireNative('chrome').GetChrome(); |
| @@ -200,7 +201,7 @@ |
| // Dispatches a named event with the given argument array. The args array is |
| // the list of arguments that will be sent to the event callback. |
| - chromeHidden.Event.dispatchEvent = function(name, args, filteringInfo) { |
| + function dispatchEvent(name, args, filteringInfo) { |
| var listenerIDs = null; |
| if (filteringInfo) |
| @@ -221,13 +222,7 @@ |
| eventArgumentMassagers[name](args, dispatchArgs); |
| else |
| dispatchArgs(args); |
| - }; |
| - |
| - // Test if a named event has any listeners. |
| - chromeHidden.Event.hasListener = function(name) { |
| - return (attachedNamedEvents[name] && |
| - attachedNamedEvents[name].listeners_.length > 0); |
| - }; |
| + } |
| // Registers a callback to be called when this event is dispatched. |
| Event.prototype.addListener = function(cb, filters) { |
| @@ -450,20 +445,13 @@ |
| ruleFunctionSchemas.getRules.parameters); |
| } |
| - // Special load events: we don't use the DOM unload because that slows |
| - // down tab shutdown. On the other hand, onUnload might not always fire, |
| - // since Chrome will terminate renderers on shutdown (SuddenTermination). |
| - chromeHidden.onUnload = new Event(); |
| - |
| - chromeHidden.dispatchOnUnload = function() { |
| - chromeHidden.onUnload.dispatch(); |
| - chromeHidden.wasUnloaded = true; |
| - |
| + unloadEvent.addListener(function() { |
|
koz (OOO until 15th September)
2013/05/31 04:28:44
Very nice :-)
not at google - send to devlin
2013/05/31 22:47:07
:)
|
| for (var i = 0; i < allAttachedEvents.length; ++i) { |
| var event = allAttachedEvents[i]; |
| if (event) |
| event.detach_(); |
| } |
| - }; |
| + }); |
| chrome.Event = Event; |
| + exports.dispatchEvent = dispatchEvent; |