| 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;
|
|
|
|
|