| Index: ppapi/proxy/ppb_testing_proxy.cc
|
| ===================================================================
|
| --- ppapi/proxy/ppb_testing_proxy.cc (revision 114053)
|
| +++ ppapi/proxy/ppb_testing_proxy.cc (working copy)
|
| @@ -9,6 +9,7 @@
|
| #include "ppapi/proxy/enter_proxy.h"
|
| #include "ppapi/proxy/plugin_dispatcher.h"
|
| #include "ppapi/proxy/ppapi_messages.h"
|
| +#include "ppapi/proxy/serialized_var.h"
|
| #include "ppapi/shared_impl/ppapi_globals.h"
|
| #include "ppapi/shared_impl/resource.h"
|
| #include "ppapi/shared_impl/resource_tracker.h"
|
| @@ -87,13 +88,31 @@
|
| API_ID_PPB_TESTING, instance_id, input_event_data));
|
| }
|
|
|
| +PP_Var ExecuteScript(PP_Instance instance,
|
| + PP_Var script,
|
| + PP_Var* exception) {
|
| + PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance);
|
| + if (!dispatcher)
|
| + return PP_MakeUndefined();
|
| + ReceiveSerializedException se(dispatcher, exception);
|
| + if (se.IsThrown())
|
| + return PP_MakeUndefined();
|
| +
|
| + ReceiveSerializedVarReturnValue result;
|
| + dispatcher->Send(new PpapiHostMsg_PPBTesting_ExecuteScript(
|
| + API_ID_PPB_TESTING, instance,
|
| + SerializedVarSendInput(dispatcher, script), &se, &result));
|
| + return result.Return(dispatcher);
|
| +}
|
| +
|
| const PPB_Testing_Dev testing_interface = {
|
| &ReadImageData,
|
| &RunMessageLoop,
|
| &QuitMessageLoop,
|
| &GetLiveObjectsForInstance,
|
| &IsOutOfProcess,
|
| - &SimulateInputEvent
|
| + &SimulateInputEvent,
|
| + &ExecuteScript
|
| };
|
|
|
| InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) {
|
| @@ -127,6 +146,12 @@
|
| }
|
|
|
| bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) {
|
| + // Prevent the dispatcher from going away during a call to ExecuteScript.
|
| + // This must happen OUTSIDE of ExecuteScript since the SerializedVars use
|
| + // the dispatcher upon return of the function (converting the
|
| + // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor).
|
| + ScopedModuleReference death_grip(dispatcher());
|
| +
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(PPB_Testing_Proxy, msg)
|
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ReadImageData,
|
| @@ -135,6 +160,8 @@
|
| OnMsgGetLiveObjectsForInstance)
|
| IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent,
|
| OnMsgSimulateInputEvent)
|
| + IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_ExecuteScript,
|
| + OnMsgExecuteScript)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP()
|
| return handled;
|
| @@ -173,5 +200,21 @@
|
| input_event_impl->pp_resource());
|
| }
|
|
|
| +void PPB_Testing_Proxy::OnMsgExecuteScript(
|
| + PP_Instance instance,
|
| + SerializedVarReceiveInput script,
|
| + SerializedVarOutParam out_exception,
|
| + SerializedVarReturnValue result) {
|
| + if (dispatcher()->IsPlugin())
|
| + NOTREACHED();
|
| + else
|
| + static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy();
|
| +
|
| + result.Return(dispatcher(), ppb_testing_impl_->ExecuteScript(
|
| + instance,
|
| + script.Get(dispatcher()),
|
| + out_exception.OutParam(dispatcher())));
|
| +}
|
| +
|
| } // namespace proxy
|
| } // namespace ppapi
|
|
|