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" |
11 #include "ppapi/thunk/enter.h" | 11 #include "ppapi/thunk/enter.h" |
12 #include "ppapi/thunk/ppb_flash_menu_api.h" | 12 #include "ppapi/thunk/ppb_flash_menu_api.h" |
13 #include "ppapi/thunk/resource_creation_api.h" | 13 #include "ppapi/thunk/resource_creation_api.h" |
14 #include "ppapi/thunk/thunk.h" | 14 #include "ppapi/thunk/thunk.h" |
15 | 15 |
16 using ppapi::HostResource; | 16 using ppapi::HostResource; |
| 17 using ppapi::Resource; |
17 using ppapi::thunk::EnterFunctionNoLock; | 18 using ppapi::thunk::EnterFunctionNoLock; |
18 using ppapi::thunk::PPB_Flash_Menu_API; | 19 using ppapi::thunk::PPB_Flash_Menu_API; |
19 using ppapi::thunk::ResourceCreationAPI; | 20 using ppapi::thunk::ResourceCreationAPI; |
20 | 21 |
21 namespace pp { | 22 namespace pp { |
22 namespace proxy { | 23 namespace proxy { |
23 | 24 |
24 class FlashMenu : public PPB_Flash_Menu_API, public PluginResource { | 25 class FlashMenu : public PPB_Flash_Menu_API, public Resource { |
25 public: | 26 public: |
26 explicit FlashMenu(const HostResource& resource); | 27 explicit FlashMenu(const HostResource& resource); |
27 virtual ~FlashMenu(); | 28 virtual ~FlashMenu(); |
28 | 29 |
29 // ResourceObjectBase overrides. | 30 // Resource overrides. |
30 virtual PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE; | 31 virtual PPB_Flash_Menu_API* AsPPB_Flash_Menu_API() OVERRIDE; |
31 | 32 |
32 // PPB_Flash_Menu_API implementation. | 33 // PPB_Flash_Menu_API implementation. |
33 virtual int32_t Show(const PP_Point* location, | 34 virtual int32_t Show(const PP_Point* location, |
34 int32_t* selected_id, | 35 int32_t* selected_id, |
35 PP_CompletionCallback callback) OVERRIDE; | 36 PP_CompletionCallback callback) OVERRIDE; |
36 | 37 |
37 void ShowACK(int32_t selected_id, int32_t result); | 38 void ShowACK(int32_t selected_id, int32_t result); |
38 | 39 |
39 private: | 40 private: |
40 PP_CompletionCallback callback_; | 41 PP_CompletionCallback callback_; |
41 int32_t* selected_id_ptr_; | 42 int32_t* selected_id_ptr_; |
42 | 43 |
43 DISALLOW_COPY_AND_ASSIGN(FlashMenu); | 44 DISALLOW_COPY_AND_ASSIGN(FlashMenu); |
44 }; | 45 }; |
45 | 46 |
46 FlashMenu::FlashMenu(const HostResource& resource) | 47 FlashMenu::FlashMenu(const HostResource& resource) |
47 : PluginResource(resource), | 48 : Resource(resource), |
48 callback_(PP_BlockUntilComplete()), | 49 callback_(PP_BlockUntilComplete()), |
49 selected_id_ptr_(NULL) { | 50 selected_id_ptr_(NULL) { |
50 } | 51 } |
51 | 52 |
52 FlashMenu::~FlashMenu() { | 53 FlashMenu::~FlashMenu() { |
53 } | 54 } |
54 | 55 |
55 PPB_Flash_Menu_API* FlashMenu::AsPPB_Flash_Menu_API() { | 56 PPB_Flash_Menu_API* FlashMenu::AsPPB_Flash_Menu_API() { |
56 return this; | 57 return this; |
57 } | 58 } |
58 | 59 |
59 int32_t FlashMenu::Show(const struct PP_Point* location, | 60 int32_t FlashMenu::Show(const struct PP_Point* location, |
60 int32_t* selected_id, | 61 int32_t* selected_id, |
61 struct PP_CompletionCallback callback) { | 62 struct PP_CompletionCallback callback) { |
62 if (callback_.func) | 63 if (callback_.func) |
63 return PP_ERROR_INPROGRESS; | 64 return PP_ERROR_INPROGRESS; |
64 | 65 |
65 selected_id_ptr_ = selected_id; | 66 selected_id_ptr_ = selected_id; |
66 callback_ = callback; | 67 callback_ = callback; |
67 | 68 |
68 GetDispatcher()->Send(new PpapiHostMsg_PPBFlashMenu_Show( | 69 PluginDispatcher::GetForResource(this)->Send( |
69 INTERFACE_ID_PPB_FLASH_MENU, host_resource(), *location)); | 70 new PpapiHostMsg_PPBFlashMenu_Show( |
| 71 INTERFACE_ID_PPB_FLASH_MENU, host_resource(), *location)); |
70 return PP_OK_COMPLETIONPENDING; | 72 return PP_OK_COMPLETIONPENDING; |
71 } | 73 } |
72 | 74 |
73 void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { | 75 void FlashMenu::ShowACK(int32_t selected_id, int32_t result) { |
74 *selected_id_ptr_ = selected_id; | 76 *selected_id_ptr_ = selected_id; |
75 PP_RunAndClearCompletionCallback(&callback_, result); | 77 PP_RunAndClearCompletionCallback(&callback_, result); |
76 } | 78 } |
77 | 79 |
78 namespace { | 80 namespace { |
79 | 81 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 117 |
116 HostResource result; | 118 HostResource result; |
117 pp::proxy::SerializedFlashMenu serialized_menu; | 119 pp::proxy::SerializedFlashMenu serialized_menu; |
118 if (!serialized_menu.SetPPMenu(menu_data)) | 120 if (!serialized_menu.SetPPMenu(menu_data)) |
119 return 0; | 121 return 0; |
120 | 122 |
121 dispatcher->Send(new PpapiHostMsg_PPBFlashMenu_Create( | 123 dispatcher->Send(new PpapiHostMsg_PPBFlashMenu_Create( |
122 INTERFACE_ID_PPB_FLASH_MENU, instance_id, serialized_menu, &result)); | 124 INTERFACE_ID_PPB_FLASH_MENU, instance_id, serialized_menu, &result)); |
123 if (result.is_null()) | 125 if (result.is_null()) |
124 return 0; | 126 return 0; |
125 | 127 return (new FlashMenu(result))->GetReference(); |
126 return PluginResourceTracker::GetInstance()->AddResource( | |
127 new FlashMenu(result)); | |
128 } | 128 } |
129 | 129 |
130 bool PPB_Flash_Menu_Proxy::OnMessageReceived(const IPC::Message& msg) { | 130 bool PPB_Flash_Menu_Proxy::OnMessageReceived(const IPC::Message& msg) { |
131 bool handled = true; | 131 bool handled = true; |
132 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Menu_Proxy, msg) | 132 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Menu_Proxy, msg) |
133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashMenu_Create, | 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashMenu_Create, |
134 OnMsgCreate) | 134 OnMsgCreate) |
135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashMenu_Show, | 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlashMenu_Show, |
136 OnMsgShow) | 136 OnMsgShow) |
137 | 137 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( | 188 dispatcher()->Send(new PpapiMsg_PPBFlashMenu_ShowACK( |
189 INTERFACE_ID_PPB_FLASH_MENU, | 189 INTERFACE_ID_PPB_FLASH_MENU, |
190 request->menu, | 190 request->menu, |
191 request->selected_id, | 191 request->selected_id, |
192 result)); | 192 result)); |
193 delete request; | 193 delete request; |
194 } | 194 } |
195 | 195 |
196 } // namespace proxy | 196 } // namespace proxy |
197 } // namespace pp | 197 } // namespace pp |
OLD | NEW |