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_proxy.h" | 5 #include "ppapi/proxy/ppb_flash_proxy.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "ppapi/c/dev/ppb_font_dev.h" | 10 #include "ppapi/c/dev/ppb_font_dev.h" |
11 #include "ppapi/c/dev/ppb_var_deprecated.h" | 11 #include "ppapi/c/dev/ppb_var_deprecated.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/pp_resource.h" | 13 #include "ppapi/c/pp_resource.h" |
14 #include "ppapi/c/private/ppb_flash.h" | 14 #include "ppapi/c/private/ppb_flash.h" |
15 #include "ppapi/proxy/host_dispatcher.h" | 15 #include "ppapi/proxy/host_dispatcher.h" |
16 #include "ppapi/proxy/plugin_dispatcher.h" | 16 #include "ppapi/proxy/plugin_dispatcher.h" |
17 #include "ppapi/proxy/plugin_globals.h" | 17 #include "ppapi/proxy/plugin_globals.h" |
18 #include "ppapi/proxy/plugin_proxy_delegate.h" | 18 #include "ppapi/proxy/plugin_proxy_delegate.h" |
19 #include "ppapi/proxy/ppapi_messages.h" | 19 #include "ppapi/proxy/ppapi_messages.h" |
20 #include "ppapi/proxy/proxy_module.h" | 20 #include "ppapi/proxy/proxy_module.h" |
21 #include "ppapi/proxy/serialized_var.h" | 21 #include "ppapi/proxy/serialized_var.h" |
22 #include "ppapi/shared_impl/ppapi_globals.h" | 22 #include "ppapi/shared_impl/ppapi_globals.h" |
23 #include "ppapi/shared_impl/proxy_lock.h" | 23 #include "ppapi/shared_impl/proxy_lock.h" |
24 #include "ppapi/shared_impl/resource.h" | 24 #include "ppapi/shared_impl/resource.h" |
25 #include "ppapi/shared_impl/resource_tracker.h" | 25 #include "ppapi/shared_impl/resource_tracker.h" |
26 #include "ppapi/shared_impl/scoped_pp_resource.h" | 26 #include "ppapi/shared_impl/scoped_pp_resource.h" |
27 #include "ppapi/shared_impl/var.h" | 27 #include "ppapi/shared_impl/var.h" |
28 #include "ppapi/thunk/enter.h" | 28 #include "ppapi/thunk/enter.h" |
29 #include "ppapi/thunk/ppb_instance_api.h" | |
29 #include "ppapi/thunk/ppb_url_request_info_api.h" | 30 #include "ppapi/thunk/ppb_url_request_info_api.h" |
30 #include "ppapi/thunk/resource_creation_api.h" | 31 #include "ppapi/thunk/resource_creation_api.h" |
31 | 32 |
32 namespace ppapi { | 33 namespace ppapi { |
33 namespace proxy { | 34 namespace proxy { |
34 | 35 |
35 namespace { | 36 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) |
36 | 37 : InterfaceProxy(dispatcher), |
37 void SetInstanceAlwaysOnTop(PP_Instance pp_instance, PP_Bool on_top) { | 38 ppb_flash_impl_(NULL) { |
38 ProxyAutoLock lock; | 39 if (!dispatcher->IsPlugin()) |
39 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(pp_instance); | 40 ppb_flash_impl_ = static_cast<const PPB_Flash*>( |
40 if (dispatcher) { | 41 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE)); |
41 dispatcher->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( | |
42 API_ID_PPB_FLASH, pp_instance, on_top)); | |
43 } | |
44 } | 42 } |
45 | 43 |
46 PP_Bool DrawGlyphs(PP_Instance instance, | 44 PPB_Flash_Proxy::~PPB_Flash_Proxy() { |
47 PP_Resource pp_image_data, | 45 } |
48 const PP_FontDescription_Dev* font_desc, | 46 |
49 uint32_t color, | 47 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
50 const PP_Point* position, | 48 // Prevent the dispatcher from going away during a call to Navigate. |
51 const PP_Rect* clip, | 49 // This must happen OUTSIDE of OnMsgNavigate since the handling code use |
52 const float transformation[3][3], | 50 // the dispatcher upon return of the function (sending the reply message). |
53 PP_Bool allow_subpixel_aa, | 51 ScopedModuleReference death_grip(dispatcher()); |
54 uint32_t glyph_count, | 52 |
55 const uint16_t glyph_indices[], | 53 bool handled = true; |
56 const PP_Point glyph_advances[]) { | 54 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) |
55 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, | |
56 OnHostMsgSetInstanceAlwaysOnTop) | |
57 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, | |
58 OnHostMsgDrawGlyphs) | |
59 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, | |
60 OnHostMsgGetProxyForURL) | |
61 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnHostMsgNavigate) | |
62 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop, | |
63 OnHostMsgRunMessageLoop) | |
64 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, | |
65 OnHostMsgQuitMessageLoop) | |
66 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | |
67 OnHostMsgGetLocalTimeZoneOffset) | |
68 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | |
69 OnHostMsgIsRectTopmost) | |
70 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashSetFullscreen, | |
71 OnHostMsgFlashSetFullscreen) | |
72 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_FlashGetScreenSize, | |
73 OnHostMsgFlashGetScreenSize) | |
74 IPC_MESSAGE_UNHANDLED(handled = false) | |
75 IPC_END_MESSAGE_MAP() | |
76 // TODO(brettw) handle bad messages! | |
77 return handled; | |
78 } | |
79 | |
80 void PPB_Flash_Proxy::SetInstanceAlwaysOnTop(PP_Instance instance, | |
81 PP_Bool on_top) { | |
82 dispatcher()->Send(new PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop( | |
83 API_ID_PPB_FLASH, instance, on_top)); | |
84 } | |
85 | |
86 PP_Bool PPB_Flash_Proxy::DrawGlyphs(PP_Instance instance, | |
87 PP_Resource pp_image_data, | |
88 const PP_FontDescription_Dev* font_desc, | |
89 uint32_t color, | |
90 const PP_Point* position, | |
91 const PP_Rect* clip, | |
92 const float transformation[3][3], | |
93 PP_Bool allow_subpixel_aa, | |
94 uint32_t glyph_count, | |
95 const uint16_t glyph_indices[], | |
96 const PP_Point glyph_advances[]) { | |
57 ProxyAutoLock lock; | 97 ProxyAutoLock lock; |
yzshen1
2012/04/18 17:57:22
I think this is not needed now, right?
| |
58 Resource* image_data = | 98 Resource* image_data = |
59 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); | 99 PpapiGlobals::Get()->GetResourceTracker()->GetResource(pp_image_data); |
60 if (!image_data) | 100 if (!image_data) |
61 return PP_FALSE; | 101 return PP_FALSE; |
62 // The instance parameter isn't strictly necessary but we check that it | 102 // The instance parameter isn't strictly necessary but we check that it |
63 // matches anyway. | 103 // matches anyway. |
64 if (image_data->pp_instance() != instance) | 104 if (image_data->pp_instance() != instance) |
65 return PP_FALSE; | 105 return PP_FALSE; |
66 | 106 |
67 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance( | |
68 image_data->pp_instance()); | |
69 if (!dispatcher) | |
70 return PP_FALSE; | |
71 | |
72 PPBFlash_DrawGlyphs_Params params; | 107 PPBFlash_DrawGlyphs_Params params; |
73 params.image_data = image_data->host_resource(); | 108 params.image_data = image_data->host_resource(); |
74 params.font_desc.SetFromPPFontDescription(dispatcher, *font_desc, true); | 109 params.font_desc.SetFromPPFontDescription(dispatcher(), *font_desc, true); |
75 params.color = color; | 110 params.color = color; |
76 params.position = *position; | 111 params.position = *position; |
77 params.clip = *clip; | 112 params.clip = *clip; |
78 for (int i = 0; i < 3; i++) { | 113 for (int i = 0; i < 3; i++) { |
79 for (int j = 0; j < 3; j++) | 114 for (int j = 0; j < 3; j++) |
80 params.transformation[i][j] = transformation[i][j]; | 115 params.transformation[i][j] = transformation[i][j]; |
81 } | 116 } |
82 params.allow_subpixel_aa = allow_subpixel_aa; | 117 params.allow_subpixel_aa = allow_subpixel_aa; |
83 | 118 |
84 params.glyph_indices.insert(params.glyph_indices.begin(), | 119 params.glyph_indices.insert(params.glyph_indices.begin(), |
85 &glyph_indices[0], | 120 &glyph_indices[0], |
86 &glyph_indices[glyph_count]); | 121 &glyph_indices[glyph_count]); |
87 params.glyph_advances.insert(params.glyph_advances.begin(), | 122 params.glyph_advances.insert(params.glyph_advances.begin(), |
88 &glyph_advances[0], | 123 &glyph_advances[0], |
89 &glyph_advances[glyph_count]); | 124 &glyph_advances[glyph_count]); |
90 | 125 |
91 PP_Bool result = PP_FALSE; | 126 PP_Bool result = PP_FALSE; |
92 dispatcher->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( | 127 dispatcher()->Send(new PpapiHostMsg_PPBFlash_DrawGlyphs( |
93 API_ID_PPB_FLASH, params, &result)); | 128 API_ID_PPB_FLASH, params, &result)); |
94 return result; | 129 return result; |
95 } | 130 } |
96 | 131 |
97 PP_Bool DrawGlyphs11(PP_Instance instance, | 132 PP_Var PPB_Flash_Proxy::GetProxyForURL(PP_Instance instance, const char* url) { |
98 PP_Resource pp_image_data, | 133 ReceiveSerializedVarReturnValue result; |
99 const PP_FontDescription_Dev* font_desc, | 134 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( |
100 uint32_t color, | 135 API_ID_PPB_FLASH, instance, url, &result)); |
101 PP_Point position, | 136 return result.Return(dispatcher()); |
102 PP_Rect clip, | |
103 const float transformation[3][3], | |
104 uint32_t glyph_count, | |
105 const uint16_t glyph_indices[], | |
106 const PP_Point glyph_advances[]) { | |
107 // Backwards-compatible version. DrawGlyphs locks; no need to lock here. | |
108 return DrawGlyphs(instance, pp_image_data, font_desc, color, &position, | |
109 &clip, transformation, PP_TRUE, glyph_count, glyph_indices, | |
110 glyph_advances); | |
111 } | 137 } |
112 | 138 |
113 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { | 139 int32_t PPB_Flash_Proxy::Navigate(PP_Instance instance, |
114 ProxyAutoLock lock; | 140 PP_Resource request_info, |
115 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 141 const char* target, |
116 if (!dispatcher) | 142 PP_Bool from_user_action) { |
117 return PP_MakeUndefined(); | 143 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_info, true); |
118 | |
119 ReceiveSerializedVarReturnValue result; | |
120 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetProxyForURL( | |
121 API_ID_PPB_FLASH, instance, url, &result)); | |
122 return result.Return(dispatcher); | |
123 } | |
124 | |
125 int32_t Navigate(PP_Resource request_id, | |
126 const char* target, | |
127 PP_Bool from_user_action) { | |
128 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true); | |
129 if (enter.failed()) | 144 if (enter.failed()) |
130 return PP_ERROR_BADRESOURCE; | 145 return PP_ERROR_BADRESOURCE; |
131 PP_Instance instance = enter.resource()->pp_instance(); | |
132 | |
133 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
134 if (!dispatcher) | |
135 return PP_ERROR_FAILED; | |
136 | 146 |
137 int32_t result = PP_ERROR_FAILED; | 147 int32_t result = PP_ERROR_FAILED; |
138 dispatcher->Send(new PpapiHostMsg_PPBFlash_Navigate( | 148 dispatcher()->Send(new PpapiHostMsg_PPBFlash_Navigate( |
139 API_ID_PPB_FLASH, | 149 API_ID_PPB_FLASH, |
140 instance, enter.object()->GetData(), target, from_user_action, | 150 instance, enter.object()->GetData(), target, from_user_action, |
141 &result)); | 151 &result)); |
142 return result; | 152 return result; |
143 } | 153 } |
144 | 154 |
145 int32_t Navigate11(PP_Resource request_id, | 155 void PPB_Flash_Proxy::RunMessageLoop(PP_Instance instance) { |
146 const char* target, | |
147 bool from_user_action) { | |
148 // Backwards-compatible version. Navigate locks; no need to lock here. | |
149 return Navigate(request_id, target, PP_FromBool(from_user_action)); | |
150 } | |
151 | |
152 void RunMessageLoop(PP_Instance instance) { | |
153 ProxyAutoLock lock; | |
154 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
155 if (!dispatcher) | |
156 return; | |
157 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( | 156 IPC::SyncMessage* msg = new PpapiHostMsg_PPBFlash_RunMessageLoop( |
158 API_ID_PPB_FLASH, instance); | 157 API_ID_PPB_FLASH, instance); |
159 msg->EnableMessagePumping(); | 158 msg->EnableMessagePumping(); |
160 dispatcher->Send(msg); | 159 dispatcher()->Send(msg); |
161 } | 160 } |
162 | 161 |
163 void QuitMessageLoop(PP_Instance instance) { | 162 void PPB_Flash_Proxy::QuitMessageLoop(PP_Instance instance) { |
164 ProxyAutoLock lock; | 163 dispatcher()->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( |
165 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
166 if (!dispatcher) | |
167 return; | |
168 dispatcher->Send(new PpapiHostMsg_PPBFlash_QuitMessageLoop( | |
169 API_ID_PPB_FLASH, instance)); | 164 API_ID_PPB_FLASH, instance)); |
170 } | 165 } |
171 | 166 |
172 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { | 167 double PPB_Flash_Proxy::GetLocalTimeZoneOffset(PP_Instance instance, |
173 ProxyAutoLock lock; | 168 PP_Time t) { |
174 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
175 if (!dispatcher) | |
176 return 0.0; | |
177 | |
178 // TODO(brettw) on Windows it should be possible to do the time calculation | 169 // TODO(brettw) on Windows it should be possible to do the time calculation |
179 // in-process since it doesn't need to read files on disk. This will improve | 170 // in-process since it doesn't need to read files on disk. This will improve |
180 // performance. | 171 // performance. |
181 // | 172 // |
182 // On Linux, it would be better to go directly to the browser process for | 173 // On Linux, it would be better to go directly to the browser process for |
183 // this message rather than proxy it through some instance in a renderer. | 174 // this message rather than proxy it through some instance in a renderer. |
184 double result = 0; | 175 double result = 0; |
185 dispatcher->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( | 176 dispatcher()->Send(new PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset( |
186 API_ID_PPB_FLASH, instance, t, &result)); | 177 API_ID_PPB_FLASH, instance, t, &result)); |
187 return result; | 178 return result; |
188 } | 179 } |
189 | 180 |
190 PP_Var GetCommandLineArgs(PP_Module /*pp_module*/) { | 181 PP_Bool PPB_Flash_Proxy::IsRectTopmost(PP_Instance instance, |
191 ProxyAutoLock lock; | 182 const PP_Rect* rect) { |
192 std::string args = ProxyModule::GetInstance()->GetFlashCommandLineArgs(); | |
193 return StringVar::StringToPPVar(args); | |
194 } | |
195 | |
196 void PreLoadFontWin(const void* logfontw) { | |
197 ProxyAutoLock lock; | |
198 PluginGlobals::Get()->plugin_proxy_delegate()->PreCacheFont(logfontw); | |
199 } | |
200 | |
201 PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) { | |
202 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
203 if (!dispatcher) | |
204 return PP_FALSE; | |
205 PP_Bool result = PP_FALSE; | 183 PP_Bool result = PP_FALSE; |
206 dispatcher->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( | 184 dispatcher()->Send(new PpapiHostMsg_PPBFlash_IsRectTopmost( |
207 API_ID_PPB_FLASH, instance, *rect, &result)); | 185 API_ID_PPB_FLASH, instance, *rect, &result)); |
208 return result; | 186 return result; |
209 } | 187 } |
210 | 188 |
211 int32_t InvokePrinting(PP_Instance instance) { | 189 int32_t PPB_Flash_Proxy::InvokePrinting(PP_Instance instance) { |
212 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | |
213 if (!dispatcher) | |
214 return PP_ERROR_BADARGUMENT; | |
215 | |
216 // TODO(viettrungluu): Implement me. | |
217 | |
218 return PP_ERROR_NOTSUPPORTED; | 190 return PP_ERROR_NOTSUPPORTED; |
219 } | 191 } |
220 | 192 |
221 void UpdateActivity(PP_Instance instance) { | 193 void PPB_Flash_Proxy::UpdateActivity(PP_Instance instance) { |
222 // TODO(viettrungluu): Implement me. | 194 // TODO(viettrungluu): Implement me. |
223 } | 195 } |
224 | 196 |
225 PP_Var GetDeviceID(PP_Instance instance) { | 197 PP_Var PPB_Flash_Proxy::GetDeviceID(PP_Instance instance) { |
226 // TODO(brettw) implement me. | 198 // TODO(brettw) implement me. |
227 return PP_MakeUndefined(); | 199 return PP_MakeUndefined(); |
228 } | 200 } |
229 | 201 |
230 const PPB_Flash_11 flash_interface_11 = { | 202 PP_Bool PPB_Flash_Proxy::FlashIsFullscreen(PP_Instance instance) { |
231 &SetInstanceAlwaysOnTop, | 203 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
232 &DrawGlyphs11, | 204 GetInstanceData(instance); |
233 &GetProxyForURL, | 205 if (!data) |
234 &Navigate11, | 206 return PP_FALSE; |
235 &RunMessageLoop, | 207 return data->flash_fullscreen; |
236 &QuitMessageLoop, | |
237 &GetLocalTimeZoneOffset, | |
238 &GetCommandLineArgs | |
239 }; | |
240 | |
241 const PPB_Flash_12_0 flash_interface_12_0 = { | |
242 &SetInstanceAlwaysOnTop, | |
243 &DrawGlyphs, | |
244 &GetProxyForURL, | |
245 &Navigate, | |
246 &RunMessageLoop, | |
247 &QuitMessageLoop, | |
248 &GetLocalTimeZoneOffset, | |
249 &GetCommandLineArgs, | |
250 &PreLoadFontWin | |
251 }; | |
252 | |
253 const PPB_Flash_12_1 flash_interface_12_1 = { | |
254 &SetInstanceAlwaysOnTop, | |
255 &DrawGlyphs, | |
256 &GetProxyForURL, | |
257 &Navigate, | |
258 &RunMessageLoop, | |
259 &QuitMessageLoop, | |
260 &GetLocalTimeZoneOffset, | |
261 &GetCommandLineArgs, | |
262 &PreLoadFontWin, | |
263 &IsRectTopmost, | |
264 &InvokePrinting, | |
265 &UpdateActivity | |
266 }; | |
267 | |
268 const PPB_Flash_12_2 flash_interface_12_2 = { | |
269 &SetInstanceAlwaysOnTop, | |
270 &DrawGlyphs, | |
271 &GetProxyForURL, | |
272 &Navigate, | |
273 &RunMessageLoop, | |
274 &QuitMessageLoop, | |
275 &GetLocalTimeZoneOffset, | |
276 &GetCommandLineArgs, | |
277 &PreLoadFontWin, | |
278 &IsRectTopmost, | |
279 &InvokePrinting, | |
280 &UpdateActivity, | |
281 &GetDeviceID | |
282 }; | |
283 | |
284 } // namespace | |
285 | |
286 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) | |
287 : InterfaceProxy(dispatcher), | |
288 ppb_flash_impl_(NULL) { | |
289 if (!dispatcher->IsPlugin()) | |
290 ppb_flash_impl_ = static_cast<const PPB_Flash*>( | |
291 dispatcher->local_get_interface()(PPB_FLASH_INTERFACE)); | |
292 } | 208 } |
293 | 209 |
294 PPB_Flash_Proxy::~PPB_Flash_Proxy() { | 210 PP_Bool PPB_Flash_Proxy::FlashSetFullscreen(PP_Instance instance, |
211 PP_Bool fullscreen) { | |
212 PP_Bool result = PP_FALSE; | |
213 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashSetFullscreen( | |
214 API_ID_PPB_INSTANCE, instance, fullscreen, &result)); | |
215 return result; | |
295 } | 216 } |
296 | 217 |
297 // static | 218 PP_Bool PPB_Flash_Proxy::FlashGetScreenSize(PP_Instance instance, |
298 const PPB_Flash_11* PPB_Flash_Proxy::GetInterface11() { | 219 PP_Size* size) { |
299 return &flash_interface_11; | 220 PP_Bool result = PP_FALSE; |
221 dispatcher()->Send(new PpapiHostMsg_PPBFlash_FlashGetScreenSize( | |
222 API_ID_PPB_INSTANCE, instance, &result, size)); | |
223 return result; | |
300 } | 224 } |
301 | 225 |
302 // static | 226 void PPB_Flash_Proxy::OnHostMsgSetInstanceAlwaysOnTop(PP_Instance instance, |
303 const PPB_Flash_12_0* PPB_Flash_Proxy::GetInterface12_0() { | 227 PP_Bool on_top) { |
304 return &flash_interface_12_0; | |
305 } | |
306 | |
307 // static | |
308 const PPB_Flash_12_1* PPB_Flash_Proxy::GetInterface12_1() { | |
309 return &flash_interface_12_1; | |
310 } | |
311 | |
312 // static | |
313 const PPB_Flash_12_2* PPB_Flash_Proxy::GetInterface12_2() { | |
314 return &flash_interface_12_2; | |
315 } | |
316 | |
317 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | |
318 // Prevent the dispatcher from going away during a call to Navigate. | |
319 // This must happen OUTSIDE of OnMsgNavigate since the handling code use | |
320 // the dispatcher upon return of the function (sending the reply message). | |
321 ScopedModuleReference death_grip(dispatcher()); | |
322 | |
323 bool handled = true; | |
324 IPC_BEGIN_MESSAGE_MAP(PPB_Flash_Proxy, msg) | |
325 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_SetInstanceAlwaysOnTop, | |
326 OnMsgSetInstanceAlwaysOnTop) | |
327 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_DrawGlyphs, | |
328 OnMsgDrawGlyphs) | |
329 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetProxyForURL, | |
330 OnMsgGetProxyForURL) | |
331 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_Navigate, OnMsgNavigate) | |
332 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_RunMessageLoop, | |
333 OnMsgRunMessageLoop) | |
334 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_QuitMessageLoop, | |
335 OnMsgQuitMessageLoop) | |
336 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_GetLocalTimeZoneOffset, | |
337 OnMsgGetLocalTimeZoneOffset) | |
338 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBFlash_IsRectTopmost, | |
339 OnMsgIsRectTopmost) | |
340 IPC_MESSAGE_UNHANDLED(handled = false) | |
341 IPC_END_MESSAGE_MAP() | |
342 // TODO(brettw) handle bad messages! | |
343 return handled; | |
344 } | |
345 | |
346 void PPB_Flash_Proxy::OnMsgSetInstanceAlwaysOnTop( | |
347 PP_Instance instance, | |
348 PP_Bool on_top) { | |
349 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); | 228 ppb_flash_impl_->SetInstanceAlwaysOnTop(instance, on_top); |
350 } | 229 } |
351 | 230 |
352 void PPB_Flash_Proxy::OnMsgDrawGlyphs(const PPBFlash_DrawGlyphs_Params& params, | 231 void PPB_Flash_Proxy::OnHostMsgDrawGlyphs( |
353 PP_Bool* result) { | 232 const PPBFlash_DrawGlyphs_Params& params, |
233 PP_Bool* result) { | |
354 *result = PP_FALSE; | 234 *result = PP_FALSE; |
355 | 235 |
356 PP_FontDescription_Dev font_desc; | 236 PP_FontDescription_Dev font_desc; |
357 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); | 237 params.font_desc.SetToPPFontDescription(dispatcher(), &font_desc, false); |
358 | 238 |
359 if (params.glyph_indices.size() != params.glyph_advances.size() || | 239 if (params.glyph_indices.size() != params.glyph_advances.size() || |
360 params.glyph_indices.empty()) | 240 params.glyph_indices.empty()) |
361 return; | 241 return; |
362 | 242 |
363 *result = ppb_flash_impl_->DrawGlyphs( | 243 *result = ppb_flash_impl_->DrawGlyphs( |
364 0, // Unused instance param. | 244 0, // Unused instance param. |
365 params.image_data.host_resource(), &font_desc, | 245 params.image_data.host_resource(), &font_desc, |
366 params.color, ¶ms.position, ¶ms.clip, | 246 params.color, ¶ms.position, ¶ms.clip, |
367 const_cast<float(*)[3]>(params.transformation), | 247 const_cast<float(*)[3]>(params.transformation), |
368 params.allow_subpixel_aa, | 248 params.allow_subpixel_aa, |
369 static_cast<uint32_t>(params.glyph_indices.size()), | 249 static_cast<uint32_t>(params.glyph_indices.size()), |
370 const_cast<uint16_t*>(¶ms.glyph_indices[0]), | 250 const_cast<uint16_t*>(¶ms.glyph_indices[0]), |
371 const_cast<PP_Point*>(¶ms.glyph_advances[0])); | 251 const_cast<PP_Point*>(¶ms.glyph_advances[0])); |
372 } | 252 } |
373 | 253 |
374 void PPB_Flash_Proxy::OnMsgGetProxyForURL(PP_Instance instance, | 254 void PPB_Flash_Proxy::OnHostMsgGetProxyForURL(PP_Instance instance, |
375 const std::string& url, | 255 const std::string& url, |
376 SerializedVarReturnValue result) { | 256 SerializedVarReturnValue result) { |
377 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( | 257 result.Return(dispatcher(), ppb_flash_impl_->GetProxyForURL( |
378 instance, url.c_str())); | 258 instance, url.c_str())); |
379 } | 259 } |
380 | 260 |
381 void PPB_Flash_Proxy::OnMsgNavigate(PP_Instance instance, | 261 void PPB_Flash_Proxy::OnHostMsgNavigate(PP_Instance instance, |
382 const PPB_URLRequestInfo_Data& data, | 262 const PPB_URLRequestInfo_Data& data, |
383 const std::string& target, | 263 const std::string& target, |
384 PP_Bool from_user_action, | 264 PP_Bool from_user_action, |
385 int32_t* result) { | 265 int32_t* result) { |
386 DCHECK(!dispatcher()->IsPlugin()); | 266 DCHECK(!dispatcher()->IsPlugin()); |
387 | 267 |
388 // Validate the PP_Instance since we'll be constructing resources on its | 268 // Validate the PP_Instance since we'll be constructing resources on its |
389 // behalf. | 269 // behalf. |
390 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); | 270 HostDispatcher* host_dispatcher = static_cast<HostDispatcher*>(dispatcher()); |
391 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { | 271 if (HostDispatcher::GetForInstance(instance) != host_dispatcher) { |
392 NOTREACHED(); | 272 NOTREACHED(); |
393 *result = PP_ERROR_BADARGUMENT; | 273 *result = PP_ERROR_BADARGUMENT; |
394 return; | 274 return; |
395 } | 275 } |
(...skipping 13 matching lines...) Expand all Loading... | |
409 } | 289 } |
410 ScopedPPResource request_resource( | 290 ScopedPPResource request_resource( |
411 ScopedPPResource::PassRef(), | 291 ScopedPPResource::PassRef(), |
412 enter.functions()->CreateURLRequestInfo(instance, data)); | 292 enter.functions()->CreateURLRequestInfo(instance, data)); |
413 | 293 |
414 *result = ppb_flash_impl_->Navigate(request_resource, | 294 *result = ppb_flash_impl_->Navigate(request_resource, |
415 target.c_str(), | 295 target.c_str(), |
416 from_user_action); | 296 from_user_action); |
417 } | 297 } |
418 | 298 |
419 void PPB_Flash_Proxy::OnMsgRunMessageLoop(PP_Instance instance) { | 299 void PPB_Flash_Proxy::OnHostMsgRunMessageLoop(PP_Instance instance) { |
420 ppb_flash_impl_->RunMessageLoop(instance); | 300 ppb_flash_impl_->RunMessageLoop(instance); |
421 } | 301 } |
422 | 302 |
423 void PPB_Flash_Proxy::OnMsgQuitMessageLoop(PP_Instance instance) { | 303 void PPB_Flash_Proxy::OnHostMsgQuitMessageLoop(PP_Instance instance) { |
424 ppb_flash_impl_->QuitMessageLoop(instance); | 304 ppb_flash_impl_->QuitMessageLoop(instance); |
425 } | 305 } |
426 | 306 |
427 void PPB_Flash_Proxy::OnMsgGetLocalTimeZoneOffset(PP_Instance instance, | 307 void PPB_Flash_Proxy::OnHostMsgGetLocalTimeZoneOffset(PP_Instance instance, |
428 PP_Time t, | 308 PP_Time t, |
429 double* result) { | 309 double* result) { |
430 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); | 310 *result = ppb_flash_impl_->GetLocalTimeZoneOffset(instance, t); |
431 } | 311 } |
432 | 312 |
433 void PPB_Flash_Proxy::OnMsgIsRectTopmost(PP_Instance instance, | 313 void PPB_Flash_Proxy::OnHostMsgIsRectTopmost(PP_Instance instance, |
434 PP_Rect rect, | 314 PP_Rect rect, |
435 PP_Bool* result) { | 315 PP_Bool* result) { |
436 *result = ppb_flash_impl_->IsRectTopmost(instance, &rect); | 316 *result = ppb_flash_impl_->IsRectTopmost(instance, &rect); |
437 } | 317 } |
438 | 318 |
319 void PPB_Flash_Proxy::OnHostMsgFlashSetFullscreen(PP_Instance instance, | |
320 PP_Bool fullscreen, | |
321 PP_Bool* result) { | |
322 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( | |
323 instance, false); | |
324 if (enter.failed()) | |
325 return; | |
326 *result = enter.functions()->GetFlashAPI()->FlashSetFullscreen( | |
327 instance, fullscreen); | |
328 } | |
329 | |
330 void PPB_Flash_Proxy::OnHostMsgFlashGetScreenSize(PP_Instance instance, | |
331 PP_Bool* result, | |
332 PP_Size* size) { | |
333 thunk::EnterFunctionNoLock<thunk::PPB_Instance_FunctionAPI> enter( | |
334 instance, false); | |
335 if (enter.failed()) | |
336 return; | |
337 *result = enter.functions()->GetFlashAPI()->FlashGetScreenSize( | |
338 instance, size); | |
339 } | |
340 | |
439 } // namespace proxy | 341 } // namespace proxy |
440 } // namespace ppapi | 342 } // namespace ppapi |
OLD | NEW |