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_flash_menu_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_menu_proxy.h" |
6 | 6 |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
8 #include "ppapi/c/private/ppb_flash_menu.h" | 8 #include "ppapi/c/private/ppb_flash_menu.h" |
9 #include "ppapi/proxy/ppapi_messages.h" | 9 #include "ppapi/proxy/ppapi_messages.h" |
| 10 #include "ppapi/thunk/common.h" |
10 | 11 |
11 namespace pp { | 12 namespace pp { |
12 namespace proxy { | 13 namespace proxy { |
13 | 14 |
14 class FlashMenu : public PluginResource { | 15 class FlashMenu : public PluginResource { |
15 public: | 16 public: |
16 explicit FlashMenu(const HostResource& resource) | 17 explicit FlashMenu(const HostResource& resource) |
17 : PluginResource(resource), | 18 : PluginResource(resource), |
18 callback_(PP_BlockUntilComplete()), | 19 callback_(PP_BlockUntilComplete()), |
19 selected_id_ptr_(NULL) { | 20 selected_id_ptr_(NULL) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 PP_Bool IsFlashMenu(PP_Resource resource) { | 62 PP_Bool IsFlashMenu(PP_Resource resource) { |
62 return BoolToPPBool(!!PluginResource::GetAs<FlashMenu>(resource)); | 63 return BoolToPPBool(!!PluginResource::GetAs<FlashMenu>(resource)); |
63 } | 64 } |
64 | 65 |
65 int32_t Show(PP_Resource menu_id, | 66 int32_t Show(PP_Resource menu_id, |
66 const PP_Point* location, | 67 const PP_Point* location, |
67 int32_t* selected_id, | 68 int32_t* selected_id, |
68 PP_CompletionCallback callback) { | 69 PP_CompletionCallback callback) { |
69 FlashMenu* object = PluginResource::GetAs<FlashMenu>(menu_id); | 70 FlashMenu* object = PluginResource::GetAs<FlashMenu>(menu_id); |
70 if (!object) | 71 if (!object) |
71 return PP_ERROR_BADRESOURCE; | 72 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
72 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | 73 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( |
73 object->instance()); | 74 object->instance()); |
74 if (!dispatcher) | 75 if (!dispatcher) |
75 return PP_ERROR_FAILED; | 76 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_FAILED); |
76 | 77 |
77 if (object->callback().func) | 78 if (object->callback().func) |
78 return PP_ERROR_INPROGRESS; | 79 return ppapi::thunk::MayForceCallback(callback, PP_ERROR_INPROGRESS); |
79 | 80 |
80 object->set_selected_id_ptr(selected_id); | 81 object->set_selected_id_ptr(selected_id); |
81 object->set_callback(callback); | 82 object->set_callback(callback); |
82 | 83 |
83 dispatcher->Send(new PpapiHostMsg_PPBFlashMenu_Show( | 84 dispatcher->Send(new PpapiHostMsg_PPBFlashMenu_Show( |
84 INTERFACE_ID_PPB_FLASH_MENU, object->host_resource(), *location)); | 85 INTERFACE_ID_PPB_FLASH_MENU, object->host_resource(), *location)); |
85 | 86 |
86 return PP_OK_COMPLETIONPENDING; | 87 return PP_OK_COMPLETIONPENDING; |
87 } | 88 } |
88 | 89 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( | 196 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( |
196 INTERFACE_ID_PPB_FLASH_MENU, | 197 INTERFACE_ID_PPB_FLASH_MENU, |
197 request->menu, | 198 request->menu, |
198 request->selected_id, | 199 request->selected_id, |
199 result)); | 200 result)); |
200 delete request; | 201 delete request; |
201 } | 202 } |
202 | 203 |
203 } // namespace proxy | 204 } // namespace proxy |
204 } // namespace pp | 205 } // namespace pp |
OLD | NEW |