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. 4 5 #include "ppapi/cpp/dev/cursor_control_dev.h" 6 7 #include "ppapi/cpp/image_data.h" 8 #include "ppapi/cpp/instance_handle.h" 9 #include "ppapi/cpp/module.h" 10 #include "ppapi/cpp/module_impl.h" 11 #include "ppapi/cpp/point.h" 12 13 namespace pp { 14 15 namespace { 16 17 template <> const char* interface_name<PPB_CursorControl_Dev_0_4>() { 18 return PPB_CURSOR_CONTROL_DEV_INTERFACE_0_4; 19 } 20 21 } // namespace 22 23 bool CursorControl_Dev::SetCursor(const InstanceHandle& instance, 24 PP_CursorType_Dev type, 25 const ImageData& custom_image, 26 const Point& hot_spot) { 27 if (has_interface<PPB_CursorControl_Dev_0_4>()) { 28 return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->SetCursor( 29 instance.pp_instance(), type, custom_image.pp_resource(), 30 &hot_spot.pp_point())); 31 } 32 return false; 33 } 34 35 bool LockCursor(const InstanceHandle& instance) { 36 if (has_interface<PPB_CursorControl_Dev_0_4>()) { 37 return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->LockCursor( 38 instance.pp_instance())); 39 } 40 return false; 41 } 42 43 bool UnlockCursor(const InstanceHandle& instance) { 44 if (has_interface<PPB_CursorControl_Dev_0_4>()) { 45 return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->UnlockCursor( 46 instance.pp_instance())); 47 } 48 return false; 49 } 50 51 bool HasCursorLock(const InstanceHandle& instance) { 52 if (has_interface<PPB_CursorControl_Dev_0_4>()) { 53 return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->HasCursorLock( 54 instance.pp_instance())); 55 } 56 return false; 57 } 58 59 bool CanLockCursor(const InstanceHandle& instance) { 60 if (has_interface<PPB_CursorControl_Dev_0_4>()) { 61 return PP_ToBool(get_interface<PPB_CursorControl_Dev_0_4>()->CanLockCursor( 62 instance.pp_instance())); 63 } 64 return false; 65 } 66 67 } // namespace pp 68