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/extensions_common_resource.h"
22 #include "ppapi/proxy/file_mapping_resource.h"
23 #include "ppapi/proxy/flash_clipboard_resource.h"
24 #include "ppapi/proxy/flash_file_resource.h"
25 #include "ppapi/proxy/flash_fullscreen_resource.h"
26 #include "ppapi/proxy/flash_resource.h"
27 #include "ppapi/proxy/gamepad_resource.h"
28 #include "ppapi/proxy/host_dispatcher.h"
29 #include "ppapi/proxy/isolated_file_system_private_resource.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_graphics_2d_api.h"
43 #include "ppapi/thunk/ppb_graphics_3d_api.h"
44 #include "ppapi/thunk/thunk.h"
46 // Windows headers interfere with this file.
51 using ppapi::thunk::EnterInstanceNoLock
;
52 using ppapi::thunk::EnterResourceNoLock
;
53 using ppapi::thunk::PPB_Graphics2D_API
;
54 using ppapi::thunk::PPB_Graphics3D_API
;
55 using ppapi::thunk::PPB_Instance_API
;
63 const char kSerializationError
[] = "Failed to convert a PostMessage "
64 "argument from a PP_Var to a Javascript value. It may have cycles or be of "
65 "an unsupported type.";
68 void RequestSurroundingText(PP_Instance instance
) {
69 PluginDispatcher
* dispatcher
= PluginDispatcher::GetForInstance(instance
);
71 return; // Instance has gone away while message was pending.
73 InstanceData
* data
= dispatcher
->GetInstanceData(instance
);
74 DCHECK(data
); // Should have it, since we still have a dispatcher.
75 data
->is_request_surrounding_text_pending
= false;
76 if (!data
->should_do_request_surrounding_text
)
79 // Just fake out a RequestSurroundingText message to the proxy for the PPP
81 InterfaceProxy
* proxy
= dispatcher
->GetInterfaceProxy(API_ID_PPP_TEXT_INPUT
);
84 proxy
->OnMessageReceived(PpapiMsg_PPPTextInput_RequestSurroundingText(
85 API_ID_PPP_TEXT_INPUT
, instance
,
86 PPB_Instance_Shared::kExtraCharsForTextInput
));
91 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher
* dispatcher
)
92 : InterfaceProxy(dispatcher
),
93 callback_factory_(this) {
96 PPB_Instance_Proxy::~PPB_Instance_Proxy() {
99 bool PPB_Instance_Proxy::OnMessageReceived(const IPC::Message
& msg
) {
100 // Prevent the dispatcher from going away during a call to ExecuteScript.
101 // This must happen OUTSIDE of ExecuteScript since the SerializedVars use
102 // the dispatcher upon return of the function (converting the
103 // SerializedVarReturnValue/OutParam to a SerializedVar in the destructor).
104 #if !defined(OS_NACL)
105 ScopedModuleReference
death_grip(dispatcher());
109 IPC_BEGIN_MESSAGE_MAP(PPB_Instance_Proxy
, msg
)
110 #if !defined(OS_NACL)
111 // Plugin -> Host messages.
112 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject
,
113 OnHostMsgGetWindowObject
)
114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject
,
115 OnHostMsgGetOwnerElementObject
)
116 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics
,
117 OnHostMsgBindGraphics
)
118 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame
,
119 OnHostMsgIsFullFrame
)
121 PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate
,
122 OnHostMsgGetAudioHardwareOutputSampleRate
)
124 PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize
,
125 OnHostMsgGetAudioHardwareOutputBufferSize
)
126 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript
,
127 OnHostMsgExecuteScript
)
128 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDefaultCharSet
,
129 OnHostMsgGetDefaultCharSet
)
130 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests
,
131 OnHostMsgSetPluginToHandleFindRequests
);
132 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged
,
133 OnHostMsgNumberOfFindResultsChanged
)
134 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SelectFindResultChanged
,
135 OnHostMsgSelectFindResultChanged
)
136 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTickmarks
,
137 OnHostMsgSetTickmarks
)
138 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage
,
139 OnHostMsgPostMessage
)
140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen
,
141 OnHostMsgSetFullscreen
)
142 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize
,
143 OnHostMsgGetScreenSize
)
144 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents
,
145 OnHostMsgRequestInputEvents
)
146 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents
,
147 OnHostMsgClearInputEvents
)
148 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_StartTrackingLatency
,
149 OnHostMsgStartTrackingLatency
)
150 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LockMouse
,
152 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UnlockMouse
,
153 OnHostMsgUnlockMouse
)
154 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor
,
156 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetTextInputType
,
157 OnHostMsgSetTextInputType
)
158 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateCaretPosition
,
159 OnHostMsgUpdateCaretPosition
)
160 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_CancelCompositionText
,
161 OnHostMsgCancelCompositionText
)
162 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_UpdateSurroundingText
,
163 OnHostMsgUpdateSurroundingText
)
164 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL
,
165 OnHostMsgGetDocumentURL
)
166 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument
,
167 OnHostMsgResolveRelativeToDocument
)
168 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest
,
169 OnHostMsgDocumentCanRequest
)
170 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument
,
171 OnHostMsgDocumentCanAccessDocument
)
172 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL
,
173 OnHostMsgGetPluginInstanceURL
)
174 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginReferrerURL
,
175 OnHostMsgGetPluginReferrerURL
)
176 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionCreated
,
177 OnHostMsgSessionCreated
)
178 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionMessage
,
179 OnHostMsgSessionMessage
)
180 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionReady
,
181 OnHostMsgSessionReady
)
182 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionClosed
,
183 OnHostMsgSessionClosed
)
184 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SessionError
,
185 OnHostMsgSessionError
)
186 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverBlock
,
187 OnHostMsgDeliverBlock
)
188 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderInitializeDone
,
189 OnHostMsgDecoderInitializeDone
)
190 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderDeinitializeDone
,
191 OnHostMsgDecoderDeinitializeDone
)
192 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DecoderResetDone
,
193 OnHostMsgDecoderResetDone
)
194 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverFrame
,
195 OnHostMsgDeliverFrame
)
196 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DeliverSamples
,
197 OnHostMsgDeliverSamples
)
198 #endif // !defined(OS_NACL)
200 // Host -> Plugin messages.
201 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete
,
202 OnPluginMsgMouseLockComplete
)
204 IPC_MESSAGE_UNHANDLED(handled
= false)
205 IPC_END_MESSAGE_MAP()
209 PP_Bool
PPB_Instance_Proxy::BindGraphics(PP_Instance instance
,
210 PP_Resource device
) {
211 // If device is 0, pass a null HostResource. This signals the host to unbind
213 HostResource host_resource
;
214 PP_Resource pp_resource
= 0;
217 PpapiGlobals::Get()->GetResourceTracker()->GetResource(device
);
218 if (!resource
|| resource
->pp_instance() != instance
)
220 host_resource
= resource
->host_resource();
221 pp_resource
= resource
->pp_resource();
223 // Passing 0 means unbinding all devices.
224 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
225 API_ID_PPB_INSTANCE
, instance
, 0));
229 // We need to pass different resource to Graphics 2D and 3D right now. Once
230 // 3D is migrated to the new design, we should be able to unify this.
231 EnterResourceNoLock
<PPB_Graphics2D_API
> enter_2d(device
, false);
232 EnterResourceNoLock
<PPB_Graphics3D_API
> enter_3d(device
, false);
233 if (enter_2d
.succeeded()) {
234 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
235 API_ID_PPB_INSTANCE
, instance
, pp_resource
));
237 } else if (enter_3d
.succeeded()) {
238 dispatcher()->Send(new PpapiHostMsg_PPBInstance_BindGraphics(
239 API_ID_PPB_INSTANCE
, instance
, host_resource
.host_resource()));
245 PP_Bool
PPB_Instance_Proxy::IsFullFrame(PP_Instance instance
) {
246 PP_Bool result
= PP_FALSE
;
247 dispatcher()->Send(new PpapiHostMsg_PPBInstance_IsFullFrame(
248 API_ID_PPB_INSTANCE
, instance
, &result
));
252 const ViewData
* PPB_Instance_Proxy::GetViewData(PP_Instance instance
) {
253 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
254 GetInstanceData(instance
);
260 PP_Bool
PPB_Instance_Proxy::FlashIsFullscreen(PP_Instance instance
) {
261 // This function is only used for proxying in the renderer process. It is not
262 // implemented in the plugin process.
267 PP_Var
PPB_Instance_Proxy::GetWindowObject(PP_Instance instance
) {
268 ReceiveSerializedVarReturnValue result
;
269 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetWindowObject(
270 API_ID_PPB_INSTANCE
, instance
, &result
));
271 return result
.Return(dispatcher());
274 PP_Var
PPB_Instance_Proxy::GetOwnerElementObject(PP_Instance instance
) {
275 ReceiveSerializedVarReturnValue result
;
276 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetOwnerElementObject(
277 API_ID_PPB_INSTANCE
, instance
, &result
));
278 return result
.Return(dispatcher());
281 PP_Var
PPB_Instance_Proxy::ExecuteScript(PP_Instance instance
,
284 ReceiveSerializedException
se(dispatcher(), exception
);
286 return PP_MakeUndefined();
288 ReceiveSerializedVarReturnValue result
;
289 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript(
290 API_ID_PPB_INSTANCE
, instance
,
291 SerializedVarSendInput(dispatcher(), script
), &se
, &result
));
292 return result
.Return(dispatcher());
295 uint32_t PPB_Instance_Proxy::GetAudioHardwareOutputSampleRate(
296 PP_Instance instance
) {
297 uint32_t result
= PP_AUDIOSAMPLERATE_NONE
;
299 new PpapiHostMsg_PPBInstance_GetAudioHardwareOutputSampleRate(
300 API_ID_PPB_INSTANCE
, instance
, &result
));
304 uint32_t PPB_Instance_Proxy::GetAudioHardwareOutputBufferSize(
305 PP_Instance instance
) {
308 new PpapiHostMsg_PPBInstance_GetAudioHardwareOutputBufferSize(
309 API_ID_PPB_INSTANCE
, instance
, &result
));
313 PP_Var
PPB_Instance_Proxy::GetDefaultCharSet(PP_Instance instance
) {
314 PluginDispatcher
* dispatcher
= PluginDispatcher::GetForInstance(instance
);
316 return PP_MakeUndefined();
318 ReceiveSerializedVarReturnValue result
;
319 dispatcher
->Send(new PpapiHostMsg_PPBInstance_GetDefaultCharSet(
320 API_ID_PPB_INSTANCE
, instance
, &result
));
321 return result
.Return(dispatcher
);
324 void PPB_Instance_Proxy::SetPluginToHandleFindRequests(PP_Instance instance
) {
325 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetPluginToHandleFindRequests(
326 API_ID_PPB_INSTANCE
, instance
));
329 void PPB_Instance_Proxy::NumberOfFindResultsChanged(PP_Instance instance
,
331 PP_Bool final_result
) {
332 dispatcher()->Send(new PpapiHostMsg_PPBInstance_NumberOfFindResultsChanged(
333 API_ID_PPB_INSTANCE
, instance
, total
, final_result
));
336 void PPB_Instance_Proxy::SelectedFindResultChanged(PP_Instance instance
,
338 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SelectFindResultChanged(
339 API_ID_PPB_INSTANCE
, instance
, index
));
342 void PPB_Instance_Proxy::SetTickmarks(PP_Instance instance
,
343 const PP_Rect
* tickmarks
,
345 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTickmarks(
346 API_ID_PPB_INSTANCE
, instance
,
347 std::vector
<PP_Rect
>(tickmarks
, tickmarks
+ count
)));
350 PP_Bool
PPB_Instance_Proxy::IsFullscreen(PP_Instance instance
) {
351 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
352 GetInstanceData(instance
);
355 return PP_FromBool(data
->view
.is_fullscreen
);
358 PP_Bool
PPB_Instance_Proxy::SetFullscreen(PP_Instance instance
,
359 PP_Bool fullscreen
) {
360 PP_Bool result
= PP_FALSE
;
361 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetFullscreen(
362 API_ID_PPB_INSTANCE
, instance
, fullscreen
, &result
));
366 PP_Bool
PPB_Instance_Proxy::GetScreenSize(PP_Instance instance
,
368 PP_Bool result
= PP_FALSE
;
369 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetScreenSize(
370 API_ID_PPB_INSTANCE
, instance
, &result
, size
));
374 Resource
* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance
,
375 SingletonResourceID id
) {
376 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
377 GetInstanceData(instance
);
379 InstanceData::SingletonResourceMap::iterator it
=
380 data
->singleton_resources
.find(id
);
381 if (it
!= data
->singleton_resources
.end())
382 return it
->second
.get();
384 scoped_refptr
<Resource
> new_singleton
;
385 Connection
connection(PluginGlobals::Get()->GetBrowserSender(), dispatcher());
388 case BROKER_SINGLETON_ID
:
389 new_singleton
= new BrokerResource(connection
, instance
);
391 case EXTENSIONS_COMMON_SINGLETON_ID
:
392 new_singleton
= new ExtensionsCommonResource(connection
, instance
);
394 case FILE_MAPPING_SINGLETON_ID
:
395 new_singleton
= new FileMappingResource(connection
, instance
);
397 case GAMEPAD_SINGLETON_ID
:
398 new_singleton
= new GamepadResource(connection
, instance
);
400 case ISOLATED_FILESYSTEM_SINGLETON_ID
:
402 new IsolatedFileSystemPrivateResource(connection
, instance
);
404 case NETWORK_PROXY_SINGLETON_ID
:
405 new_singleton
= new NetworkProxyResource(connection
, instance
);
407 case TRUETYPE_FONT_SINGLETON_ID
:
408 new_singleton
= new TrueTypeFontSingletonResource(connection
, instance
);
410 case UMA_SINGLETON_ID
:
411 new_singleton
= new UMAPrivateResource(connection
, instance
);
413 // Flash/trusted resources aren't needed for NaCl.
414 #if !defined(OS_NACL) && !defined(NACL_WIN64)
415 case BROWSER_FONT_SINGLETON_ID
:
416 new_singleton
= new BrowserFontSingletonResource(connection
, instance
);
418 case FLASH_CLIPBOARD_SINGLETON_ID
:
419 new_singleton
= new FlashClipboardResource(connection
, instance
);
421 case FLASH_FILE_SINGLETON_ID
:
422 new_singleton
= new FlashFileResource(connection
, instance
);
424 case FLASH_FULLSCREEN_SINGLETON_ID
:
425 new_singleton
= new FlashFullscreenResource(connection
, instance
);
427 case FLASH_SINGLETON_ID
:
428 new_singleton
= new FlashResource(connection
, instance
,
429 static_cast<PluginDispatcher
*>(dispatcher()));
431 case PDF_SINGLETON_ID
:
432 new_singleton
= new PDFResource(connection
, instance
);
435 case BROWSER_FONT_SINGLETON_ID
:
436 case FLASH_CLIPBOARD_SINGLETON_ID
:
437 case FLASH_FILE_SINGLETON_ID
:
438 case FLASH_FULLSCREEN_SINGLETON_ID
:
439 case FLASH_SINGLETON_ID
:
440 case PDF_SINGLETON_ID
:
443 #endif // !defined(OS_NACL) && !defined(NACL_WIN64)
446 if (!new_singleton
.get()) {
447 // Getting here implies that a constructor is missing in the above switch.
452 data
->singleton_resources
[id
] = new_singleton
;
453 return new_singleton
.get();
456 int32_t PPB_Instance_Proxy::RequestInputEvents(PP_Instance instance
,
457 uint32_t event_classes
) {
458 dispatcher()->Send(new PpapiHostMsg_PPBInstance_RequestInputEvents(
459 API_ID_PPB_INSTANCE
, instance
, false, event_classes
));
461 // We always register for the classes we can handle, this function validates
462 // the flags so we can notify it if anything was invalid, without requiring
464 return ValidateRequestInputEvents(false, event_classes
);
467 int32_t PPB_Instance_Proxy::RequestFilteringInputEvents(
468 PP_Instance instance
,
469 uint32_t event_classes
) {
470 dispatcher()->Send(new PpapiHostMsg_PPBInstance_RequestInputEvents(
471 API_ID_PPB_INSTANCE
, instance
, true, event_classes
));
473 // We always register for the classes we can handle, this function validates
474 // the flags so we can notify it if anything was invalid, without requiring
476 return ValidateRequestInputEvents(true, event_classes
);
479 void PPB_Instance_Proxy::ClearInputEventRequest(PP_Instance instance
,
480 uint32_t event_classes
) {
481 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ClearInputEvents(
482 API_ID_PPB_INSTANCE
, instance
, event_classes
));
485 void PPB_Instance_Proxy::StartTrackingLatency(PP_Instance instance
) {
486 dispatcher()->Send(new PpapiHostMsg_PPBInstance_StartTrackingLatency(
487 API_ID_PPB_INSTANCE
, instance
));
490 void PPB_Instance_Proxy::ZoomChanged(PP_Instance instance
,
496 void PPB_Instance_Proxy::ZoomLimitsChanged(PP_Instance instance
,
497 double minimum_factor
,
498 double maximium_factor
) {
503 PP_Var
PPB_Instance_Proxy::GetDocumentURL(PP_Instance instance
,
504 PP_URLComponents_Dev
* components
) {
505 ReceiveSerializedVarReturnValue result
;
506 PP_URLComponents_Dev url_components
;
507 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetDocumentURL(
508 API_ID_PPB_INSTANCE
, instance
, &url_components
, &result
));
510 *components
= url_components
;
511 return result
.Return(dispatcher());
514 #if !defined(OS_NACL)
515 PP_Var
PPB_Instance_Proxy::ResolveRelativeToDocument(
516 PP_Instance instance
,
518 PP_URLComponents_Dev
* components
) {
519 ReceiveSerializedVarReturnValue result
;
520 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ResolveRelativeToDocument(
521 API_ID_PPB_INSTANCE
, instance
,
522 SerializedVarSendInput(dispatcher(), relative
),
524 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
525 result
.Return(dispatcher()),
529 PP_Bool
PPB_Instance_Proxy::DocumentCanRequest(PP_Instance instance
,
531 PP_Bool result
= PP_FALSE
;
532 dispatcher()->Send(new PpapiHostMsg_PPBInstance_DocumentCanRequest(
533 API_ID_PPB_INSTANCE
, instance
,
534 SerializedVarSendInput(dispatcher(), url
),
539 PP_Bool
PPB_Instance_Proxy::DocumentCanAccessDocument(PP_Instance instance
,
540 PP_Instance target
) {
541 PP_Bool result
= PP_FALSE
;
542 dispatcher()->Send(new PpapiHostMsg_PPBInstance_DocumentCanAccessDocument(
543 API_ID_PPB_INSTANCE
, instance
, target
, &result
));
547 PP_Var
PPB_Instance_Proxy::GetPluginInstanceURL(
548 PP_Instance instance
,
549 PP_URLComponents_Dev
* components
) {
550 ReceiveSerializedVarReturnValue result
;
551 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginInstanceURL(
552 API_ID_PPB_INSTANCE
, instance
, &result
));
553 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
554 result
.Return(dispatcher()),
558 PP_Var
PPB_Instance_Proxy::GetPluginReferrerURL(
559 PP_Instance instance
,
560 PP_URLComponents_Dev
* components
) {
561 ReceiveSerializedVarReturnValue result
;
562 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetPluginReferrerURL(
563 API_ID_PPB_INSTANCE
, instance
, &result
));
564 return PPB_URLUtil_Shared::ConvertComponentsAndReturnURL(
565 result
.Return(dispatcher()),
569 void PPB_Instance_Proxy::SessionCreated(PP_Instance instance
,
571 PP_Var web_session_id
) {
572 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionCreated(
576 SerializedVarSendInput(dispatcher(), web_session_id
)));
579 void PPB_Instance_Proxy::SessionMessage(PP_Instance instance
,
582 PP_Var destination_url
) {
583 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionMessage(
587 SerializedVarSendInput(dispatcher(), message
),
588 SerializedVarSendInput(dispatcher(), destination_url
)));
591 void PPB_Instance_Proxy::SessionReady(PP_Instance instance
,
592 uint32_t session_id
) {
593 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionReady(
594 API_ID_PPB_INSTANCE
, instance
, session_id
));
597 void PPB_Instance_Proxy::SessionClosed(PP_Instance instance
,
598 uint32_t session_id
) {
599 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionClosed(
600 API_ID_PPB_INSTANCE
, instance
, session_id
));
603 void PPB_Instance_Proxy::SessionError(PP_Instance instance
,
606 uint32_t system_code
) {
607 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SessionError(
608 API_ID_PPB_INSTANCE
, instance
, session_id
, media_error
, system_code
));
611 void PPB_Instance_Proxy::DeliverBlock(PP_Instance instance
,
612 PP_Resource decrypted_block
,
613 const PP_DecryptedBlockInfo
* block_info
) {
614 PP_Resource decrypted_block_host_resource
= 0;
616 if (decrypted_block
) {
618 PpapiGlobals::Get()->GetResourceTracker()->GetResource(decrypted_block
);
619 if (!object
|| object
->pp_instance() != instance
) {
623 decrypted_block_host_resource
= object
->host_resource().host_resource();
626 std::string serialized_block_info
;
627 if (!SerializeBlockInfo(*block_info
, &serialized_block_info
)) {
633 new PpapiHostMsg_PPBInstance_DeliverBlock(API_ID_PPB_INSTANCE
,
635 decrypted_block_host_resource
,
636 serialized_block_info
));
639 void PPB_Instance_Proxy::DecoderInitializeDone(
640 PP_Instance instance
,
641 PP_DecryptorStreamType decoder_type
,
645 new PpapiHostMsg_PPBInstance_DecoderInitializeDone(
653 void PPB_Instance_Proxy::DecoderDeinitializeDone(
654 PP_Instance instance
,
655 PP_DecryptorStreamType decoder_type
,
656 uint32_t request_id
) {
658 new PpapiHostMsg_PPBInstance_DecoderDeinitializeDone(
665 void PPB_Instance_Proxy::DecoderResetDone(PP_Instance instance
,
666 PP_DecryptorStreamType decoder_type
,
667 uint32_t request_id
) {
669 new PpapiHostMsg_PPBInstance_DecoderResetDone(
676 void PPB_Instance_Proxy::DeliverFrame(PP_Instance instance
,
677 PP_Resource decrypted_frame
,
678 const PP_DecryptedFrameInfo
* frame_info
) {
679 PP_Resource host_resource
= 0;
680 if (decrypted_frame
!= 0) {
681 ResourceTracker
* tracker
= PpapiGlobals::Get()->GetResourceTracker();
682 Resource
* object
= tracker
->GetResource(decrypted_frame
);
684 if (!object
|| object
->pp_instance() != instance
) {
689 host_resource
= object
->host_resource().host_resource();
692 std::string serialized_frame_info
;
693 if (!SerializeBlockInfo(*frame_info
, &serialized_frame_info
)) {
699 new PpapiHostMsg_PPBInstance_DeliverFrame(API_ID_PPB_INSTANCE
,
702 serialized_frame_info
));
705 void PPB_Instance_Proxy::DeliverSamples(
706 PP_Instance instance
,
707 PP_Resource decrypted_samples
,
708 const PP_DecryptedSampleInfo
* sample_info
) {
709 PP_Resource host_resource
= 0;
710 if (decrypted_samples
!= 0) {
711 ResourceTracker
* tracker
= PpapiGlobals::Get()->GetResourceTracker();
712 Resource
* object
= tracker
->GetResource(decrypted_samples
);
714 if (!object
|| object
->pp_instance() != instance
) {
719 host_resource
= object
->host_resource().host_resource();
722 std::string serialized_sample_info
;
723 if (!SerializeBlockInfo(*sample_info
, &serialized_sample_info
)) {
729 new PpapiHostMsg_PPBInstance_DeliverSamples(API_ID_PPB_INSTANCE
,
732 serialized_sample_info
));
734 #endif // !defined(OS_NACL)
736 void PPB_Instance_Proxy::PostMessage(PP_Instance instance
,
738 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage(
740 instance
, SerializedVarSendInputShmem(dispatcher(), message
,
743 int32_t PPB_Instance_Proxy::RegisterMessageHandler(
744 PP_Instance instance
,
746 const PPP_MessageHandler_0_1
* handler
,
747 PP_Resource message_loop
) {
748 // Not yet implemented. See crbug.com/367896
749 return PP_ERROR_NOTSUPPORTED
;
752 void PPB_Instance_Proxy::UnregisterMessageHandler(PP_Instance instance
) {
753 // Not yet implemented. See crbug.com/367896
756 PP_Bool
PPB_Instance_Proxy::SetCursor(PP_Instance instance
,
757 PP_MouseCursor_Type type
,
759 const PP_Point
* hot_spot
) {
760 // Some of these parameters are important for security. This check is in the
761 // plugin process just for the convenience of the caller (since we don't
762 // bother returning errors from the other process with a sync message). The
763 // parameters will be validated again in the renderer.
764 if (!ValidateSetCursorParams(type
, image
, hot_spot
))
767 HostResource image_host_resource
;
769 Resource
* cursor_image
=
770 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image
);
771 if (!cursor_image
|| cursor_image
->pp_instance() != instance
)
773 image_host_resource
= cursor_image
->host_resource();
776 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor(
777 API_ID_PPB_INSTANCE
, instance
, static_cast<int32_t>(type
),
778 image_host_resource
, hot_spot
? *hot_spot
: PP_MakePoint(0, 0)));
782 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance
,
783 scoped_refptr
<TrackedCallback
> callback
) {
784 // Save the mouse callback on the instance data.
785 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
786 GetInstanceData(instance
);
788 return PP_ERROR_BADARGUMENT
;
789 if (TrackedCallback::IsPending(data
->mouse_lock_callback
))
790 return PP_ERROR_INPROGRESS
; // Already have a pending callback.
791 data
->mouse_lock_callback
= callback
;
793 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LockMouse(
794 API_ID_PPB_INSTANCE
, instance
));
795 return PP_OK_COMPLETIONPENDING
;
798 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance
) {
799 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse(
800 API_ID_PPB_INSTANCE
, instance
));
803 void PPB_Instance_Proxy::SetTextInputType(PP_Instance instance
,
804 PP_TextInput_Type type
) {
805 CancelAnyPendingRequestSurroundingText(instance
);
806 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetTextInputType(
807 API_ID_PPB_INSTANCE
, instance
, type
));
810 void PPB_Instance_Proxy::UpdateCaretPosition(PP_Instance instance
,
811 const PP_Rect
& caret
,
812 const PP_Rect
& bounding_box
) {
813 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateCaretPosition(
814 API_ID_PPB_INSTANCE
, instance
, caret
, bounding_box
));
817 void PPB_Instance_Proxy::CancelCompositionText(PP_Instance instance
) {
818 CancelAnyPendingRequestSurroundingText(instance
);
819 dispatcher()->Send(new PpapiHostMsg_PPBInstance_CancelCompositionText(
820 API_ID_PPB_INSTANCE
, instance
));
823 void PPB_Instance_Proxy::SelectionChanged(PP_Instance instance
) {
824 // The "right" way to do this is to send the message to the host. However,
825 // all it will do is call RequestSurroundingText with a hardcoded number of
826 // characters in response, which is an entire IPC round-trip.
828 // We can avoid this round-trip by just implementing the
829 // RequestSurroundingText logic in the plugin process. If the logic in the
830 // host becomes more complex (like a more adaptive number of characters),
831 // we'll need to reevanuate whether we want to do the round trip instead.
833 // Be careful to post a task to avoid reentering the plugin.
836 static_cast<PluginDispatcher
*>(dispatcher())->GetInstanceData(instance
);
839 data
->should_do_request_surrounding_text
= true;
841 if (!data
->is_request_surrounding_text_pending
) {
842 base::MessageLoop::current()->PostTask(
844 RunWhileLocked(base::Bind(&RequestSurroundingText
, instance
)));
845 data
->is_request_surrounding_text_pending
= true;
849 void PPB_Instance_Proxy::UpdateSurroundingText(PP_Instance instance
,
853 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UpdateSurroundingText(
854 API_ID_PPB_INSTANCE
, instance
, text
, caret
, anchor
));
857 #if !defined(OS_NACL)
858 void PPB_Instance_Proxy::OnHostMsgGetWindowObject(
859 PP_Instance instance
,
860 SerializedVarReturnValue result
) {
861 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
863 EnterInstanceNoLock
enter(instance
);
864 if (enter
.succeeded())
865 result
.Return(dispatcher(), enter
.functions()->GetWindowObject(instance
));
868 void PPB_Instance_Proxy::OnHostMsgGetOwnerElementObject(
869 PP_Instance instance
,
870 SerializedVarReturnValue result
) {
871 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
873 EnterInstanceNoLock
enter(instance
);
874 if (enter
.succeeded()) {
875 result
.Return(dispatcher(),
876 enter
.functions()->GetOwnerElementObject(instance
));
880 void PPB_Instance_Proxy::OnHostMsgBindGraphics(PP_Instance instance
,
881 PP_Resource device
) {
882 // Note that we ignroe the return value here. Otherwise, this would need to
883 // be a slow sync call, and the plugin side of the proxy will have already
884 // validated the resources, so we shouldn't see errors here that weren't
886 EnterInstanceNoLock
enter(instance
);
887 if (enter
.succeeded())
888 enter
.functions()->BindGraphics(instance
, device
);
891 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputSampleRate(
892 PP_Instance instance
, uint32_t* result
) {
893 EnterInstanceNoLock
enter(instance
);
894 if (enter
.succeeded())
895 *result
= enter
.functions()->GetAudioHardwareOutputSampleRate(instance
);
898 void PPB_Instance_Proxy::OnHostMsgGetAudioHardwareOutputBufferSize(
899 PP_Instance instance
, uint32_t* result
) {
900 EnterInstanceNoLock
enter(instance
);
901 if (enter
.succeeded())
902 *result
= enter
.functions()->GetAudioHardwareOutputBufferSize(instance
);
905 void PPB_Instance_Proxy::OnHostMsgIsFullFrame(PP_Instance instance
,
907 EnterInstanceNoLock
enter(instance
);
908 if (enter
.succeeded())
909 *result
= enter
.functions()->IsFullFrame(instance
);
912 void PPB_Instance_Proxy::OnHostMsgExecuteScript(
913 PP_Instance instance
,
914 SerializedVarReceiveInput script
,
915 SerializedVarOutParam out_exception
,
916 SerializedVarReturnValue result
) {
917 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
919 EnterInstanceNoLock
enter(instance
);
923 if (dispatcher()->IsPlugin())
926 static_cast<HostDispatcher
*>(dispatcher())->set_allow_plugin_reentrancy();
928 result
.Return(dispatcher(), enter
.functions()->ExecuteScript(
930 script
.Get(dispatcher()),
931 out_exception
.OutParam(dispatcher())));
934 void PPB_Instance_Proxy::OnHostMsgGetDefaultCharSet(
935 PP_Instance instance
,
936 SerializedVarReturnValue result
) {
937 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
939 EnterInstanceNoLock
enter(instance
);
940 if (enter
.succeeded())
941 result
.Return(dispatcher(), enter
.functions()->GetDefaultCharSet(instance
));
944 void PPB_Instance_Proxy::OnHostMsgSetPluginToHandleFindRequests(
945 PP_Instance instance
) {
946 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
948 EnterInstanceNoLock
enter(instance
);
949 if (enter
.succeeded())
950 enter
.functions()->SetPluginToHandleFindRequests(instance
);
953 void PPB_Instance_Proxy::OnHostMsgNumberOfFindResultsChanged(
954 PP_Instance instance
,
956 PP_Bool final_result
) {
957 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
959 EnterInstanceNoLock
enter(instance
);
960 if (enter
.succeeded()) {
961 enter
.functions()->NumberOfFindResultsChanged(
962 instance
, total
, final_result
);
966 void PPB_Instance_Proxy::OnHostMsgSelectFindResultChanged(
967 PP_Instance instance
,
969 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
971 EnterInstanceNoLock
enter(instance
);
972 if (enter
.succeeded())
973 enter
.functions()->SelectedFindResultChanged(instance
, index
);
976 void PPB_Instance_Proxy::OnHostMsgSetTickmarks(
977 PP_Instance instance
,
978 const std::vector
<PP_Rect
>& tickmarks
) {
979 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
981 const PP_Rect
* array
= tickmarks
.empty() ? NULL
: &tickmarks
[0];
982 EnterInstanceNoLock
enter(instance
);
983 if (enter
.succeeded()) {
984 enter
.functions()->SetTickmarks(instance
,
986 static_cast<uint32_t>(tickmarks
.size()));
990 void PPB_Instance_Proxy::OnHostMsgSetFullscreen(PP_Instance instance
,
993 EnterInstanceNoLock
enter(instance
);
994 if (enter
.succeeded())
995 *result
= enter
.functions()->SetFullscreen(instance
, fullscreen
);
999 void PPB_Instance_Proxy::OnHostMsgGetScreenSize(PP_Instance instance
,
1002 EnterInstanceNoLock
enter(instance
);
1003 if (enter
.succeeded())
1004 *result
= enter
.functions()->GetScreenSize(instance
, size
);
1007 void PPB_Instance_Proxy::OnHostMsgRequestInputEvents(PP_Instance instance
,
1009 uint32_t event_classes
) {
1010 EnterInstanceNoLock
enter(instance
);
1011 if (enter
.succeeded()) {
1013 enter
.functions()->RequestFilteringInputEvents(instance
, event_classes
);
1015 enter
.functions()->RequestInputEvents(instance
, event_classes
);
1019 void PPB_Instance_Proxy::OnHostMsgClearInputEvents(PP_Instance instance
,
1020 uint32_t event_classes
) {
1021 EnterInstanceNoLock
enter(instance
);
1022 if (enter
.succeeded())
1023 enter
.functions()->ClearInputEventRequest(instance
, event_classes
);
1026 void PPB_Instance_Proxy::OnHostMsgStartTrackingLatency(PP_Instance instance
) {
1027 EnterInstanceNoLock
enter(instance
);
1028 if (enter
.succeeded())
1029 enter
.functions()->StartTrackingLatency(instance
);
1032 void PPB_Instance_Proxy::OnHostMsgPostMessage(
1033 PP_Instance instance
,
1034 SerializedVarReceiveInput message
) {
1035 EnterInstanceNoLock
enter(instance
);
1036 if (!message
.is_valid_var()) {
1037 PpapiGlobals::Get()->LogWithSource(
1038 instance
, PP_LOGLEVEL_ERROR
, std::string(), kSerializationError
);
1042 if (enter
.succeeded())
1043 enter
.functions()->PostMessage(instance
,
1044 message
.GetForInstance(dispatcher(),
1048 void PPB_Instance_Proxy::OnHostMsgLockMouse(PP_Instance instance
) {
1049 // Need to be careful to always issue the callback.
1050 pp::CompletionCallback cb
= callback_factory_
.NewCallback(
1051 &PPB_Instance_Proxy::MouseLockCompleteInHost
, instance
);
1053 EnterInstanceNoLock
enter(instance
, cb
.pp_completion_callback());
1054 if (enter
.succeeded())
1055 enter
.SetResult(enter
.functions()->LockMouse(instance
, enter
.callback()));
1058 void PPB_Instance_Proxy::OnHostMsgUnlockMouse(PP_Instance instance
) {
1059 EnterInstanceNoLock
enter(instance
);
1060 if (enter
.succeeded())
1061 enter
.functions()->UnlockMouse(instance
);
1064 void PPB_Instance_Proxy::OnHostMsgGetDocumentURL(
1065 PP_Instance instance
,
1066 PP_URLComponents_Dev
* components
,
1067 SerializedVarReturnValue result
) {
1068 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1070 EnterInstanceNoLock
enter(instance
);
1071 if (enter
.succeeded()) {
1072 PP_Var document_url
= enter
.functions()->GetDocumentURL(instance
,
1074 result
.Return(dispatcher(), document_url
);
1078 void PPB_Instance_Proxy::OnHostMsgResolveRelativeToDocument(
1079 PP_Instance instance
,
1080 SerializedVarReceiveInput relative
,
1081 SerializedVarReturnValue result
) {
1082 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1084 EnterInstanceNoLock
enter(instance
);
1085 if (enter
.succeeded()) {
1086 result
.Return(dispatcher(),
1087 enter
.functions()->ResolveRelativeToDocument(
1088 instance
, relative
.Get(dispatcher()), NULL
));
1092 void PPB_Instance_Proxy::OnHostMsgDocumentCanRequest(
1093 PP_Instance instance
,
1094 SerializedVarReceiveInput url
,
1096 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1098 EnterInstanceNoLock
enter(instance
);
1099 if (enter
.succeeded()) {
1100 *result
= enter
.functions()->DocumentCanRequest(instance
,
1101 url
.Get(dispatcher()));
1105 void PPB_Instance_Proxy::OnHostMsgDocumentCanAccessDocument(PP_Instance active
,
1108 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1110 EnterInstanceNoLock
enter(active
);
1111 if (enter
.succeeded())
1112 *result
= enter
.functions()->DocumentCanAccessDocument(active
, target
);
1115 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL(
1116 PP_Instance instance
,
1117 SerializedVarReturnValue result
) {
1118 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1120 EnterInstanceNoLock
enter(instance
);
1121 if (enter
.succeeded()) {
1122 result
.Return(dispatcher(),
1123 enter
.functions()->GetPluginInstanceURL(instance
, NULL
));
1127 void PPB_Instance_Proxy::OnHostMsgGetPluginReferrerURL(
1128 PP_Instance instance
,
1129 SerializedVarReturnValue result
) {
1130 if (!dispatcher()->permissions().HasPermission(PERMISSION_DEV
))
1132 EnterInstanceNoLock
enter(instance
);
1133 if (enter
.succeeded()) {
1134 result
.Return(dispatcher(),
1135 enter
.functions()->GetPluginReferrerURL(instance
, NULL
));
1139 void PPB_Instance_Proxy::OnHostMsgSessionCreated(
1140 PP_Instance instance
,
1141 uint32_t session_id
,
1142 SerializedVarReceiveInput web_session_id
) {
1143 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1145 EnterInstanceNoLock
enter(instance
);
1146 if (enter
.succeeded()) {
1147 enter
.functions()->SessionCreated(
1148 instance
, session_id
, web_session_id
.Get(dispatcher()));
1152 void PPB_Instance_Proxy::OnHostMsgSessionMessage(
1153 PP_Instance instance
,
1154 uint32_t session_id
,
1155 SerializedVarReceiveInput message
,
1156 SerializedVarReceiveInput destination_url
) {
1157 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1159 EnterInstanceNoLock
enter(instance
);
1160 if (enter
.succeeded()) {
1161 enter
.functions()->SessionMessage(instance
,
1163 message
.Get(dispatcher()),
1164 destination_url
.Get(dispatcher()));
1168 void PPB_Instance_Proxy::OnHostMsgSessionReady(PP_Instance instance
,
1169 uint32_t session_id
) {
1170 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1172 EnterInstanceNoLock
enter(instance
);
1173 if (enter
.succeeded()) {
1174 enter
.functions()->SessionReady(instance
, session_id
);
1178 void PPB_Instance_Proxy::OnHostMsgSessionClosed(PP_Instance instance
,
1179 uint32_t session_id
) {
1180 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1182 EnterInstanceNoLock
enter(instance
);
1183 if (enter
.succeeded()) {
1184 enter
.functions()->SessionClosed(instance
, session_id
);
1188 void PPB_Instance_Proxy::OnHostMsgSessionError(PP_Instance instance
,
1189 uint32_t session_id
,
1190 int32_t media_error
,
1191 uint32_t system_code
) {
1192 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1194 EnterInstanceNoLock
enter(instance
);
1195 if (enter
.succeeded()) {
1196 enter
.functions()->SessionError(
1197 instance
, session_id
, media_error
, system_code
);
1201 void PPB_Instance_Proxy::OnHostMsgDeliverBlock(
1202 PP_Instance instance
,
1203 PP_Resource decrypted_block
,
1204 const std::string
& serialized_block_info
) {
1205 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1207 PP_DecryptedBlockInfo block_info
;
1208 if (!DeserializeBlockInfo(serialized_block_info
, &block_info
))
1211 EnterInstanceNoLock
enter(instance
);
1212 if (enter
.succeeded())
1213 enter
.functions()->DeliverBlock(instance
, decrypted_block
, &block_info
);
1216 void PPB_Instance_Proxy::OnHostMsgDecoderInitializeDone(
1217 PP_Instance instance
,
1218 PP_DecryptorStreamType decoder_type
,
1219 uint32_t request_id
,
1221 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1223 EnterInstanceNoLock
enter(instance
);
1224 if (enter
.succeeded()) {
1225 enter
.functions()->DecoderInitializeDone(instance
,
1232 void PPB_Instance_Proxy::OnHostMsgDecoderDeinitializeDone(
1233 PP_Instance instance
,
1234 PP_DecryptorStreamType decoder_type
,
1235 uint32_t request_id
) {
1236 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1238 EnterInstanceNoLock
enter(instance
);
1239 if (enter
.succeeded())
1240 enter
.functions()->DecoderDeinitializeDone(instance
,
1245 void PPB_Instance_Proxy::OnHostMsgDecoderResetDone(
1246 PP_Instance instance
,
1247 PP_DecryptorStreamType decoder_type
,
1248 uint32_t request_id
) {
1249 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1251 EnterInstanceNoLock
enter(instance
);
1252 if (enter
.succeeded())
1253 enter
.functions()->DecoderResetDone(instance
, decoder_type
, request_id
);
1256 void PPB_Instance_Proxy::OnHostMsgDeliverFrame(
1257 PP_Instance instance
,
1258 PP_Resource decrypted_frame
,
1259 const std::string
& serialized_frame_info
) {
1260 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1262 PP_DecryptedFrameInfo frame_info
;
1263 if (!DeserializeBlockInfo(serialized_frame_info
, &frame_info
))
1266 EnterInstanceNoLock
enter(instance
);
1267 if (enter
.succeeded())
1268 enter
.functions()->DeliverFrame(instance
, decrypted_frame
, &frame_info
);
1271 void PPB_Instance_Proxy::OnHostMsgDeliverSamples(
1272 PP_Instance instance
,
1273 PP_Resource audio_frames
,
1274 const std::string
& serialized_sample_info
) {
1275 if (!dispatcher()->permissions().HasPermission(PERMISSION_PRIVATE
))
1277 PP_DecryptedSampleInfo sample_info
;
1278 if (!DeserializeBlockInfo(serialized_sample_info
, &sample_info
))
1281 EnterInstanceNoLock
enter(instance
);
1282 if (enter
.succeeded())
1283 enter
.functions()->DeliverSamples(instance
, audio_frames
, &sample_info
);
1286 void PPB_Instance_Proxy::OnHostMsgSetCursor(
1287 PP_Instance instance
,
1289 const ppapi::HostResource
& custom_image
,
1290 const PP_Point
& hot_spot
) {
1291 // This API serves PPB_CursorControl_Dev and PPB_MouseCursor, so is public.
1292 EnterInstanceNoLock
enter(instance
);
1293 if (enter
.succeeded()) {
1294 enter
.functions()->SetCursor(
1295 instance
, static_cast<PP_MouseCursor_Type
>(type
),
1296 custom_image
.host_resource(), &hot_spot
);
1300 void PPB_Instance_Proxy::OnHostMsgSetTextInputType(PP_Instance instance
,
1301 PP_TextInput_Type type
) {
1302 EnterInstanceNoLock
enter(instance
);
1303 if (enter
.succeeded())
1304 enter
.functions()->SetTextInputType(instance
, type
);
1307 void PPB_Instance_Proxy::OnHostMsgUpdateCaretPosition(
1308 PP_Instance instance
,
1309 const PP_Rect
& caret
,
1310 const PP_Rect
& bounding_box
) {
1311 EnterInstanceNoLock
enter(instance
);
1312 if (enter
.succeeded())
1313 enter
.functions()->UpdateCaretPosition(instance
, caret
, bounding_box
);
1316 void PPB_Instance_Proxy::OnHostMsgCancelCompositionText(PP_Instance instance
) {
1317 EnterInstanceNoLock
enter(instance
);
1318 if (enter
.succeeded())
1319 enter
.functions()->CancelCompositionText(instance
);
1322 void PPB_Instance_Proxy::OnHostMsgUpdateSurroundingText(
1323 PP_Instance instance
,
1324 const std::string
& text
,
1327 EnterInstanceNoLock
enter(instance
);
1328 if (enter
.succeeded()) {
1329 enter
.functions()->UpdateSurroundingText(instance
, text
.c_str(), caret
,
1333 #endif // !defined(OS_NACL)
1335 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance
,
1337 if (!dispatcher()->IsPlugin())
1340 // Save the mouse callback on the instance data.
1341 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
1342 GetInstanceData(instance
);
1344 return; // Instance was probably deleted.
1345 if (!TrackedCallback::IsPending(data
->mouse_lock_callback
)) {
1349 data
->mouse_lock_callback
->Run(result
);
1352 #if !defined(OS_NACL)
1353 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result
,
1354 PP_Instance instance
) {
1355 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
1356 API_ID_PPB_INSTANCE
, instance
, result
));
1358 #endif // !defined(OS_NACL)
1360 void PPB_Instance_Proxy::CancelAnyPendingRequestSurroundingText(
1361 PP_Instance instance
) {
1362 InstanceData
* data
= static_cast<PluginDispatcher
*>(dispatcher())->
1363 GetInstanceData(instance
);
1365 return; // Instance was probably deleted.
1366 data
->should_do_request_surrounding_text
= false;
1369 } // namespace proxy
1370 } // namespace ppapi