| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 12 matching lines...) Expand all Loading... |
| 23 public: | 23 public: |
| 24 explicit FlashMenu(const HostResource& resource); | 24 explicit FlashMenu(const HostResource& resource); |
| 25 virtual ~FlashMenu(); | 25 virtual ~FlashMenu(); |
| 26 | 26 |
| 27 // Resource overrides. | 27 // Resource overrides. |
| 28 virtual PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE; | 28 virtual PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE; |
| 29 | 29 |
| 30 // PPB_Flash_Menu_API implementation. | 30 // PPB_Flash_Menu_API implementation. |
| 31 virtual int32_t Show(const PP_Point* location, | 31 virtual int32_t Show(const PP_Point* location, |
| 32 int32_t* selected_id, | 32 int32_t* selected_id, |
| 33 PP_CompletionCallback callback) OVERRIDE; | 33 scoped_refptr<TrackedCallback> callback) OVERRIDE; |
| 34 | 34 |
| 35 void ShowACK(int32_t selected_id, int32_t result); | 35 void ShowACK(int32_t selected_id, int32_t result); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 scoped_refptr<TrackedCallback> callback_; | 38 scoped_refptr<TrackedCallback> callback_; |
| 39 int32_t* selected_id_ptr_; | 39 int32_t* selected_id_ptr_; |
| 40 | 40 |
| 41 DISALLOW_COPY_AND_ASSIGN(FlashMenu); | 41 DISALLOW_COPY_AND_ASSIGN(FlashMenu); |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 FlashMenu::FlashMenu(const HostResource& resource) | 44 FlashMenu::FlashMenu(const HostResource& resource) |
| 45 : Resource(OBJECT_IS_PROXY, resource), | 45 : Resource(OBJECT_IS_PROXY, resource), |
| 46 selected_id_ptr_(NULL) { | 46 selected_id_ptr_(NULL) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 FlashMenu::~FlashMenu() { | 49 FlashMenu::~FlashMenu() { |
| 50 } | 50 } |
| 51 | 51 |
| 52 PPB_Flash_Menu_API* FlashMenu::AsPPB_Flash_Menu_API() { | 52 PPB_Flash_Menu_API* FlashMenu::AsPPB_Flash_Menu_API() { |
| 53 return this; | 53 return this; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int32_t FlashMenu::Show(const struct PP_Point* location, | 56 int32_t FlashMenu::Show(const struct PP_Point* location, |
| 57 int32_t* selected_id, | 57 int32_t* selected_id, |
| 58 struct PP_CompletionCallback callback) { | 58 scoped_refptr<TrackedCallback> callback) { |
| 59 if (TrackedCallback::IsPending(callback_)) | 59 if (TrackedCallback::IsPending(callback_)) |
| 60 return PP_ERROR_INPROGRESS; | 60 return PP_ERROR_INPROGRESS; |
| 61 | 61 |
| 62 selected_id_ptr_ = selected_id; | 62 selected_id_ptr_ = selected_id; |
| 63 callback_ = new TrackedCallback(this, callback); | 63 callback_ = callback; |
| 64 | 64 |
| 65 PluginDispatcher::GetForResource(this)->Send( | 65 PluginDispatcher::GetForResource(this)->Send( |
| 66 new PpapiHostMsg_PPBFlashMenu_Show( | 66 new PpapiHostMsg_PPBFlashMenu_Show( |
| 67 API_ID_PPB_FLASH_MENU, host_resource(), *location)); | 67 API_ID_PPB_FLASH_MENU, host_resource(), *location)); |
| 68 return PP_OK_COMPLETIONPENDING; | 68 return PP_OK_COMPLETIONPENDING; |
| 69 } | 69 } |
| 70 | 70 |
| 71 void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { | 71 void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { |
| 72 *selected_id_ptr_ = selected_id; | 72 *selected_id_ptr_ = selected_id; |
| 73 TrackedCallback::ClearAndRun(&callback_, result); | 73 TrackedCallback::ClearAndRun(&callback_, result); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( | 162 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( |
| 163 API_ID_PPB_FLASH_MENU, | 163 API_ID_PPB_FLASH_MENU, |
| 164 request->menu, | 164 request->menu, |
| 165 request->selected_id, | 165 request->selected_id, |
| 166 result)); | 166 result)); |
| 167 delete request; | 167 delete request; |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace proxy | 170 } // namespace proxy |
| 171 } // namespace ppapi | 171 } // namespace ppapi |
| OLD | NEW |