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_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
6 | 6 |
| 7 #include "base/memory/ref_counted.h" |
7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
8 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/c/pp_time.h" | 10 #include "ppapi/c/pp_time.h" |
10 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
11 #include "ppapi/c/ppb_audio_config.h" | 12 #include "ppapi/c/ppb_audio_config.h" |
12 #include "ppapi/c/ppb_instance.h" | 13 #include "ppapi/c/ppb_instance.h" |
13 #include "ppapi/c/ppb_messaging.h" | 14 #include "ppapi/c/ppb_messaging.h" |
14 #include "ppapi/c/ppb_mouse_lock.h" | 15 #include "ppapi/c/ppb_mouse_lock.h" |
15 #include "ppapi/c/private/pp_content_decryptor.h" | 16 #include "ppapi/c/private/pp_content_decryptor.h" |
16 #include "ppapi/proxy/content_decryptor_private_serializer.h" | 17 #include "ppapi/proxy/content_decryptor_private_serializer.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetScreenSize( | 325 dispatcher()->Send(new PpapiHostMsg_PPBInstance_GetScreenSize( |
325 API_ID_PPB_INSTANCE, instance, &result, size)); | 326 API_ID_PPB_INSTANCE, instance, &result, size)); |
326 return result; | 327 return result; |
327 } | 328 } |
328 | 329 |
329 thunk::PPB_Flash_API* PPB_Instance_Proxy::GetFlashAPI() { | 330 thunk::PPB_Flash_API* PPB_Instance_Proxy::GetFlashAPI() { |
330 InterfaceProxy* ip = dispatcher()->GetInterfaceProxy(API_ID_PPB_FLASH); | 331 InterfaceProxy* ip = dispatcher()->GetInterfaceProxy(API_ID_PPB_FLASH); |
331 return static_cast<PPB_Flash_Proxy*>(ip); | 332 return static_cast<PPB_Flash_Proxy*>(ip); |
332 } | 333 } |
333 | 334 |
334 // TODO(raymes): We can most likely cut down this boilerplate for grabbing | 335 Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance, |
335 // singleton resource APIs. | 336 SingletonResourceID id) { |
336 thunk::PPB_Flash_Functions_API* PPB_Instance_Proxy::GetFlashFunctionsAPI( | |
337 PP_Instance instance) { | |
338 #if !defined(OS_NACL) && !defined(NACL_WIN64) | |
339 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 337 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
340 GetInstanceData(instance); | 338 GetInstanceData(instance); |
341 if (!data) | 339 |
| 340 InstanceData::SingletonResourceMap::iterator it = |
| 341 data->singleton_resources.find(id); |
| 342 if (it != data->singleton_resources.end()) |
| 343 return it->second.get(); |
| 344 |
| 345 scoped_refptr<Resource> new_singleton; |
| 346 Connection connection( |
| 347 PluginGlobals::Get()->plugin_proxy_delegate()->GetBrowserSender(), |
| 348 dispatcher()); |
| 349 |
| 350 switch (id) { |
| 351 case GAMEPAD_SINGLETON_ID: |
| 352 new_singleton = new GamepadResource(connection, instance); |
| 353 break; |
| 354 // Flash resources aren't needed for NaCl. |
| 355 #if !defined(OS_NACL) && !defined(NACL_WIN64) |
| 356 case FLASH_SINGLETON_ID: |
| 357 new_singleton = new FlashResource(connection, instance); |
| 358 break; |
| 359 case FLASH_CLIPBOARD_SINGLETON_ID: |
| 360 new_singleton = new FlashClipboardResource(connection, instance); |
| 361 break; |
| 362 #else |
| 363 case FLASH_SINGLETON_ID: |
| 364 case FLASH_CLIPBOARD_SINGLETON_ID: |
| 365 NOTREACHED(); |
| 366 break; |
| 367 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) |
| 368 } |
| 369 |
| 370 if (!new_singleton) { |
| 371 // Getting here implies that a constructor is missing in the above switch. |
| 372 NOTREACHED(); |
342 return NULL; | 373 return NULL; |
| 374 } |
343 | 375 |
344 if (!data->flash_resource.get()) { | 376 data->singleton_resources[id] = new_singleton; |
345 Connection connection( | 377 return new_singleton.get(); |
346 PluginGlobals::Get()->plugin_proxy_delegate()->GetBrowserSender(), | |
347 dispatcher()); | |
348 data->flash_resource = new FlashResource(connection, instance); | |
349 } | |
350 return data->flash_resource.get(); | |
351 #else | |
352 // Flash functions aren't implemented for nacl. | |
353 NOTIMPLEMENTED(); | |
354 return NULL; | |
355 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) | |
356 } | |
357 | |
358 thunk::PPB_Flash_Clipboard_API* PPB_Instance_Proxy::GetFlashClipboardAPI( | |
359 PP_Instance instance) { | |
360 #if !defined(OS_NACL) && !defined(NACL_WIN64) | |
361 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | |
362 GetInstanceData(instance); | |
363 if (!data) | |
364 return NULL; | |
365 | |
366 if (!data->flash_clipboard_resource.get()) { | |
367 Connection connection( | |
368 PluginGlobals::Get()->plugin_proxy_delegate()->GetBrowserSender(), | |
369 dispatcher()); | |
370 data->flash_clipboard_resource = | |
371 new FlashClipboardResource(connection, instance); | |
372 } | |
373 return data->flash_clipboard_resource.get(); | |
374 #else | |
375 // Flash functions aren't implemented for nacl. | |
376 NOTIMPLEMENTED(); | |
377 return NULL; | |
378 #endif // !defined(OS_NACL) && !defined(NACL_WIN64) | |
379 } | |
380 | |
381 thunk::PPB_Gamepad_API* PPB_Instance_Proxy::GetGamepadAPI( | |
382 PP_Instance instance) { | |
383 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | |
384 GetInstanceData(instance); | |
385 if (!data) | |
386 return NULL; | |
387 | |
388 if (!data->gamepad_resource.get()) { | |
389 Connection connection( | |
390 PluginGlobals::Get()->plugin_proxy_delegate()->GetBrowserSender(), | |
391 dispatcher()); | |
392 data->gamepad_resource = new GamepadResource(connection, instance); | |
393 } | |
394 return data->gamepad_resource.get(); | |
395 } | 378 } |
396 | 379 |
397 int32_t PPB_Instance_Proxy::RequestInputEvents(PP_Instance instance, | 380 int32_t PPB_Instance_Proxy::RequestInputEvents(PP_Instance instance, |
398 uint32_t event_classes) { | 381 uint32_t event_classes) { |
399 dispatcher()->Send(new PpapiHostMsg_PPBInstance_RequestInputEvents( | 382 dispatcher()->Send(new PpapiHostMsg_PPBInstance_RequestInputEvents( |
400 API_ID_PPB_INSTANCE, instance, false, event_classes)); | 383 API_ID_PPB_INSTANCE, instance, false, event_classes)); |
401 | 384 |
402 // We always register for the classes we can handle, this function validates | 385 // We always register for the classes we can handle, this function validates |
403 // the flags so we can notify it if anything was invalid, without requiring | 386 // the flags so we can notify it if anything was invalid, without requiring |
404 // a sync reply. | 387 // a sync reply. |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 PP_Instance instance) { | 1175 PP_Instance instance) { |
1193 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 1176 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
1194 GetInstanceData(instance); | 1177 GetInstanceData(instance); |
1195 if (!data) | 1178 if (!data) |
1196 return; // Instance was probably deleted. | 1179 return; // Instance was probably deleted. |
1197 data->should_do_request_surrounding_text = false; | 1180 data->should_do_request_surrounding_text = false; |
1198 } | 1181 } |
1199 | 1182 |
1200 } // namespace proxy | 1183 } // namespace proxy |
1201 } // namespace ppapi | 1184 } // namespace ppapi |
OLD | NEW |