summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/extensions
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 00:01:03 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 00:01:03 +0000
commit3ca29e2d2844eef858a635a32e34e298ceea0b10 (patch)
tree3e5135001307b0110fc5e4afceec74fe5d5ebf2d /chrome/renderer/extensions
parente0411ae51dad04edaab9365590ce47161606af0e (diff)
downloadchromium_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/extensions')
-rw-r--r--chrome/renderer/extensions/event_bindings.h4
-rw-r--r--chrome/renderer/extensions/renderer_extension_bindings.cc13
2 files changed, 15 insertions, 2 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.