diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 00:01:03 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 00:01:03 +0000 |
commit | 3ca29e2d2844eef858a635a32e34e298ceea0b10 (patch) | |
tree | 3e5135001307b0110fc5e4afceec74fe5d5ebf2d /chrome/renderer | |
parent | e0411ae51dad04edaab9365590ce47161606af0e (diff) | |
download | chromium_src-3ca29e2d2844eef858a635a32e34e298ceea0b10.zip chromium_src-3ca29e2d2844eef858a635a32e34e298ceea0b10.tar.gz chromium_src-3ca29e2d2844eef858a635a32e34e298ceea0b10.tar.bz2 |
Send port disconnect events when a frame is unloaded.
This is the other half of CL http://codereview.chromium.org/125280, which I split into http://codereview.chromium.org/147033 and this CL.
BUG=12686
TEST=no
Review URL: http://codereview.chromium.org/150125
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19686 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/extensions/event_bindings.h | 4 | ||||
-rw-r--r-- | chrome/renderer/extensions/renderer_extension_bindings.cc | 13 | ||||
-rw-r--r-- | chrome/renderer/resources/renderer_extension_bindings.js | 3 |
3 files changed, 17 insertions, 3 deletions
diff --git a/chrome/renderer/extensions/event_bindings.h b/chrome/renderer/extensions/event_bindings.h index f2c5f88..285a379 100644 --- a/chrome/renderer/extensions/event_bindings.h +++ b/chrome/renderer/extensions/event_bindings.h @@ -27,8 +27,8 @@ class EventBindings { static void HandleContextDestroyed(WebFrame* frame); // Calls the given function in each registered context which is listening - // for events. The function can be an object property, ie: - // "chromium.Event.dispatch_". + // for events. See comments on bindings_utils::CallFunctionInContext for + // more details. static void CallFunction(const std::string& function_name, int argc, v8::Handle<v8::Value>* argv); diff --git a/chrome/renderer/extensions/renderer_extension_bindings.cc b/chrome/renderer/extensions/renderer_extension_bindings.cc index f719797..4cff1dd 100644 --- a/chrome/renderer/extensions/renderer_extension_bindings.cc +++ b/chrome/renderer/extensions/renderer_extension_bindings.cc @@ -46,6 +46,8 @@ class ExtensionImpl : public ExtensionBase { return v8::FunctionTemplate::New(OpenChannelToExtension); } else if (name->Equals(v8::String::New("PostMessage"))) { return v8::FunctionTemplate::New(PostMessage); + } else if (name->Equals(v8::String::New("CloseChannel"))) { + return v8::FunctionTemplate::New(CloseChannel); } return ExtensionBase::GetNativeFunction(name); } @@ -83,6 +85,17 @@ class ExtensionImpl : public ExtensionBase { } return v8::Undefined(); } + + // Sends a message along the given channel. + static v8::Handle<v8::Value> CloseChannel(const v8::Arguments& args) { + if (args.Length() >= 1 && args[0]->IsInt32()) { + int port_id = args[0]->Int32Value(); + // Send via the RenderThread because the RenderView might be closing. + EventBindings::GetRenderThread()->Send( + new ViewHostMsg_ExtensionCloseChannel(port_id)); + } + return v8::Undefined(); + } }; // Convert a ListValue to a vector of V8 values. diff --git a/chrome/renderer/resources/renderer_extension_bindings.js b/chrome/renderer/resources/renderer_extension_bindings.js index bf59671..f9d354e 100644 --- a/chrome/renderer/resources/renderer_extension_bindings.js +++ b/chrome/renderer/resources/renderer_extension_bindings.js @@ -10,6 +10,7 @@ var chrome = chrome || {}; (function () { native function OpenChannelToExtension(id); + native function CloseChannel(portId); native function PostMessage(portId, msg); native function GetChromeHidden(); @@ -78,7 +79,7 @@ var chrome = chrome || {}; // Disconnects the port from the other end. chrome.Port.prototype.disconnect = function() { delete ports[this.portId_]; - //CloseChannel(this.portId_); // TODO(mpcomplete) + CloseChannel(this.portId_); } // Extension object. |