1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ppapi/proxy/ppb_instance_proxy.h"
7 #include "base/memory/ref_counted.h"
8 #include "build/build_config.h"
9 #include "ppapi/c/pp_errors.h"
10 #include "ppapi/c/pp_time.h"
11 #include "ppapi/c/pp_var.h"
12 #include "ppapi/c/ppb_audio_config.h"
13 #include "ppapi/c/ppb_instance.h"
14 #include "ppapi/c/ppb_messaging.h"
15 #include "ppapi/c/ppb_mouse_lock.h"
16 #include "ppapi/c/private/pp_content_decryptor.h"
17 #include "ppapi/proxy/broker_resource.h"
18 #include "ppapi/proxy/browser_font_singleton_resource.h"
19 #include "ppapi/proxy/content_decryptor_private_serializer.h"
20 #include "ppapi/proxy/enter_proxy.h"
21 #include "ppapi/proxy/file_mapping_resource.h"
22 #include "ppapi/proxy/flash_clipboard_resource.h"
23 #include "ppapi/proxy/flash_file_resource.h"
24 #include "ppapi/proxy/flash_fullscreen_resource.h"
25 #include "ppapi/proxy/flash_resource.h"
26 #include "ppapi/proxy/gamepad_resource.h"
27 #include "ppapi/proxy/host_dispatcher.h"
28 #include "ppapi/proxy/isolated_file_system_private_resource.h"
29 #include "ppapi/proxy/message_handler.h"
30 #include "ppapi/proxy/network_proxy_resource.h"
31 #include "ppapi/proxy/pdf_resource.h"
32 #include "ppapi/proxy/plugin_dispatcher.h"
33 #include "ppapi/proxy/ppapi_messages.h"
34 #include "ppapi/proxy/serialized_var.h"
35 #include "ppapi/proxy/truetype_font_singleton_resource.h"
36 #include "ppapi/proxy/uma_private_resource.h"
37 #include "ppapi/shared_impl/ppapi_globals.h"
38 #include "ppapi/shared_impl/ppb_url_util_shared.h"
39 #include "ppapi/shared_impl/ppb_view_shared.h"
40 #include "ppapi/shared_impl/var.h"
41 #include "ppapi/thunk/enter.h"
42 #include "ppapi/thunk/ppb_compositor_api.h"
43 #include "ppapi/thunk/ppb_graphics_2d_api.h"
44 #include "ppapi/thunk/ppb_graphics_3d_api.h"
45 #include "ppapi/thunk/thunk.h"
47 // Windows headers interfere with this file.
52 using ppapi::thunk::EnterInstanceNoLock
;
53 using ppapi::thunk::EnterResourceNoLock
;
54 using ppapi::thunk::PPB_Compositor_API
;
55 using ppapi::thunk::PPB_Graphics2D_API
;
56 using ppapi::thunk::PPB_Graphics3D_API
;
57 using ppapi::thunk::PPB_Instance_API
;
65 const char kSerializationError
[] = "Failed to convert a PostMessage "
66 "argument from a PP_Var to a Javascript value. It may have cycles or be of "
67 "an unsupported type.";
70 void RequestSurroundingText(PP_Instance instance
) {
71 PluginDispatcher
* dispatcher
= PluginDispatcher::GetForInstance(instance
);
73 return; // Instance has gone away while message was pending.
75 InstanceData
* data
= dispatcher
->GetInstanceData(instance
);
76 DCHECK(data
); // Should have it, since we still have a dispatcher.
77 data
->is_request_surrounding_text_pending
= false;
78 if (!data
->should_do_request_surrounding_text
)
81 // Just fake out a RequestSurroundingText message to the proxy for the PPP
83 InterfaceProxy
* proxy
= dispatcher
->GetInterfaceProxy(API_ID_PPP_TEXT_INPUT
);
86 proxy
->OnMessageReceived(PpapiMsg_PPPTextInput_RequestSurroundingText(
87 API_ID_PPP_TEXT_INPUT
, instance
,
88 PPB_Instance_Shared::kExtraCharsForTextInput
));
93 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher
* dispatcher
)
94 : InterfaceProxy(dispatcher
),
95 callback_factory_(this) {
98 PPB_Instance_Proxy::~PPB_Instance_Proxy() {
101 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message
& msg
) {
102 // Prevent the dispatcher from going away during a call to ExecuteScript.
103 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use
104 // the dispatcher upon return of the function (converting the
105 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor).
106 #if !defined(OS_NACL)
107 ScopedModuleReference
death_grip(dispatcher());
111 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy
, msg
)
112 #if !defined(OS_NACL)
113 // Plugin -> Host messages.
114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject
,
115 OnHostMsgGetWindowObject
)
116 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject
,
117 OnHostMsgGetOwnerElementObject
)
118 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics
,
119 OnHostMsgBindGraphics
)
120 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame
,
121 OnHostMsgIsFullFrame
)
123 PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate
,
124 OnHostMsgGetAudioHardwareOutputSampleRate
)
126 PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize
,
127 OnHostMsgGetAudioHardwareOutputBufferSize
)
128 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript
,
129 OnHostMsgExecuteScript
)
130 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDefaultCharSet
,
131 OnHostMsgGetDefaultCharSet
)
132 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests
,
133 OnHostMsgSetPluginToHandleFindRequests
);
134 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged
,
135 OnHostMsgNumberOfFindResultsChanged
)
136 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SelectFindResultChanged
,
137 OnHostMsgSelectFindResultChanged
)
138 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTickmarks
,
139 OnHostMsgSetTickmarks
)
140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage
,
141 OnHostMsgPostMessage
)
142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen
,
143 OnHostMsgSetFullscreen
)
144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize
,
145 OnHostMsgGetScreenSize
)
146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents
,
147 OnHostMsgRequestInputEvents
)
148 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents
,
149 OnHostMsgClearInputEvents
)
150 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_StartTrackingLatency
,
151 OnHostMsgStartTrackingLatency
)
152 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse
,
154 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse
,
155 OnHostMsgUnlockMouse
)
156 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor
,
158 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType
,
159 OnHostMsgSetTextInputType
)
160 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition
,
161 OnHostMsgUpdateCaretPosition
)
162 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText
,
163 OnHostMsgCancelCompositionText
)
164 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText
,
165 OnHostMsgUpdateSurroundingText
)
166 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL
,
167 OnHostMsgGetDocumentURL
)
168 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument
,
169 OnHostMsgResolveRelativeToDocument
)
170 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest
,
171 OnHostMsgDocumentCanRequest
)
172 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument
,
173 OnHostMsgDocumentCanAccessDocument
)
174 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL
,
175 OnHostMsgGetPluginInstanceURL
)
176 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL
,
177 OnHostMsgGetPluginReferrerURL
)
178 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolved
,
179 OnHostMsgPromiseResolved
)
180 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseResolvedWithSession
,
181 OnHostMsgPromiseResolvedWithSession
)
182 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PromiseRejected
,
183 OnHostMsgPromiseRejected
)
184 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage
,
185 OnHostMsgSessionMessage
)
186 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady
,
187 OnHostMsgSessionReady
)
188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed
,
189 OnHostMsgSessionClosed
)
190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError
,
191 OnHostMsgSessionError
)
192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock
,
193 OnHostMsgDeliverBlock
)
194 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderInitializeDone
,
195 OnHostMsgDecoderInitializeDone
)
196 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderDeinitializeDone
,
197 OnHostMsgDecoderDeinitializeDone
)
198 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderResetDone
,
199 OnHostMsgDecoderResetDone
)
200 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverFrame
,
201 OnHostMsgDeliverFrame
)
202 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverSamples
,
203 OnHostMsgDeliverSamples
)
204 #endif // !defined(OS_NACL)
206 // Host -> Plugin messages.
207 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete
,
208 OnPluginMsgMouseLockComplete
)
210 IPC_MESSAGE_UNHANDLED(handled
= false)
211 IPC_END_MESSAGE_MAP()
215 PP_Bool
PPB_Instance_Proxy::BindGraphics(PP_Instance instance
,
216 PP_Resource device
) {
217 // If device is 0, pass a null HostResource. This signals the host to unbind
219 PP_Resource pp_resource
= 0;
222 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device
);
223 if (!resource
|| resource
->pp_instance() != instance
)
225 // We need to pass different resource to Graphics 2D, 3D and Compositor
226 // right now. Once 3D is migrated to the new design, we should be able to
228 if (resource
->AsPPB_Graphics3D_API()) {
229 pp_resource
= resource
->host_resource().host_resource();
230 } else if (resource
->AsPPB_Graphics2D_API() ||
231 resource
->AsPPB_Compositor_API()) {
232 pp_resource
= resource
->pp_resource();
238 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
239 API_ID_PPB_INSTANCE
, instance
, pp_resource
));
243 PP_Bool
PPB_Instance_Proxy::IsFullFrame(PP_Instance instance
) {
244 PP_Bool result
= PP_FALSE
;
245 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame(
246 API_ID_PPB_INSTANCE
, instance
, &result
));
250 const ViewData
* PPB_Instance_Proxy::GetViewData(PP_Instance instance
) {
251 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
252 GetInstanceData(instance
);
258 PP_Bool
PPB_Instance_Proxy::FlashIsFullscreen(PP_Instance instance
) {
259 // This function is only used for proxying in the renderer process. It is not
260 // implemented in the plugin process.
265 PP_Var
PPB_Instance_Proxy::GetWindowObject(PP_Instance instance
) {
266 ReceiveSerializedVarReturnValue result
;
267 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetWindowObject(
268 API_ID_PPB_INSTANCE
, instance
, &result
));
269 return result
.Return(dispatcher());
272 PP_Var
PPB_Instance_Proxy::GetOwnerElementObject(PP_Instance instance
) {
273 ReceiveSerializedVarReturnValue result
;
274 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetOwnerElementObject(
275 API_ID_PPB_INSTANCE
, instance
, &result
));
276 return result
.Return(dispatcher());
279 PP_Var
PPB_Instance_Proxy::ExecuteScript(PP_Instance instance
,
282 ReceiveSerializedException
se(dispatcher(), exception
);
284 return PP_MakeUndefined();
286 ReceiveSerializedVarReturnValue result
;
287 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript(
288 API_ID_PPB_INSTANCE
, instance
,
289 SerializedVarSendInput(dispatcher(), script
), &se
, &result
));
290 return result
.Return(dispatcher());
293 uint32_t PPB_Instance_Proxy::GetAudioHardwareOutputSampleRate(
294 PP_Instance instance
) {
295 uint32_t result
= PP_AUDIOSAMPLERATE_NONE
;
297 new PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate(
298 API_ID_PPB_INSTANCE
, instance
, &result
));
302 uint32_t PPB_Instance_Proxy::GetAudioHardwareOutputBufferSize(
303 PP_Instance instance
) {
306 new PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize(
307 API_ID_PPB_INSTANCE
, instance
, &result
));
311 PP_Var
PPB_Instance_Proxy::GetDefaultCharSet(PP_Instance instance
) {
312 PluginDispatcher
* dispatcher
= PluginDispatcher::GetForInstance(instance
);
314 return PP_MakeUndefined();
316 ReceiveSerializedVarReturnValue result
;
317 dispatcher
->Send(new PpapiHostMsg_PPBInstance_GetDefaultCharSet(
318 API_ID_PPB_INSTANCE
, instance
, &result
));
319 return result
.Return(dispatcher
);
322 void PPB_Instance_Proxy::SetPluginToHandleFindRequests(PP_Instance instance
) {
323 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests(
324 API_ID_PPB_INSTANCE
, instance
));
327 void PPB_Instance_Proxy::NumberOfFindResultsChanged(PP_Instance instance
,
329 PP_Bool final_result
) {
330 dispatcher()->Send(new PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged(
331 API_ID_PPB_INSTANCE
, instance
, total
, final_result
));
334 void PPB_Instance_Proxy::SelectedFindResultChanged(PP_Instance instance
,
336 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SelectFindResultChanged(
337 API_ID_PPB_INSTANCE
, instance
, index
));
340 void PPB_Instance_Proxy::SetTickmarks(PP_Instance instance
,
341 const PP_Rect
* tickmarks
,
343 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTickmarks(
344 API_ID_PPB_INSTANCE
, instance
,
345 std::vector
<PP_Rect
>(tickmarks
, tickmarks
+ count
)));
348 PP_Bool
PPB_Instance_Proxy::IsFullscreen(PP_Instance instance
) {
349 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
350 GetInstanceData(instance
);
353 return PP_FromBool(data
->view
.is_fullscreen
);
356 PP_Bool
PPB_Instance_Proxy::SetFullscreen(PP_Instance instance
,
357 PP_Bool fullscreen
) {
358 PP_Bool result
= PP_FALSE
;
359 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetFullscreen(
360 API_ID_PPB_INSTANCE
, instance
, fullscreen
, &result
));
364 PP_Bool
PPB_Instance_Proxy::GetScreenSize(PP_Instance instance
,
366 PP_Bool result
= PP_FALSE
;
367 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetScreenSize(
368 API_ID_PPB_INSTANCE
, instance
, &result
, size
));
372 Resource
* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance
,
373 SingletonResourceID id
) {
374 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
375 GetInstanceData(instance
);
377 InstanceData::SingletonResourceMap::iterator it
=
378 data
->singleton_resources
.find(id
);
379 if (it
!= data
->singleton_resources
.end())
380 return it
->second
.get();
382 scoped_refptr
<Resource
> new_singleton
;
383 Connection
connection(PluginGlobals::Get()->GetBrowserSender(), dispatcher());
386 case BROKER_SINGLETON_ID
:
387 new_singleton
= new BrokerResource(connection
, instance
);
389 case FILE_MAPPING_SINGLETON_ID
:
390 new_singleton
= new FileMappingResource(connection
, instance
);
392 case GAMEPAD_SINGLETON_ID
:
393 new_singleton
= new GamepadResource(connection
, instance
);
395 case ISOLATED_FILESYSTEM_SINGLETON_ID
:
397 new IsolatedFileSystemPrivateResource(connection
, instance
);
399 case NETWORK_PROXY_SINGLETON_ID
:
400 new_singleton
= new NetworkProxyResource(connection
, instance
);
402 case TRUETYPE_FONT_SINGLETON_ID
:
403 new_singleton
= new TrueTypeFontSingletonResource(connection
, instance
);
405 case UMA_SINGLETON_ID
:
406 new_singleton
= new UMAPrivateResource(connection
, instance
);
408 // Flash/trusted resources aren't needed for NaCl.
409 #if !defined(OS_NACL) && !defined(NACL_WIN64)
410 case BROWSER_FONT_SINGLETON_ID
:
411 new_singleton
= new BrowserFontSingletonResource(connection
, instance
);
413 case FLASH_CLIPBOARD_SINGLETON_ID
:
414 new_singleton
= new FlashClipboardResource(connection
, instance
);
416 case FLASH_FILE_SINGLETON_ID
:
417 new_singleton
= new FlashFileResource(connection
, instance
);
419 case FLASH_FULLSCREEN_SINGLETON_ID
:
420 new_singleton
= new FlashFullscreenResource(connection
, instance
);
422 case FLASH_SINGLETON_ID
:
423 new_singleton
= new FlashResource(connection
, instance
,
424 static_cast<PluginDispatcher
*>(dispatcher()));
426 case PDF_SINGLETON_ID
:
427 new_singleton
= new PDFResource(connection
, instance
);
430 case BROWSER_FONT_SINGLETON_ID
:
431 case FLASH_CLIPBOARD_SINGLETON_ID
:
432 case FLASH_FILE_SINGLETON_ID
:
433 case FLASH_FULLSCREEN_SINGLETON_ID
:
434 case FLASH_SINGLETON_ID
:
435 case PDF_SINGLETON_ID
:
438 #endif // !defined(OS_NACL) && !defined(NACL_WIN64)
441 if (!new_singleton
.get()) {
442 // Getting here implies that a constructor is missing in the above switch.
447 data
->singleton_resources
[id
] = new_singleton
;
448 return new_singleton
.get();
451 int32_t PPB_Instance_Proxy::RequestInputEvents(PP_Instance instance
,
452 uint32_t event_classes
) {
453 dispatcher()->Send(new PpapiHostMsg_PPBInstance_RequestInputEvents(
454 API_ID_PPB_INSTANCE
, instance
, false, event_classes
));
456 // We always register for the classes we can handle, this function validates
457 // the flags so we can notify it if anything was invalid, without requiring
459 return ValidateRequestInputEvents(false, event_classes
);
462 int32_t PPB_Instance_Proxy::RequestFilteringInputEvents(
463 PP_Instance instance
,
464 uint32_t event_classes
) {
465 dispatcher()->Send(new PpapiHostMsg_PPBInstance_RequestInputEvents(
466 API_ID_PPB_INSTANCE
, instance
, true, event_classes
));
468 // We always register for the classes we can handle, this function validates
469 // the flags so we can notify it if anything was invalid, without requiring
471 return ValidateRequestInputEvents(true, event_classes
);
474 void PPB_Instance_Proxy::ClearInputEventRequest(PP_Instance instance
,
475 uint32_t event_classes
) {
476 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ClearInputEvents(
477 API_ID_PPB_INSTANCE
, instance
, event_classes
));
480 void PPB_Instance_Proxy::StartTrackingLatency(PP_Instance instance
) {
481 dispatcher()->Send(new PpapiHostMsg_PPBInstance_StartTrackingLatency(
482 API_ID_PPB_INSTANCE
, instance
));
485 void PPB_Instance_Proxy::ZoomChanged(PP_Instance instance
,
491 void PPB_Instance_Proxy::ZoomLimitsChanged(PP_Instance instance
,
492 double minimum_factor
,
493 double maximium_factor
) {
498 PP_Var
PPB_Instance_Proxy::GetDocumentURL(PP_Instance instance
,
499 PP_URLComponents_Dev
* components
) {
500 ReceiveSerializedVarReturnValue result
;
501 PP_URLComponents_Dev url_components
= {{0}};
502 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetDocumentURL(
503 API_ID_PPB_INSTANCE
, instance
, &url_components
, &result
));
505 *components
= url_components
;
506 return result
.Return(dispatcher());
509 #if !defined(OS_NACL)
510 PP_Var
PPB_Instance_Proxy::ResolveRelativeToDocument(
511 PP_Instance instance
,
513 PP_URLComponents_Dev
* components
) {
514 ReceiveSerializedVarReturnValue result
;
515 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ResolveRelativeToDocument(
516 API_ID_PPB_INSTANCE
, instance
,
517 SerializedVarSendInput(dispatcher(), relative
),
519 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
520 result
.Return(dispatcher()),
524 PP_Bool
PPB_Instance_Proxy::DocumentCanRequest(PP_Instance instance
,
526 PP_Bool result
= PP_FALSE
;
527 dispatcher()->Send(new PpapiHostMsg_PPBInstance_DocumentCanRequest(
528 API_ID_PPB_INSTANCE
, instance
,
529 SerializedVarSendInput(dispatcher(), url
),
534 PP_Bool
PPB_Instance_Proxy::DocumentCanAccessDocument(PP_Instance instance
,
535 PP_Instance target
) {
536 PP_Bool result
= PP_FALSE
;
537 dispatcher()->Send(new PpapiHostMsg_PPBInstance_DocumentCanAccessDocument(
538 API_ID_PPB_INSTANCE
, instance
, target
, &result
));
542 PP_Var
PPB_Instance_Proxy::GetPluginInstanceURL(
543 PP_Instance instance
,
544 PP_URLComponents_Dev
* components
) {
545 ReceiveSerializedVarReturnValue result
;
546 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginInstanceURL(
547 API_ID_PPB_INSTANCE
, instance
, &result
));
548 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
549 result
.Return(dispatcher()),
553 PP_Var
PPB_Instance_Proxy::GetPluginReferrerURL(
554 PP_Instance instance
,
555 PP_URLComponents_Dev
* components
) {
556 ReceiveSerializedVarReturnValue result
;
557 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginReferrerURL(
558 API_ID_PPB_INSTANCE
, instance
, &result
));
559 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
560 result
.Return(dispatcher()),
564 void PPB_Instance_Proxy::PromiseResolved(PP_Instance instance
,
566 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolved(
567 API_ID_PPB_INSTANCE
, instance
, promise_id
));
570 void PPB_Instance_Proxy::PromiseResolvedWithSession(PP_Instance instance
,
572 PP_Var web_session_id_var
) {
573 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseResolvedWithSession(
577 SerializedVarSendInput(dispatcher(), web_session_id_var
)));
580 void PPB_Instance_Proxy::PromiseRejected(PP_Instance instance
,
582 PP_CdmExceptionCode exception_code
,
584 PP_Var error_description_var
) {
585 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PromiseRejected(
591 SerializedVarSendInput(dispatcher(), error_description_var
)));
594 void PPB_Instance_Proxy::SessionMessage(PP_Instance instance
,
595 PP_Var web_session_id_var
,
597 PP_Var destination_url_var
) {
598 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage(
601 SerializedVarSendInput(dispatcher(), web_session_id_var
),
602 SerializedVarSendInput(dispatcher(), message_var
),
603 SerializedVarSendInput(dispatcher(), destination_url_var
)));
606 void PPB_Instance_Proxy::SessionReady(PP_Instance instance
,
607 PP_Var web_session_id_var
) {
608 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady(
611 SerializedVarSendInput(dispatcher(), web_session_id_var
)));
614 void PPB_Instance_Proxy::SessionClosed(PP_Instance instance
,
615 PP_Var web_session_id_var
) {
616 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed(
619 SerializedVarSendInput(dispatcher(), web_session_id_var
)));
622 void PPB_Instance_Proxy::SessionError(PP_Instance instance
,
623 PP_Var web_session_id_var
,
624 PP_CdmExceptionCode exception_code
,
626 PP_Var error_description_var
) {
627 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionError(
630 SerializedVarSendInput(dispatcher(), web_session_id_var
),
633 SerializedVarSendInput(dispatcher(), error_description_var
)));
636 void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance
,
637 PP_Resource decrypted_block
,
638 const PP_DecryptedBlockInfo
* block_info
) {
639 PP_Resource decrypted_block_host_resource
= 0;
641 if (decrypted_block
) {
643 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_block
);
644 if (!object
|| object
->pp_instance() != instance
) {
648 decrypted_block_host_resource
= object
->host_resource().host_resource();
651 std::string serialized_block_info
;
652 if (!SerializeBlockInfo(*block_info
, &serialized_block_info
)) {
658 new PpapiHostMsg_PPBInstance_DeliverBlock(API_ID_PPB_INSTANCE
,
660 decrypted_block_host_resource
,
661 serialized_block_info
));
664 void PPB_Instance_Proxy::DecoderInitializeDone(
665 PP_Instance instance
,
666 PP_DecryptorStreamType decoder_type
,
670 new PpapiHostMsg_PPBInstance_DecoderInitializeDone(
678 void PPB_Instance_Proxy::DecoderDeinitializeDone(
679 PP_Instance instance
,
680 PP_DecryptorStreamType decoder_type
,
681 uint32_t request_id
) {
683 new PpapiHostMsg_PPBInstance_DecoderDeinitializeDone(
690 void PPB_Instance_Proxy::DecoderResetDone(PP_Instance instance
,
691 PP_DecryptorStreamType decoder_type
,
692 uint32_t request_id
) {
694 new PpapiHostMsg_PPBInstance_DecoderResetDone(
701 void PPB_Instance_Proxy::DeliverFrame(PP_Instance instance
,
702 PP_Resource decrypted_frame
,
703 const PP_DecryptedFrameInfo
* frame_info
) {
704 PP_Resource host_resource
= 0;
705 if (decrypted_frame
!= 0) {
706 ResourceTracker
* tracker
= PpapiGlobals::Get()->GetResourceTracker();
707 Resource
* object
= tracker
->GetResource(decrypted_frame
);
709 if (!object
|| object
->pp_instance() != instance
) {
714 host_resource
= object
->host_resource().host_resource();
717 std::string serialized_frame_info
;
718 if (!SerializeBlockInfo(*frame_info
, &serialized_frame_info
)) {
724 new PpapiHostMsg_PPBInstance_DeliverFrame(API_ID_PPB_INSTANCE
,
727 serialized_frame_info
));
730 void PPB_Instance_Proxy::DeliverSamples(
731 PP_Instance instance
,
732 PP_Resource decrypted_samples
,
733 const PP_DecryptedSampleInfo
* sample_info
) {
734 PP_Resource host_resource
= 0;
735 if (decrypted_samples
!= 0) {
736 ResourceTracker
* tracker
= PpapiGlobals::Get()->GetResourceTracker();
737 Resource
* object
= tracker
->GetResource(decrypted_samples
);
739 if (!object
|| object
->pp_instance() != instance
) {
744 host_resource
= object
->host_resource().host_resource();
747 std::string serialized_sample_info
;
748 if (!SerializeBlockInfo(*sample_info
, &serialized_sample_info
)) {
754 new PpapiHostMsg_PPBInstance_DeliverSamples(API_ID_PPB_INSTANCE
,
757 serialized_sample_info
));
759 #endif // !defined(OS_NACL)
761 void PPB_Instance_Proxy::PostMessage(PP_Instance instance
,
763 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage(
765 instance
, SerializedVarSendInputShmem(dispatcher(), message
,
769 int32_t PPB_Instance_Proxy::RegisterMessageHandler(
770 PP_Instance instance
,
772 const PPP_MessageHandler_0_1
* handler
,
773 PP_Resource message_loop
) {
775 static_cast<PluginDispatcher
*>(dispatcher())->GetInstanceData(instance
);
777 return PP_ERROR_BADARGUMENT
;
779 int32_t result
= PP_ERROR_FAILED
;
780 scoped_ptr
<MessageHandler
> message_handler
= MessageHandler::Create(
781 instance
, handler
, user_data
, message_loop
, &result
);
783 data
->message_handler
= message_handler
.Pass();
787 void PPB_Instance_Proxy::UnregisterMessageHandler(PP_Instance instance
) {
789 static_cast<PluginDispatcher
*>(dispatcher())->GetInstanceData(instance
);
792 data
->message_handler
.reset();
795 PP_Bool
PPB_Instance_Proxy::SetCursor(PP_Instance instance
,
796 PP_MouseCursor_Type type
,
798 const PP_Point
* hot_spot
) {
799 // Some of these parameters are important for security. This check is in the
800 // plugin process just for the convenience of the caller (since we don't
801 // bother returning errors from the other process with a sync message). The
802 // parameters will be validated again in the renderer.
803 if (!ValidateSetCursorParams(type
, image
, hot_spot
))
806 HostResource image_host_resource
;
808 Resource
* cursor_image
=
809 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image
);
810 if (!cursor_image
|| cursor_image
->pp_instance() != instance
)
812 image_host_resource
= cursor_image
->host_resource();
815 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor(
816 API_ID_PPB_INSTANCE
, instance
, static_cast<int32_t>(type
),
817 image_host_resource
, hot_spot
? *hot_spot
: PP_MakePoint(0, 0)));
821 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance
,
822 scoped_refptr
<TrackedCallback
> callback
) {
823 // Save the mouse callback on the instance data.
824 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
825 GetInstanceData(instance
);
827 return PP_ERROR_BADARGUMENT
;
828 if (TrackedCallback::IsPending(data
->mouse_lock_callback
))
829 return PP_ERROR_INPROGRESS
; // Already have a pending callback.
830 data
->mouse_lock_callback
= callback
;
832 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse(
833 API_ID_PPB_INSTANCE
, instance
));
834 return PP_OK_COMPLETIONPENDING
;
837 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance
) {
838 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse(
839 API_ID_PPB_INSTANCE
, instance
));
842 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance
,
843 PP_TextInput_Type type
) {
844 CancelAnyPendingRequestSurroundingText(instance
);
845 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType(
846 API_ID_PPB_INSTANCE
, instance
, type
));
849 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance
,
850 const PP_Rect
& caret
,
851 const PP_Rect
& bounding_box
) {
852 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateCaretPosition(
853 API_ID_PPB_INSTANCE
, instance
, caret
, bounding_box
));
856 void PPB_Instance_Proxy::CancelCompositionText(PP_Instance instance
) {
857 CancelAnyPendingRequestSurroundingText(instance
);
858 dispatcher()->Send(new PpapiHostMsg_PPBInstance_CancelCompositionText(
859 API_ID_PPB_INSTANCE
, instance
));
862 void PPB_Instance_Proxy::SelectionChanged(PP_Instance instance
) {
863 // The "right" way to do this is to send the message to the host. However,
864 // all it will do is call RequestSurroundingText with a hardcoded number of
865 // characters in response, which is an entire IPC round-trip.
867 // We can avoid this round-trip by just implementing the
868 // RequestSurroundingText logic in the plugin process. If the logic in the
869 // host becomes more complex (like a more adaptive number of characters),
870 // we'll need to reevanuate whether we want to do the round trip instead.
872 // Be careful to post a task to avoid reentering the plugin.
875 static_cast<PluginDispatcher
*>(dispatcher())->GetInstanceData(instance
);
878 data
->should_do_request_surrounding_text
= true;
880 if (!data
->is_request_surrounding_text_pending
) {
881 base::MessageLoop::current()->PostTask(
883 RunWhileLocked(base::Bind(&RequestSurroundingText
, instance
)));
884 data
->is_request_surrounding_text_pending
= true;
888 void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance
,
892 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateSurroundingText(
893 API_ID_PPB_INSTANCE
, instance
, text
, caret
, anchor
));
896 #if !defined(OS_NACL)
897 void PPB_Instance_Proxy::OnHostMsgGetWindowObject(
898 PP_Instance instance
,
899 SerializedVarReturnValue result
) {
900 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
902 EnterInstanceNoLock
enter(instance
);
903 if (enter
.succeeded())
904 result
.Return(dispatcher(), enter
.functions()->GetWindowObject(instance
));
907 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject(
908 PP_Instance instance
,
909 SerializedVarReturnValue result
) {
910 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
912 EnterInstanceNoLock
enter(instance
);
913 if (enter
.succeeded()) {
914 result
.Return(dispatcher(),
915 enter
.functions()->GetOwnerElementObject(instance
));
919 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance
,
920 PP_Resource device
) {
921 // Note that we ignroe the return value here. Otherwise, this would need to
922 // be a slow sync call, and the plugin side of the proxy will have already
923 // validated the resources, so we shouldn't see errors here that weren't
925 EnterInstanceNoLock
enter(instance
);
926 if (enter
.succeeded())
927 enter
.functions()->BindGraphics(instance
, device
);
930 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate(
931 PP_Instance instance
, uint32_t* result
) {
932 EnterInstanceNoLock
enter(instance
);
933 if (enter
.succeeded())
934 *result
= enter
.functions()->GetAudioHardwareOutputSampleRate(instance
);
937 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize(
938 PP_Instance instance
, uint32_t* result
) {
939 EnterInstanceNoLock
enter(instance
);
940 if (enter
.succeeded())
941 *result
= enter
.functions()->GetAudioHardwareOutputBufferSize(instance
);
944 void PPB_Instance_Proxy::OnHostMsgIsFullFrame(PP_Instance instance
,
946 EnterInstanceNoLock
enter(instance
);
947 if (enter
.succeeded())
948 *result
= enter
.functions()->IsFullFrame(instance
);
951 void PPB_Instance_Proxy::OnHostMsgExecuteScript(
952 PP_Instance instance
,
953 SerializedVarReceiveInput script
,
954 SerializedVarOutParam out_exception
,
955 SerializedVarReturnValue result
) {
956 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
958 EnterInstanceNoLock
enter(instance
);
962 if (dispatcher()->IsPlugin())
965 static_cast<HostDispatcher
*>(dispatcher())->set_allow_plugin_reentrancy();
967 result
.Return(dispatcher(), enter
.functions()->ExecuteScript(
969 script
.Get(dispatcher()),
970 out_exception
.OutParam(dispatcher())));
973 void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet(
974 PP_Instance instance
,
975 SerializedVarReturnValue result
) {
976 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
978 EnterInstanceNoLock
enter(instance
);
979 if (enter
.succeeded())
980 result
.Return(dispatcher(), enter
.functions()->GetDefaultCharSet(instance
));
983 void PPB_Instance_Proxy::OnHostMsgSetPluginToHandleFindRequests(
984 PP_Instance instance
) {
985 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
987 EnterInstanceNoLock
enter(instance
);
988 if (enter
.succeeded())
989 enter
.functions()->SetPluginToHandleFindRequests(instance
);
992 void PPB_Instance_Proxy::OnHostMsgNumberOfFindResultsChanged(
993 PP_Instance instance
,
995 PP_Bool final_result
) {
996 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
998 EnterInstanceNoLock
enter(instance
);
999 if (enter
.succeeded()) {
1000 enter
.functions()->NumberOfFindResultsChanged(
1001 instance
, total
, final_result
);
1005 void PPB_Instance_Proxy::OnHostMsgSelectFindResultChanged(
1006 PP_Instance instance
,
1008 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1010 EnterInstanceNoLock
enter(instance
);
1011 if (enter
.succeeded())
1012 enter
.functions()->SelectedFindResultChanged(instance
, index
);
1015 void PPB_Instance_Proxy::OnHostMsgSetTickmarks(
1016 PP_Instance instance
,
1017 const std::vector
<PP_Rect
>& tickmarks
) {
1018 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1020 const PP_Rect
* array
= tickmarks
.empty() ? NULL
: &tickmarks
[0];
1021 EnterInstanceNoLock
enter(instance
);
1022 if (enter
.succeeded()) {
1023 enter
.functions()->SetTickmarks(instance
,
1025 static_cast<uint32_t>(tickmarks
.size()));
1029 void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance
,
1032 EnterInstanceNoLock
enter(instance
);
1033 if (enter
.succeeded())
1034 *result
= enter
.functions()->SetFullscreen(instance
, fullscreen
);
1038 void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance
,
1041 EnterInstanceNoLock
enter(instance
);
1042 if (enter
.succeeded())
1043 *result
= enter
.functions()->GetScreenSize(instance
, size
);
1046 void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance
,
1048 uint32_t event_classes
) {
1049 EnterInstanceNoLock
enter(instance
);
1050 if (enter
.succeeded()) {
1052 enter
.functions()->RequestFilteringInputEvents(instance
, event_classes
);
1054 enter
.functions()->RequestInputEvents(instance
, event_classes
);
1058 void PPB_Instance_Proxy::OnHostMsgClearInputEvents(PP_Instance instance
,
1059 uint32_t event_classes
) {
1060 EnterInstanceNoLock
enter(instance
);
1061 if (enter
.succeeded())
1062 enter
.functions()->ClearInputEventRequest(instance
, event_classes
);
1065 void PPB_Instance_Proxy::OnHostMsgStartTrackingLatency(PP_Instance instance
) {
1066 EnterInstanceNoLock
enter(instance
);
1067 if (enter
.succeeded())
1068 enter
.functions()->StartTrackingLatency(instance
);
1071 void PPB_Instance_Proxy::OnHostMsgPostMessage(
1072 PP_Instance instance
,
1073 SerializedVarReceiveInput message
) {
1074 EnterInstanceNoLock
enter(instance
);
1075 if (!message
.is_valid_var()) {
1076 PpapiGlobals::Get()->LogWithSource(
1077 instance
, PP_LOGLEVEL_ERROR
, std::string(), kSerializationError
);
1081 if (enter
.succeeded())
1082 enter
.functions()->PostMessage(instance
,
1083 message
.GetForInstance(dispatcher(),
1087 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance
) {
1088 // Need to be careful to always issue the callback.
1089 pp::CompletionCallback cb
= callback_factory_
.NewCallback(
1090 &PPB_Instance_Proxy::MouseLockCompleteInHost
, instance
);
1092 EnterInstanceNoLock
enter(instance
, cb
.pp_completion_callback());
1093 if (enter
.succeeded())
1094 enter
.SetResult(enter
.functions()->LockMouse(instance
, enter
.callback()));
1097 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance
) {
1098 EnterInstanceNoLock
enter(instance
);
1099 if (enter
.succeeded())
1100 enter
.functions()->UnlockMouse(instance
);
1103 void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(
1104 PP_Instance instance
,
1105 PP_URLComponents_Dev
* components
,
1106 SerializedVarReturnValue result
) {
1107 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1109 EnterInstanceNoLock
enter(instance
);
1110 if (enter
.succeeded()) {
1111 PP_Var document_url
= enter
.functions()->GetDocumentURL(instance
,
1113 result
.Return(dispatcher(), document_url
);
1117 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument(
1118 PP_Instance instance
,
1119 SerializedVarReceiveInput relative
,
1120 SerializedVarReturnValue result
) {
1121 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1123 EnterInstanceNoLock
enter(instance
);
1124 if (enter
.succeeded()) {
1125 result
.Return(dispatcher(),
1126 enter
.functions()->ResolveRelativeToDocument(
1127 instance
, relative
.Get(dispatcher()), NULL
));
1131 void PPB_Instance_Proxy::OnHostMsgDocumentCanRequest(
1132 PP_Instance instance
,
1133 SerializedVarReceiveInput url
,
1135 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1137 EnterInstanceNoLock
enter(instance
);
1138 if (enter
.succeeded()) {
1139 *result
= enter
.functions()->DocumentCanRequest(instance
,
1140 url
.Get(dispatcher()));
1144 void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active
,
1147 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1149 EnterInstanceNoLock
enter(active
);
1150 if (enter
.succeeded())
1151 *result
= enter
.functions()->DocumentCanAccessDocument(active
, target
);
1154 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL(
1155 PP_Instance instance
,
1156 SerializedVarReturnValue result
) {
1157 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1159 EnterInstanceNoLock
enter(instance
);
1160 if (enter
.succeeded()) {
1161 result
.Return(dispatcher(),
1162 enter
.functions()->GetPluginInstanceURL(instance
, NULL
));
1166 void PPB_Instance_Proxy::OnHostMsgGetPluginReferrerURL(
1167 PP_Instance instance
,
1168 SerializedVarReturnValue result
) {
1169 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1171 EnterInstanceNoLock
enter(instance
);
1172 if (enter
.succeeded()) {
1173 result
.Return(dispatcher(),
1174 enter
.functions()->GetPluginReferrerURL(instance
, NULL
));
1178 void PPB_Instance_Proxy::OnHostMsgPromiseResolved(PP_Instance instance
,
1179 uint32_t promise_id
) {
1180 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1182 EnterInstanceNoLock
enter(instance
);
1183 if (enter
.succeeded()) {
1184 enter
.functions()->PromiseResolved(instance
, promise_id
);
1188 void PPB_Instance_Proxy::OnHostMsgPromiseResolvedWithSession(
1189 PP_Instance instance
,
1190 uint32_t promise_id
,
1191 SerializedVarReceiveInput web_session_id
) {
1192 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1194 EnterInstanceNoLock
enter(instance
);
1195 if (enter
.succeeded()) {
1196 enter
.functions()->PromiseResolvedWithSession(
1197 instance
, promise_id
, web_session_id
.Get(dispatcher()));
1201 void PPB_Instance_Proxy::OnHostMsgPromiseRejected(
1202 PP_Instance instance
,
1203 uint32_t promise_id
,
1204 PP_CdmExceptionCode exception_code
,
1205 uint32_t system_code
,
1206 SerializedVarReceiveInput error_description
) {
1207 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1209 EnterInstanceNoLock
enter(instance
);
1210 if (enter
.succeeded()) {
1211 enter
.functions()->PromiseRejected(instance
,
1215 error_description
.Get(dispatcher()));
1219 void PPB_Instance_Proxy::OnHostMsgSessionMessage(
1220 PP_Instance instance
,
1221 SerializedVarReceiveInput web_session_id
,
1222 SerializedVarReceiveInput message
,
1223 SerializedVarReceiveInput destination_url
) {
1224 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1226 EnterInstanceNoLock
enter(instance
);
1227 if (enter
.succeeded()) {
1228 enter
.functions()->SessionMessage(instance
,
1229 web_session_id
.Get(dispatcher()),
1230 message
.Get(dispatcher()),
1231 destination_url
.Get(dispatcher()));
1235 void PPB_Instance_Proxy::OnHostMsgSessionReady(
1236 PP_Instance instance
,
1237 SerializedVarReceiveInput web_session_id
) {
1238 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1240 EnterInstanceNoLock
enter(instance
);
1241 if (enter
.succeeded()) {
1242 enter
.functions()->SessionReady(instance
, web_session_id
.Get(dispatcher()));
1246 void PPB_Instance_Proxy::OnHostMsgSessionClosed(
1247 PP_Instance instance
,
1248 SerializedVarReceiveInput web_session_id
) {
1249 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1251 EnterInstanceNoLock
enter(instance
);
1252 if (enter
.succeeded()) {
1253 enter
.functions()->SessionClosed(instance
,
1254 web_session_id
.Get(dispatcher()));
1258 void PPB_Instance_Proxy::OnHostMsgSessionError(
1259 PP_Instance instance
,
1260 SerializedVarReceiveInput web_session_id
,
1261 PP_CdmExceptionCode exception_code
,
1262 uint32_t system_code
,
1263 SerializedVarReceiveInput error_description
) {
1264 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1266 EnterInstanceNoLock
enter(instance
);
1267 if (enter
.succeeded()) {
1268 enter
.functions()->SessionError(instance
,
1269 web_session_id
.Get(dispatcher()),
1272 error_description
.Get(dispatcher()));
1276 void PPB_Instance_Proxy::OnHostMsgDeliverBlock(
1277 PP_Instance instance
,
1278 PP_Resource decrypted_block
,
1279 const std::string
& serialized_block_info
) {
1280 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1282 PP_DecryptedBlockInfo block_info
;
1283 if (!DeserializeBlockInfo(serialized_block_info
, &block_info
))
1286 EnterInstanceNoLock
enter(instance
);
1287 if (enter
.succeeded())
1288 enter
.functions()->DeliverBlock(instance
, decrypted_block
, &block_info
);
1291 void PPB_Instance_Proxy::OnHostMsgDecoderInitializeDone(
1292 PP_Instance instance
,
1293 PP_DecryptorStreamType decoder_type
,
1294 uint32_t request_id
,
1296 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1298 EnterInstanceNoLock
enter(instance
);
1299 if (enter
.succeeded()) {
1300 enter
.functions()->DecoderInitializeDone(instance
,
1307 void PPB_Instance_Proxy::OnHostMsgDecoderDeinitializeDone(
1308 PP_Instance instance
,
1309 PP_DecryptorStreamType decoder_type
,
1310 uint32_t request_id
) {
1311 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1313 EnterInstanceNoLock
enter(instance
);
1314 if (enter
.succeeded())
1315 enter
.functions()->DecoderDeinitializeDone(instance
,
1320 void PPB_Instance_Proxy::OnHostMsgDecoderResetDone(
1321 PP_Instance instance
,
1322 PP_DecryptorStreamType decoder_type
,
1323 uint32_t request_id
) {
1324 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1326 EnterInstanceNoLock
enter(instance
);
1327 if (enter
.succeeded())
1328 enter
.functions()->DecoderResetDone(instance
, decoder_type
, request_id
);
1331 void PPB_Instance_Proxy::OnHostMsgDeliverFrame(
1332 PP_Instance instance
,
1333 PP_Resource decrypted_frame
,
1334 const std::string
& serialized_frame_info
) {
1335 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1337 PP_DecryptedFrameInfo frame_info
;
1338 if (!DeserializeBlockInfo(serialized_frame_info
, &frame_info
))
1341 EnterInstanceNoLock
enter(instance
);
1342 if (enter
.succeeded())
1343 enter
.functions()->DeliverFrame(instance
, decrypted_frame
, &frame_info
);
1346 void PPB_Instance_Proxy::OnHostMsgDeliverSamples(
1347 PP_Instance instance
,
1348 PP_Resource audio_frames
,
1349 const std::string
& serialized_sample_info
) {
1350 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1352 PP_DecryptedSampleInfo sample_info
;
1353 if (!DeserializeBlockInfo(serialized_sample_info
, &sample_info
))
1356 EnterInstanceNoLock
enter(instance
);
1357 if (enter
.succeeded())
1358 enter
.functions()->DeliverSamples(instance
, audio_frames
, &sample_info
);
1361 void PPB_Instance_Proxy::OnHostMsgSetCursor(
1362 PP_Instance instance
,
1364 const ppapi::HostResource
& custom_image
,
1365 const PP_Point
& hot_spot
) {
1366 // This API serves PPB_CursorControl_Dev and PPB_MouseCursor, so is public.
1367 EnterInstanceNoLock
enter(instance
);
1368 if (enter
.succeeded()) {
1369 enter
.functions()->SetCursor(
1370 instance
, static_cast<PP_MouseCursor_Type
>(type
),
1371 custom_image
.host_resource(), &hot_spot
);
1375 void PPB_Instance_Proxy::OnHostMsgSetTextInputType(PP_Instance instance
,
1376 PP_TextInput_Type type
) {
1377 EnterInstanceNoLock
enter(instance
);
1378 if (enter
.succeeded())
1379 enter
.functions()->SetTextInputType(instance
, type
);
1382 void PPB_Instance_Proxy::OnHostMsgUpdateCaretPosition(
1383 PP_Instance instance
,
1384 const PP_Rect
& caret
,
1385 const PP_Rect
& bounding_box
) {
1386 EnterInstanceNoLock
enter(instance
);
1387 if (enter
.succeeded())
1388 enter
.functions()->UpdateCaretPosition(instance
, caret
, bounding_box
);
1391 void PPB_Instance_Proxy::OnHostMsgCancelCompositionText(PP_Instance instance
) {
1392 EnterInstanceNoLock
enter(instance
);
1393 if (enter
.succeeded())
1394 enter
.functions()->CancelCompositionText(instance
);
1397 void PPB_Instance_Proxy::OnHostMsgUpdateSurroundingText(
1398 PP_Instance instance
,
1399 const std::string
& text
,
1402 EnterInstanceNoLock
enter(instance
);
1403 if (enter
.succeeded()) {
1404 enter
.functions()->UpdateSurroundingText(instance
, text
.c_str(), caret
,
1408 #endif // !defined(OS_NACL)
1410 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance
,
1412 if (!dispatcher()->IsPlugin())
1415 // Save the mouse callback on the instance data.
1416 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
1417 GetInstanceData(instance
);
1419 return; // Instance was probably deleted.
1420 if (!TrackedCallback::IsPending(data
->mouse_lock_callback
)) {
1424 data
->mouse_lock_callback
->Run(result
);
1427 #if !defined(OS_NACL)
1428 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result
,
1429 PP_Instance instance
) {
1430 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
1431 API_ID_PPB_INSTANCE
, instance
, result
));
1433 #endif // !defined(OS_NACL)
1435 void PPB_Instance_Proxy::CancelAnyPendingRequestSurroundingText(
1436 PP_Instance instance
) {
1437 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
1438 GetInstanceData(instance
);
1440 return; // Instance was probably deleted.
1441 data
->should_do_request_surrounding_text
= false;
1444 } // namespace proxy
1445 } // namespace ppapi