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

Side by Side Diff: ppapi/proxy/ppb_instance_proxy.cc

Issue 9814015: Add new MouseCursor interface for setting the mouse cursor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/proxy/ppb_instance_proxy.h" 5 #include "ppapi/proxy/ppb_instance_proxy.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/pp_time.h" 8 #include "ppapi/c/pp_time.h"
9 #include "ppapi/c/pp_var.h" 9 #include "ppapi/c/pp_var.h"
10 #include "ppapi/c/ppb_audio_config.h" 10 #include "ppapi/c/ppb_audio_config.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument, 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ResolveRelativeToDocument,
118 OnHostMsgResolveRelativeToDocument) 118 OnHostMsgResolveRelativeToDocument)
119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest, 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanRequest,
120 OnHostMsgDocumentCanRequest) 120 OnHostMsgDocumentCanRequest)
121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument, 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_DocumentCanAccessDocument,
122 OnHostMsgDocumentCanAccessDocument) 122 OnHostMsgDocumentCanAccessDocument)
123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL, 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetDocumentURL,
124 OnHostMsgGetDocumentURL) 124 OnHostMsgGetDocumentURL)
125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL, 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetPluginInstanceURL,
126 OnHostMsgGetPluginInstanceURL) 126 OnHostMsgGetPluginInstanceURL)
127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetCursor,
128 OnHostMsgSetCursor)
127 129
128 // Host -> Plugin messages. 130 // Host -> Plugin messages.
129 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete, 131 IPC_MESSAGE_HANDLER(PpapiMsg_PPBInstance_MouseLockComplete,
130 OnPluginMsgMouseLockComplete) 132 OnPluginMsgMouseLockComplete)
131 133
132 IPC_MESSAGE_UNHANDLED(handled = false) 134 IPC_MESSAGE_UNHANDLED(handled = false)
133 IPC_END_MESSAGE_MAP() 135 IPC_END_MESSAGE_MAP()
134 return handled; 136 return handled;
135 } 137 }
136 138
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 components); 398 components);
397 } 399 }
398 400
399 void PPB_Instance_Proxy::PostMessage(PP_Instance instance, 401 void PPB_Instance_Proxy::PostMessage(PP_Instance instance,
400 PP_Var message) { 402 PP_Var message) {
401 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage( 403 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage(
402 API_ID_PPB_INSTANCE, 404 API_ID_PPB_INSTANCE,
403 instance, SerializedVarSendInput(dispatcher(), message))); 405 instance, SerializedVarSendInput(dispatcher(), message)));
404 } 406 }
405 407
408 PP_Bool PPB_Instance_Proxy::SetCursor(PP_Instance instance,
409 PP_MouseCursor_Type type,
410 PP_Resource image,
411 const PP_Point* hot_spot) {
412 // Some of these parameters are important for security. This check is in the
413 // plugin process just for the convenience of the caller (since we don't
414 // bother returning errors from the other process with a sync message). The
415 // parameters will be validated again in the rendeer.
dmichael (off chromium) 2012/03/26 17:43:17 rendeer->renderer
416 if (!ValidateSetCursorParams(type, image, hot_spot))
417 return PP_FALSE;
418
419 HostResource image_host_resource;
420 if (image) {
421 Resource* cursor_image =
422 PpapiGlobals::Get()->GetResourceTracker()->GetResource(image);
423 if (!image || cursor_image->pp_instance() != instance)
dmichael (off chromium) 2012/03/26 17:43:17 !image->!cursor_image?
424 return PP_FALSE;
425 image_host_resource = cursor_image->host_resource();
426 }
427
428 dispatcher()->Send(new PpapiHostMsg_PPBInstance_SetCursor(
429 API_ID_PPB_INSTANCE, instance, static_cast<int32_t>(type),
430 image_host_resource, hot_spot ? *hot_spot : PP_MakePoint(0, 0)));
431 return PP_TRUE;
432 }
433
406 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance, 434 int32_t PPB_Instance_Proxy::LockMouse(PP_Instance instance,
407 PP_CompletionCallback callback) { 435 PP_CompletionCallback callback) {
408 if (!callback.func) 436 if (!callback.func)
409 return PP_ERROR_BADARGUMENT; 437 return PP_ERROR_BADARGUMENT;
410 438
411 // Save the mouse callback on the instance data. 439 // Save the mouse callback on the instance data.
412 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 440 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
413 GetInstanceData(instance); 441 GetInstanceData(instance);
414 if (!data) 442 if (!data)
415 return PP_ERROR_BADARGUMENT; 443 return PP_ERROR_BADARGUMENT;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( 656 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL(
629 PP_Instance instance, 657 PP_Instance instance,
630 SerializedVarReturnValue result) { 658 SerializedVarReturnValue result) {
631 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 659 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true);
632 if (enter.succeeded()) { 660 if (enter.succeeded()) {
633 result.Return(dispatcher(), 661 result.Return(dispatcher(),
634 enter.functions()->GetPluginInstanceURL(instance, NULL)); 662 enter.functions()->GetPluginInstanceURL(instance, NULL));
635 } 663 }
636 } 664 }
637 665
666 void PPB_Instance_Proxy::OnHostMsgSetCursor(
667 PP_Instance instance,
668 int32_t type,
669 const ppapi::HostResource& custom_image,
670 const PP_Point& hot_spot) {
671 EnterInstanceNoLock enter(instance, true);
672 if (enter.succeeded()) {
673 enter.functions()->SetCursor(
674 instance, static_cast<PP_MouseCursor_Type>(type),
675 custom_image.host_resource(), &hot_spot);
676 }
677 }
678
638 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, 679 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance,
639 int32_t result) { 680 int32_t result) {
640 // Save the mouse callback on the instance data. 681 // Save the mouse callback on the instance data.
641 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 682 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
642 GetInstanceData(instance); 683 GetInstanceData(instance);
643 if (!data) 684 if (!data)
644 return; // Instance was probably deleted. 685 return; // Instance was probably deleted.
645 if (!data->mouse_lock_callback.func) { 686 if (!data->mouse_lock_callback.func) {
646 NOTREACHED(); 687 NOTREACHED();
647 return; 688 return;
648 } 689 }
649 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result); 690 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result);
650 } 691 }
651 692
652 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, 693 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
653 PP_Instance instance) { 694 PP_Instance instance) {
654 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( 695 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
655 API_ID_PPB_INSTANCE, instance, result)); 696 API_ID_PPB_INSTANCE, instance, result));
656 } 697 }
657 698
658 } // namespace proxy 699 } // namespace proxy
659 } // namespace ppapi 700 } // namespace ppapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698