| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_cursor_control.h" | 5 #include "webkit/glue/plugins/pepper_cursor_control.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 9 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
| 10 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 10 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
| 11 #include "ppapi/c/pp_point.h" | 11 #include "ppapi/c/pp_point.h" |
| 12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
| 13 #include "webkit/glue/plugins/pepper_common.h" |
| 13 #include "webkit/glue/plugins/pepper_image_data.h" | 14 #include "webkit/glue/plugins/pepper_image_data.h" |
| 14 #include "webkit/glue/plugins/pepper_plugin_instance.h" | 15 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
| 15 #include "webkit/glue/plugins/pepper_resource.h" | 16 #include "webkit/glue/plugins/pepper_resource.h" |
| 16 | 17 |
| 17 namespace pepper { | 18 namespace pepper { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 bool SetCursor(PP_Instance instance_id, | 22 PP_Bool SetCursor(PP_Instance instance_id, |
| 22 PP_CursorType_Dev type, | 23 PP_CursorType_Dev type, |
| 23 PP_Resource custom_image_id, | 24 PP_Resource custom_image_id, |
| 24 const PP_Point* hot_spot) { | 25 const PP_Point* hot_spot) { |
| 25 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 26 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 26 if (!instance) | 27 if (!instance) |
| 27 return false; | 28 return PP_FALSE; |
| 28 | 29 |
| 29 scoped_refptr<ImageData> custom_image( | 30 scoped_refptr<ImageData> custom_image( |
| 30 Resource::GetAs<ImageData>(custom_image_id)); | 31 Resource::GetAs<ImageData>(custom_image_id)); |
| 31 if (custom_image.get()) { | 32 if (custom_image.get()) { |
| 32 // TODO(neb): implement custom cursors. | 33 // TODO(neb): implement custom cursors. |
| 33 NOTIMPLEMENTED(); | 34 NOTIMPLEMENTED(); |
| 34 return false; | 35 return PP_FALSE; |
| 35 } | 36 } |
| 36 | 37 |
| 37 return instance->SetCursor(type); | 38 return BoolToPPBool(instance->SetCursor(type)); |
| 38 } | 39 } |
| 39 | 40 |
| 40 bool LockCursor(PP_Instance instance_id) { | 41 PP_Bool LockCursor(PP_Instance instance_id) { |
| 41 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 42 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 42 if (!instance) | 43 if (!instance) |
| 43 return false; | 44 return PP_FALSE; |
| 44 | 45 |
| 45 // TODO(neb): implement cursor locking. | 46 // TODO(neb): implement cursor locking. |
| 46 return false; | 47 return PP_FALSE; |
| 47 } | 48 } |
| 48 | 49 |
| 49 bool UnlockCursor(PP_Instance instance_id) { | 50 PP_Bool UnlockCursor(PP_Instance instance_id) { |
| 50 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 51 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 51 if (!instance) | 52 if (!instance) |
| 52 return false; | 53 return PP_FALSE; |
| 53 | 54 |
| 54 // TODO(neb): implement cursor locking. | 55 // TODO(neb): implement cursor locking. |
| 55 return false; | 56 return PP_FALSE; |
| 56 } | 57 } |
| 57 | 58 |
| 58 bool HasCursorLock(PP_Instance instance_id) { | 59 PP_Bool HasCursorLock(PP_Instance instance_id) { |
| 59 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 60 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 60 if (!instance) | 61 if (!instance) |
| 61 return false; | 62 return PP_FALSE; |
| 62 | 63 |
| 63 // TODO(neb): implement cursor locking. | 64 // TODO(neb): implement cursor locking. |
| 64 return false; | 65 return PP_FALSE; |
| 65 } | 66 } |
| 66 | 67 |
| 67 bool CanLockCursor(PP_Instance instance_id) { | 68 PP_Bool CanLockCursor(PP_Instance instance_id) { |
| 68 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 69 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 69 if (!instance) | 70 if (!instance) |
| 70 return false; | 71 return PP_FALSE; |
| 71 | 72 |
| 72 // TODO(neb): implement cursor locking. | 73 // TODO(neb): implement cursor locking. |
| 73 return false; | 74 return PP_FALSE; |
| 74 } | 75 } |
| 75 | 76 |
| 76 const PPB_CursorControl_Dev cursor_control_interface = { | 77 const PPB_CursorControl_Dev cursor_control_interface = { |
| 77 &SetCursor, | 78 &SetCursor, |
| 78 &LockCursor, | 79 &LockCursor, |
| 79 &UnlockCursor, | 80 &UnlockCursor, |
| 80 &HasCursorLock, | 81 &HasCursorLock, |
| 81 &CanLockCursor | 82 &CanLockCursor |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 } // namespace | 85 } // namespace |
| 85 | 86 |
| 86 const PPB_CursorControl_Dev* GetCursorControlInterface() { | 87 const PPB_CursorControl_Dev* GetCursorControlInterface() { |
| 87 return &cursor_control_interface; | 88 return &cursor_control_interface; |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace pepper | 91 } // namespace pepper |
| 91 | 92 |
| OLD | NEW |