OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_cursor_control_proxy.h" | 5 #include "ppapi/proxy/ppb_cursor_control_proxy.h" |
6 | 6 |
7 #include "ppapi/c/dev/pp_cursor_type_dev.h" | 7 #include "ppapi/c/dev/pp_cursor_type_dev.h" |
8 #include "ppapi/c/dev/ppb_cursor_control_dev.h" | 8 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
9 #include "ppapi/proxy/plugin_dispatcher.h" | 9 #include "ppapi/proxy/plugin_dispatcher.h" |
10 #include "ppapi/proxy/plugin_resource_tracker.h" | 10 #include "ppapi/proxy/plugin_resource_tracker.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/shared_impl/ppapi_globals.h" | |
13 #include "ppapi/thunk/enter.h" | 12 #include "ppapi/thunk/enter.h" |
14 #include "ppapi/thunk/thunk.h" | 13 #include "ppapi/thunk/thunk.h" |
15 | 14 |
16 using ppapi::thunk::EnterFunctionNoLock; | 15 using ppapi::thunk::EnterFunctionNoLock; |
17 using ppapi::thunk::PPB_CursorControl_FunctionAPI; | 16 using ppapi::thunk::PPB_CursorControl_FunctionAPI; |
18 | 17 |
19 namespace ppapi { | 18 namespace ppapi { |
20 namespace proxy { | 19 namespace proxy { |
21 | 20 |
22 PPB_CursorControl_Proxy::PPB_CursorControl_Proxy(Dispatcher* dispatcher) | 21 PPB_CursorControl_Proxy::PPB_CursorControl_Proxy(Dispatcher* dispatcher) |
23 : InterfaceProxy(dispatcher) { | 22 : InterfaceProxy(dispatcher) { |
24 } | 23 } |
25 | 24 |
26 PPB_CursorControl_Proxy::~PPB_CursorControl_Proxy() { | 25 PPB_CursorControl_Proxy::~PPB_CursorControl_Proxy() { |
27 } | 26 } |
28 | 27 |
29 ppapi::thunk::PPB_CursorControl_FunctionAPI* | 28 ppapi::thunk::PPB_CursorControl_FunctionAPI* |
30 PPB_CursorControl_Proxy::AsPPB_CursorControl_FunctionAPI() { | 29 PPB_CursorControl_Proxy::AsPPB_CursorControl_FunctionAPI() { |
31 return this; | 30 return this; |
32 } | 31 } |
33 | 32 |
34 PP_Bool PPB_CursorControl_Proxy::SetCursor(PP_Instance instance, | 33 PP_Bool PPB_CursorControl_Proxy::SetCursor(PP_Instance instance, |
35 PP_CursorType_Dev type, | 34 PP_CursorType_Dev type, |
36 PP_Resource custom_image_id, | 35 PP_Resource custom_image_id, |
37 const PP_Point* hot_spot) { | 36 const PP_Point* hot_spot) { |
38 // It's legal for the image ID to be null if the type is not custom. | 37 // It's legal for the image ID to be null if the type is not custom. |
39 HostResource cursor_image_resource; | 38 HostResource cursor_image_resource; |
40 if (type == PP_CURSORTYPE_CUSTOM) { | 39 if (type == PP_CURSORTYPE_CUSTOM) { |
41 Resource* cursor_image = | 40 Resource* cursor_image = PluginResourceTracker::GetInstance()-> |
42 PpapiGlobals::Get()->GetResourceTracker()->GetResource(custom_image_id); | 41 GetResource(custom_image_id); |
43 if (!cursor_image || cursor_image->pp_instance() != instance) | 42 if (!cursor_image || cursor_image->pp_instance() != instance) |
44 return PP_FALSE; | 43 return PP_FALSE; |
45 cursor_image_resource = cursor_image->host_resource(); | 44 cursor_image_resource = cursor_image->host_resource(); |
46 } else { | 45 } else { |
47 if (custom_image_id) | 46 if (custom_image_id) |
48 return PP_FALSE; // Image specified for a predefined type. | 47 return PP_FALSE; // Image specified for a predefined type. |
49 } | 48 } |
50 | 49 |
51 PP_Bool result = PP_FALSE; | 50 PP_Bool result = PP_FALSE; |
52 PP_Point empty_point = { 0, 0 }; | 51 PP_Point empty_point = { 0, 0 }; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 139 |
141 void PPB_CursorControl_Proxy::OnMsgCanLockCursor(PP_Instance instance, | 140 void PPB_CursorControl_Proxy::OnMsgCanLockCursor(PP_Instance instance, |
142 PP_Bool* result) { | 141 PP_Bool* result) { |
143 EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); | 142 EnterFunctionNoLock<PPB_CursorControl_FunctionAPI> enter(instance, true); |
144 if (enter.succeeded()) | 143 if (enter.succeeded()) |
145 *result = enter.functions()->CanLockCursor(instance); | 144 *result = enter.functions()->CanLockCursor(instance); |
146 } | 145 } |
147 | 146 |
148 } // namespace proxy | 147 } // namespace proxy |
149 } // namespace ppapi | 148 } // namespace ppapi |
OLD | NEW |