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/enter_proxy.h" | 9 #include "ppapi/proxy/enter_proxy.h" |
10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 int32_t* selected_id, | 59 int32_t* selected_id, |
60 struct PP_CompletionCallback callback) { | 60 struct PP_CompletionCallback callback) { |
61 if (callback_.func) | 61 if (callback_.func) |
62 return PP_ERROR_INPROGRESS; | 62 return PP_ERROR_INPROGRESS; |
63 | 63 |
64 selected_id_ptr_ = selected_id; | 64 selected_id_ptr_ = selected_id; |
65 callback_ = callback; | 65 callback_ = callback; |
66 | 66 |
67 PluginDispatcher::GetForResource(this)->Send( | 67 PluginDispatcher::GetForResource(this)->Send( |
68 new PpapiHostMsg_PPBFlashMenu_Show( | 68 new PpapiHostMsg_PPBFlashMenu_Show( |
69 INTERFACE_ID_PPB_FLASH_MENU, host_resource(), *location)); | 69 API_ID_PPB_FLASH_MENU, host_resource(), *location)); |
70 return PP_OK_COMPLETIONPENDING; | 70 return PP_OK_COMPLETIONPENDING; |
71 } | 71 } |
72 | 72 |
73 void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { | 73 void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { |
74 *selected_id_ptr_ = selected_id; | 74 *selected_id_ptr_ = selected_id; |
75 PP_RunAndClearCompletionCallback(&callback_, result); | 75 PP_RunAndClearCompletionCallback(&callback_, result); |
76 } | 76 } |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 InterfaceProxy* CreateFlashMenuProxy(Dispatcher* dispatcher) { | 80 InterfaceProxy* CreateFlashMenuProxy(Dispatcher* dispatcher) { |
81 return new PPB_Flash_Menu_Proxy(dispatcher); | 81 return new PPB_Flash_Menu_Proxy(dispatcher); |
82 } | 82 } |
83 | 83 |
84 } // namespace | 84 } // namespace |
85 | 85 |
86 PPB_Flash_Menu_Proxy::PPB_Flash_Menu_Proxy(Dispatcher* dispatcher) | 86 PPB_Flash_Menu_Proxy::PPB_Flash_Menu_Proxy(Dispatcher* dispatcher) |
87 : InterfaceProxy(dispatcher), | 87 : InterfaceProxy(dispatcher), |
88 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { | 88 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
89 } | 89 } |
90 | 90 |
91 PPB_Flash_Menu_Proxy::~PPB_Flash_Menu_Proxy() { | 91 PPB_Flash_Menu_Proxy::~PPB_Flash_Menu_Proxy() { |
92 } | 92 } |
93 | 93 |
94 // static | 94 // static |
95 const InterfaceProxy::Info* PPB_Flash_Menu_Proxy::GetInfo() { | 95 const InterfaceProxy::Info* PPB_Flash_Menu_Proxy::GetInfo() { |
96 static const Info info = { | 96 static const Info info = { |
97 ppapi::thunk::GetPPB_Flash_Menu_Thunk(), | 97 ppapi::thunk::GetPPB_Flash_Menu_Thunk(), |
98 PPB_FLASH_MENU_INTERFACE, | 98 PPB_FLASH_MENU_INTERFACE, |
99 INTERFACE_ID_PPB_FLASH_MENU, | 99 API_ID_PPB_FLASH_MENU, |
100 true, | 100 true, |
101 &CreateFlashMenuProxy, | 101 &CreateFlashMenuProxy, |
102 }; | 102 }; |
103 return &info; | 103 return &info; |
104 } | 104 } |
105 | 105 |
106 // static | 106 // static |
107 PP_Resource PPB_Flash_Menu_Proxy::CreateProxyResource( | 107 PP_Resource PPB_Flash_Menu_Proxy::CreateProxyResource( |
108 PP_Instance instance_id, | 108 PP_Instance instance_id, |
109 const PP_Flash_Menu* menu_data) { | 109 const PP_Flash_Menu* menu_data) { |
110 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); | 110 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id); |
111 if (!dispatcher) | 111 if (!dispatcher) |
112 return 0; | 112 return 0; |
113 | 113 |
114 HostResource result; | 114 HostResource result; |
115 SerializedFlashMenu serialized_menu; | 115 SerializedFlashMenu serialized_menu; |
116 if (!serialized_menu.SetPPMenu(menu_data)) | 116 if (!serialized_menu.SetPPMenu(menu_data)) |
117 return 0; | 117 return 0; |
118 | 118 |
119 dispatcher->Send(new PpapiHostMsg_PPBFlashMenu_Create( | 119 dispatcher->Send(new PpapiHostMsg_PPBFlashMenu_Create( |
120 INTERFACE_ID_PPB_FLASH_MENU, instance_id, serialized_menu, &result)); | 120 API_ID_PPB_FLASH_MENU, instance_id, serialized_menu, &result)); |
121 if (result.is_null()) | 121 if (result.is_null()) |
122 return 0; | 122 return 0; |
123 return (new FlashMenu(result))->GetReference(); | 123 return (new FlashMenu(result))->GetReference(); |
124 } | 124 } |
125 | 125 |
126 bool PPB_Flash_Menu_Proxy::OnMessageReceived(const IPC::Message& msg) { | 126 bool PPB_Flash_Menu_Proxy::OnMessageReceived(const IPC::Message& msg) { |
127 bool handled = true; | 127 bool handled = true; |
128 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Menu_Proxy, msg) | 128 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Menu_Proxy, msg) |
129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashMenu_Create, | 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashMenu_Create, |
130 OnMsgCreate) | 130 OnMsgCreate) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 EnterPluginFromHostResource<PPB_Flash_Menu_API> enter(menu); | 175 EnterPluginFromHostResource<PPB_Flash_Menu_API> enter(menu); |
176 if (enter.failed()) | 176 if (enter.failed()) |
177 return; | 177 return; |
178 static_cast<FlashMenu*>(enter.object())->ShowACK(selected_id, result); | 178 static_cast<FlashMenu*>(enter.object())->ShowACK(selected_id, result); |
179 } | 179 } |
180 | 180 |
181 void PPB_Flash_Menu_Proxy::SendShowACKToPlugin( | 181 void PPB_Flash_Menu_Proxy::SendShowACKToPlugin( |
182 int32_t result, | 182 int32_t result, |
183 ShowRequest* request) { | 183 ShowRequest* request) { |
184 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( | 184 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( |
185 INTERFACE_ID_PPB_FLASH_MENU, | 185 API_ID_PPB_FLASH_MENU, |
186 request->menu, | 186 request->menu, |
187 request->selected_id, | 187 request->selected_id, |
188 result)); | 188 result)); |
189 delete request; | 189 delete request; |
190 } | 190 } |
191 | 191 |
192 } // namespace proxy | 192 } // namespace proxy |
193 } // namespace ppapi | 193 } // namespace ppapi |
OLD | NEW |