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

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
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.h ('k') | ppapi/shared_impl/ppb_instance_shared.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 (!cursor_image || cursor_image->pp_instance() != instance)
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL( 658 void PPB_Instance_Proxy::OnHostMsgGetPluginInstanceURL(
631 PP_Instance instance, 659 PP_Instance instance,
632 SerializedVarReturnValue result) { 660 SerializedVarReturnValue result) {
633 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); 661 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true);
634 if (enter.succeeded()) { 662 if (enter.succeeded()) {
635 result.Return(dispatcher(), 663 result.Return(dispatcher(),
636 enter.functions()->GetPluginInstanceURL(instance, NULL)); 664 enter.functions()->GetPluginInstanceURL(instance, NULL));
637 } 665 }
638 } 666 }
639 667
668 void PPB_Instance_Proxy::OnHostMsgSetCursor(
669 PP_Instance instance,
670 int32_t type,
671 const ppapi::HostResource& custom_image,
672 const PP_Point& hot_spot) {
673 EnterInstanceNoLock enter(instance, true);
674 if (enter.succeeded()) {
675 enter.functions()->SetCursor(
676 instance, static_cast<PP_MouseCursor_Type>(type),
677 custom_image.host_resource(), &hot_spot);
678 }
679 }
680
640 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance, 681 void PPB_Instance_Proxy::OnPluginMsgMouseLockComplete(PP_Instance instance,
641 int32_t result) { 682 int32_t result) {
642 // Save the mouse callback on the instance data. 683 // Save the mouse callback on the instance data.
643 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> 684 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())->
644 GetInstanceData(instance); 685 GetInstanceData(instance);
645 if (!data) 686 if (!data)
646 return; // Instance was probably deleted. 687 return; // Instance was probably deleted.
647 if (!data->mouse_lock_callback.func) { 688 if (!data->mouse_lock_callback.func) {
648 NOTREACHED(); 689 NOTREACHED();
649 return; 690 return;
650 } 691 }
651 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result); 692 PP_RunAndClearCompletionCallback(&data->mouse_lock_callback, result);
652 } 693 }
653 694
654 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result, 695 void PPB_Instance_Proxy::MouseLockCompleteInHost(int32_t result,
655 PP_Instance instance) { 696 PP_Instance instance) {
656 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete( 697 dispatcher()->Send(new PpapiMsg_PPBInstance_MouseLockComplete(
657 API_ID_PPB_INSTANCE, instance, result)); 698 API_ID_PPB_INSTANCE, instance, result));
658 } 699 }
659 700
660 } // namespace proxy 701 } // namespace proxy
661 } // namespace ppapi 702 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_instance_proxy.h ('k') | ppapi/shared_impl/ppb_instance_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698