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

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

Issue 6334016: Refactor PPAPI proxy resource handling to maintain which host they came from,... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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_cursor_control_proxy.h ('k') | ppapi/proxy/ppb_flash_proxy.cc » ('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) 2010 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/ppb_cursor_control_dev.h" 8 #include "ppapi/c/dev/ppb_cursor_control_dev.h"
8 #include "ppapi/proxy/plugin_dispatcher.h" 9 #include "ppapi/proxy/plugin_dispatcher.h"
10 #include "ppapi/proxy/plugin_resource.h"
11 #include "ppapi/proxy/plugin_resource_tracker.h"
9 #include "ppapi/proxy/ppapi_messages.h" 12 #include "ppapi/proxy/ppapi_messages.h"
10 13
11 namespace pp { 14 namespace pp {
12 namespace proxy { 15 namespace proxy {
13 16
14 namespace { 17 namespace {
15 18
16 PP_Bool SetCursor(PP_Instance instance_id, 19 PP_Bool SetCursor(PP_Instance instance_id,
17 PP_CursorType_Dev type, 20 PP_CursorType_Dev type,
18 PP_Resource custom_image_id, 21 PP_Resource custom_image_id,
19 const PP_Point* hot_spot) { 22 const PP_Point* hot_spot) {
20 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); 23 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
21 if (!dispatcher) 24 if (!dispatcher)
22 return PP_FALSE; 25 return PP_FALSE;
23 26
27 // It's legal for the image ID to be null if the type is not custom.
28 HostResource cursor_image_resource;
29 if (type == PP_CURSORTYPE_CUSTOM) {
30 PluginResource* cursor_image = PluginResourceTracker::GetInstance()->
31 GetResourceObject(custom_image_id);
32 if (!cursor_image || cursor_image->instance() != instance_id)
33 return PP_FALSE;
34 cursor_image_resource = cursor_image->host_resource();
35 } else {
36 if (custom_image_id)
37 return PP_FALSE; // Image specified for a predefined type.
38 }
39
24 PP_Bool result = PP_FALSE; 40 PP_Bool result = PP_FALSE;
25 PP_Point empty_point = { 0, 0 }; 41 PP_Point empty_point = { 0, 0 };
26 dispatcher->Send(new PpapiHostMsg_PPBCursorControl_SetCursor( 42 dispatcher->Send(new PpapiHostMsg_PPBCursorControl_SetCursor(
27 INTERFACE_ID_PPB_CURSORCONTROL, 43 INTERFACE_ID_PPB_CURSORCONTROL,
28 instance_id, static_cast<int32_t>(type), custom_image_id, 44 instance_id, static_cast<int32_t>(type), cursor_image_resource,
29 hot_spot ? *hot_spot : empty_point, &result)); 45 hot_spot ? *hot_spot : empty_point, &result));
30 return result; 46 return result;
31 } 47 }
32 48
33 PP_Bool LockCursor(PP_Instance instance_id) { 49 PP_Bool LockCursor(PP_Instance instance_id) {
34 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); 50 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
35 if (!dispatcher) 51 if (!dispatcher)
36 return PP_FALSE; 52 return PP_FALSE;
37 53
38 PP_Bool result = PP_FALSE; 54 PP_Bool result = PP_FALSE;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_CanLockCursor, 130 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBCursorControl_CanLockCursor,
115 OnMsgCanLockCursor) 131 OnMsgCanLockCursor)
116 IPC_MESSAGE_UNHANDLED(handled = false) 132 IPC_MESSAGE_UNHANDLED(handled = false)
117 IPC_END_MESSAGE_MAP() 133 IPC_END_MESSAGE_MAP()
118 // TODO(brettw): handle bad messages! 134 // TODO(brettw): handle bad messages!
119 return handled; 135 return handled;
120 } 136 }
121 137
122 void PPB_CursorControl_Proxy::OnMsgSetCursor(PP_Instance instance, 138 void PPB_CursorControl_Proxy::OnMsgSetCursor(PP_Instance instance,
123 int32_t type, 139 int32_t type,
124 PP_Resource custom_image, 140 HostResource custom_image,
125 const PP_Point& hot_spot, 141 const PP_Point& hot_spot,
126 PP_Bool* result) { 142 PP_Bool* result) {
127 *result = ppb_cursor_control_target()->SetCursor( 143 *result = ppb_cursor_control_target()->SetCursor(
128 instance, static_cast<PP_CursorType_Dev>(type), custom_image, &hot_spot); 144 instance, static_cast<PP_CursorType_Dev>(type),
145 custom_image.host_resource(), &hot_spot);
129 } 146 }
130 147
131 void PPB_CursorControl_Proxy::OnMsgLockCursor(PP_Instance instance, 148 void PPB_CursorControl_Proxy::OnMsgLockCursor(PP_Instance instance,
132 PP_Bool* result) { 149 PP_Bool* result) {
133 *result = ppb_cursor_control_target()->LockCursor(instance); 150 *result = ppb_cursor_control_target()->LockCursor(instance);
134 } 151 }
135 152
136 void PPB_CursorControl_Proxy::OnMsgUnlockCursor(PP_Instance instance, 153 void PPB_CursorControl_Proxy::OnMsgUnlockCursor(PP_Instance instance,
137 PP_Bool* result) { 154 PP_Bool* result) {
138 *result = ppb_cursor_control_target()->UnlockCursor(instance); 155 *result = ppb_cursor_control_target()->UnlockCursor(instance);
139 } 156 }
140 157
141 void PPB_CursorControl_Proxy::OnMsgHasCursorLock(PP_Instance instance, 158 void PPB_CursorControl_Proxy::OnMsgHasCursorLock(PP_Instance instance,
142 PP_Bool* result) { 159 PP_Bool* result) {
143 *result = ppb_cursor_control_target()->HasCursorLock(instance); 160 *result = ppb_cursor_control_target()->HasCursorLock(instance);
144 } 161 }
145 162
146 void PPB_CursorControl_Proxy::OnMsgCanLockCursor(PP_Instance instance, 163 void PPB_CursorControl_Proxy::OnMsgCanLockCursor(PP_Instance instance,
147 PP_Bool* result) { 164 PP_Bool* result) {
148 *result = ppb_cursor_control_target()->CanLockCursor(instance); 165 *result = ppb_cursor_control_target()->CanLockCursor(instance);
149 } 166 }
150 167
151 } // namespace proxy 168 } // namespace proxy
152 } // namespace pp 169 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/proxy/ppb_cursor_control_proxy.h ('k') | ppapi/proxy/ppb_flash_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698