Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2493)

Unified Diff: content/common/npobject_proxy.cc

Issue 8576001: Chromium does not throw the exception message by calling NPN_SetException from NPAPI plugin Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « content/common/npobject_proxy.h ('k') | content/common/npobject_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/npobject_proxy.cc
===================================================================
--- content/common/npobject_proxy.cc (revision 109161)
+++ content/common/npobject_proxy.cc (working copy)
@@ -62,7 +62,8 @@
: channel_(channel),
route_id_(route_id),
containing_window_(containing_window),
- page_url_(page_url) {
+ page_url_(page_url),
+ has_exception_thrown_(false) {
channel_->AddRoute(route_id, this, this);
}
@@ -110,8 +111,15 @@
}
bool NPObjectProxy::OnMessageReceived(const IPC::Message& msg) {
- NOTREACHED();
- return false;
+ bool handled = true;
+
+ IPC_BEGIN_MESSAGE_MAP(NPObjectProxy, msg)
+ IPC_MESSAGE_HANDLER(NPObjectMsg_SetException, OnSetException)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+
+ DCHECK(handled);
+ return true;
}
void NPObjectProxy::OnChannelError() {
@@ -120,6 +128,23 @@
channel_ = NULL;
}
+void NPObjectProxy::OnSetException(const std::string& msg) {
+ if (IsPluginProcess()) {
+ NOTREACHED() << "Should be only called from renderer process!";
+ return;
+ }
+
+ has_exception_thrown_ = true;
+
+ NPObject* obj = NULL;
+
+ if (channel()) {
+ obj = channel()->GetExistingNPObjectProxy(route_id_);
+ }
+
+ WebKit::WebBindings::setException(obj, msg.c_str());
+}
+
bool NPObjectProxy::NPHasMethod(NPObject *obj,
NPIdentifier name) {
if (obj == NULL)
@@ -137,6 +162,7 @@
proxy->Send(new NPObjectMsg_HasMethod(proxy->route_id(), name_param,
&result));
+
return result;
}
@@ -215,6 +241,14 @@
GURL page_url = proxy->page_url_;
proxy->Send(msg);
+ // In case of returning result is false and the NPObjectProxy instance
+ // has exception thrown, it means that NPN_SetException is called from
+ // NPAPI plugin during the process of invoking native method.
+ if (!result && proxy->HasExceptionThrown()) {
+ // Tell v8 engine that an exception has been already thrown via np_result
+ BOOLEAN_TO_NPVARIANT(true, *np_result);
+ proxy->SetExceptionThrown(false);
+ }
// Send may delete proxy.
proxy = NULL;
@@ -435,6 +469,13 @@
GURL page_url = proxy->page_url_;
proxy->Send(msg);
+ // An exception has been occurred during the process of handling
+ // NPObjectMsg_Construct on the peer side
+ if (!result && proxy->HasExceptionThrown()) {
+ BOOLEAN_TO_NPVARIANT(true, *np_result);
+ proxy->SetExceptionThrown(false);
+ }
+
// Send may delete proxy.
proxy = NULL;
« no previous file with comments | « content/common/npobject_proxy.h ('k') | content/common/npobject_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698