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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 struct PPB_Flash_Menu_Proxy::ShowRequest { | 156 struct PPB_Flash_Menu_Proxy::ShowRequest { |
157 HostResource menu; | 157 HostResource menu; |
158 int32_t selected_id; | 158 int32_t selected_id; |
159 }; | 159 }; |
160 | 160 |
161 void PPB_Flash_Menu_Proxy::OnMsgShow(const HostResource& menu, | 161 void PPB_Flash_Menu_Proxy::OnMsgShow(const HostResource& menu, |
162 const PP_Point& location) { | 162 const PP_Point& location) { |
163 ShowRequest* request = new ShowRequest; | 163 ShowRequest* request = new ShowRequest; |
164 request->menu = menu; | 164 request->menu = menu; |
165 CompletionCallback callback = callback_factory_.NewOptionalCallback( | |
166 &PPB_Flash_Menu_Proxy::SendShowACKToPlugin, request); | |
167 | 165 |
168 EnterHostFromHostResource<PPB_Flash_Menu_API> enter(menu); | 166 EnterHostFromHostResourceForceCallback<PPB_Flash_Menu_API> enter( |
169 int32_t result = PP_ERROR_BADRESOURCE; | 167 menu, callback_factory_, &PPB_Flash_Menu_Proxy::SendShowACKToPlugin, |
| 168 request); |
170 if (enter.succeeded()) { | 169 if (enter.succeeded()) { |
171 result = enter.object()->Show(&location, | 170 enter.SetResult(enter.object()->Show(&location, &request->selected_id, |
172 &request->selected_id, | 171 enter.callback())); |
173 callback.pp_completion_callback()); | |
174 } | |
175 if (result != PP_OK_COMPLETIONPENDING) { | |
176 // There was some error, so we won't get a callback. We need to now issue | |
177 // the ACK to the plugin so that it hears about the error. This will also | |
178 // clean up the data associated with the callback. | |
179 callback.Run(result); | |
180 } | 172 } |
181 } | 173 } |
182 | 174 |
183 void PPB_Flash_Menu_Proxy::OnMsgShowACK(const HostResource& menu, | 175 void PPB_Flash_Menu_Proxy::OnMsgShowACK(const HostResource& menu, |
184 int32_t selected_id, | 176 int32_t selected_id, |
185 int32_t result) { | 177 int32_t result) { |
186 EnterPluginFromHostResource<PPB_Flash_Menu_API> enter(menu); | 178 EnterPluginFromHostResource<PPB_Flash_Menu_API> enter(menu); |
187 if (enter.failed()) | 179 if (enter.failed()) |
188 return; | 180 return; |
189 static_cast<FlashMenu*>(enter.object())->ShowACK(selected_id, result); | 181 static_cast<FlashMenu*>(enter.object())->ShowACK(selected_id, result); |
190 } | 182 } |
191 | 183 |
192 void PPB_Flash_Menu_Proxy::SendShowACKToPlugin( | 184 void PPB_Flash_Menu_Proxy::SendShowACKToPlugin( |
193 int32_t result, | 185 int32_t result, |
194 ShowRequest* request) { | 186 ShowRequest* request) { |
195 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( | 187 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( |
196 INTERFACE_ID_PPB_FLASH_MENU, | 188 INTERFACE_ID_PPB_FLASH_MENU, |
197 request->menu, | 189 request->menu, |
198 request->selected_id, | 190 request->selected_id, |
199 result)); | 191 result)); |
200 delete request; | 192 delete request; |
201 } | 193 } |
202 | 194 |
203 } // namespace proxy | 195 } // namespace proxy |
204 } // namespace pp | 196 } // namespace pp |
OLD | NEW |