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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ppapi/c/dev/ppb_font_dev.h" | 13 #include "ppapi/c/dev/ppb_font_dev.h" |
14 #include "ppapi/c/dev/ppb_var_deprecated.h" | 14 #include "ppapi/c/dev/ppb_var_deprecated.h" |
15 #include "ppapi/c/pp_errors.h" | 15 #include "ppapi/c/pp_errors.h" |
16 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
17 #include "ppapi/c/private/ppb_flash.h" | 17 #include "ppapi/c/private/ppb_flash.h" |
| 18 #include "ppapi/c/private/ppb_flash_font.h" |
18 #include "ppapi/c/private/ppb_flash_print.h" | 19 #include "ppapi/c/private/ppb_flash_print.h" |
| 20 #include "ppapi/c/private/ppb_pdf.h" |
19 #include "ppapi/proxy/host_dispatcher.h" | 21 #include "ppapi/proxy/host_dispatcher.h" |
20 #include "ppapi/proxy/pepper_file_messages.h" | 22 #include "ppapi/proxy/pepper_file_messages.h" |
21 #include "ppapi/proxy/plugin_dispatcher.h" | 23 #include "ppapi/proxy/plugin_dispatcher.h" |
22 #include "ppapi/proxy/plugin_globals.h" | 24 #include "ppapi/proxy/plugin_globals.h" |
23 #include "ppapi/proxy/plugin_proxy_delegate.h" | 25 #include "ppapi/proxy/plugin_proxy_delegate.h" |
24 #include "ppapi/proxy/ppapi_messages.h" | 26 #include "ppapi/proxy/ppapi_messages.h" |
25 #include "ppapi/proxy/proxy_module.h" | 27 #include "ppapi/proxy/proxy_module.h" |
26 #include "ppapi/proxy/serialized_var.h" | 28 #include "ppapi/proxy/serialized_var.h" |
27 #include "ppapi/shared_impl/dir_contents.h" | 29 #include "ppapi/shared_impl/dir_contents.h" |
28 #include "ppapi/shared_impl/file_type_conversion.h" | 30 #include "ppapi/shared_impl/file_type_conversion.h" |
29 #include "ppapi/shared_impl/ppapi_globals.h" | 31 #include "ppapi/shared_impl/ppapi_globals.h" |
30 #include "ppapi/shared_impl/proxy_lock.h" | 32 #include "ppapi/shared_impl/proxy_lock.h" |
31 #include "ppapi/shared_impl/resource.h" | 33 #include "ppapi/shared_impl/resource.h" |
32 #include "ppapi/shared_impl/resource_tracker.h" | 34 #include "ppapi/shared_impl/resource_tracker.h" |
33 #include "ppapi/shared_impl/scoped_pp_resource.h" | 35 #include "ppapi/shared_impl/scoped_pp_resource.h" |
34 #include "ppapi/shared_impl/time_conversion.h" | 36 #include "ppapi/shared_impl/time_conversion.h" |
35 #include "ppapi/shared_impl/var.h" | 37 #include "ppapi/shared_impl/var.h" |
36 #include "ppapi/thunk/enter.h" | 38 #include "ppapi/thunk/enter.h" |
37 #include "ppapi/thunk/ppb_instance_api.h" | 39 #include "ppapi/thunk/ppb_instance_api.h" |
38 #include "ppapi/thunk/ppb_url_request_info_api.h" | 40 #include "ppapi/thunk/ppb_url_request_info_api.h" |
39 #include "ppapi/thunk/resource_creation_api.h" | 41 #include "ppapi/thunk/resource_creation_api.h" |
40 | 42 |
41 using ppapi::thunk::EnterInstanceNoLock; | 43 using ppapi::thunk::EnterInstanceNoLock; |
| 44 using ppapi::thunk::EnterResource; |
42 using ppapi::thunk::EnterResourceNoLock; | 45 using ppapi::thunk::EnterResourceNoLock; |
43 | 46 |
44 namespace ppapi { | 47 namespace ppapi { |
45 namespace proxy { | 48 namespace proxy { |
46 | 49 |
47 namespace { | 50 namespace { |
48 | 51 |
49 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( | 52 IPC::PlatformFileForTransit PlatformFileToPlatformFileForTransit( |
50 Dispatcher* dispatcher, | 53 Dispatcher* dispatcher, |
51 int32_t* error, | 54 int32_t* error, |
52 base::PlatformFile file) { | 55 base::PlatformFile file) { |
53 if (*error != PP_OK) | 56 if (*error != PP_OK) |
54 return IPC::InvalidPlatformFileForTransit(); | 57 return IPC::InvalidPlatformFileForTransit(); |
55 IPC::PlatformFileForTransit out_handle = | 58 IPC::PlatformFileForTransit out_handle = |
56 dispatcher->ShareHandleWithRemote(file, true); | 59 dispatcher->ShareHandleWithRemote(file, true); |
57 if (out_handle == IPC::InvalidPlatformFileForTransit()) | 60 if (out_handle == IPC::InvalidPlatformFileForTransit()) |
58 *error = PP_ERROR_NOACCESS; | 61 *error = PP_ERROR_NOACCESS; |
59 return out_handle; | 62 return out_handle; |
60 } | 63 } |
61 | 64 |
| 65 PP_Resource GetFontFileWithFallback( |
| 66 PP_Instance instance, |
| 67 const PP_FontDescription_Dev* description, |
| 68 PP_PrivateFontCharset charset) { |
| 69 ProxyAutoLock lock; |
| 70 |
| 71 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 72 if (!dispatcher) |
| 73 return 0; |
| 74 |
| 75 const PPB_PDF* ppb_pdf = static_cast<const PPB_PDF*>( |
| 76 dispatcher->GetBrowserInterface(PPB_PDF_INTERFACE)); |
| 77 return CallWhileUnlocked(ppb_pdf->GetFontFileWithFallback, instance, |
| 78 description, charset); |
| 79 } |
| 80 |
| 81 PP_Bool GetFontTableForPrivateFontFile(PP_Resource font_file, |
| 82 uint32_t table, |
| 83 void* output, |
| 84 uint32_t* output_length) { |
| 85 EnterResource<ppapi::thunk::PPB_PDFFont_API> enter(font_file, true); |
| 86 if (enter.failed()) |
| 87 return PP_FALSE; |
| 88 |
| 89 PluginDispatcher* dispatcher = PluginDispatcher::GetForResource( |
| 90 enter.resource()); |
| 91 if (!dispatcher) |
| 92 return PP_FALSE; |
| 93 |
| 94 const PPB_PDF* ppb_pdf = static_cast<const PPB_PDF*>( |
| 95 dispatcher->GetBrowserInterface(PPB_PDF_INTERFACE)); |
| 96 return PP_FromBool(CallWhileUnlocked( |
| 97 ppb_pdf->GetFontTableForPrivateFontFile, font_file, table, output, |
| 98 output_length)); |
| 99 } |
| 100 |
62 void InvokePrinting(PP_Instance instance) { | 101 void InvokePrinting(PP_Instance instance) { |
| 102 ProxyAutoLock lock; |
| 103 |
63 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 104 PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
64 if (dispatcher) { | 105 if (dispatcher) { |
65 dispatcher->Send(new PpapiHostMsg_PPBFlash_InvokePrinting( | 106 dispatcher->Send(new PpapiHostMsg_PPBFlash_InvokePrinting( |
66 API_ID_PPB_FLASH, instance)); | 107 API_ID_PPB_FLASH, instance)); |
67 } | 108 } |
68 } | 109 } |
69 | 110 |
| 111 const PPB_Flash_Font_0_1 g_flash_font_interface = { |
| 112 &GetFontFileWithFallback, |
| 113 &GetFontTableForPrivateFontFile |
| 114 }; |
| 115 |
70 const PPB_Flash_Print_1_0 g_flash_print_interface = { | 116 const PPB_Flash_Print_1_0 g_flash_print_interface = { |
71 &InvokePrinting | 117 &InvokePrinting |
72 }; | 118 }; |
73 | 119 |
74 } // namespace | 120 } // namespace |
75 | 121 |
76 // ----------------------------------------------------------------------------- | 122 // ----------------------------------------------------------------------------- |
77 | 123 |
78 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) | 124 PPB_Flash_Proxy::PPB_Flash_Proxy(Dispatcher* dispatcher) |
79 : InterfaceProxy(dispatcher) { | 125 : InterfaceProxy(dispatcher) { |
80 } | 126 } |
81 | 127 |
82 PPB_Flash_Proxy::~PPB_Flash_Proxy() { | 128 PPB_Flash_Proxy::~PPB_Flash_Proxy() { |
83 } | 129 } |
84 | 130 |
85 // static | 131 // static |
| 132 const PPB_Flash_Font_0_1* PPB_Flash_Proxy::GetFlashFontInterface() { |
| 133 return &g_flash_font_interface; |
| 134 } |
| 135 |
| 136 // static |
86 const PPB_Flash_Print_1_0* PPB_Flash_Proxy::GetFlashPrintInterface() { | 137 const PPB_Flash_Print_1_0* PPB_Flash_Proxy::GetFlashPrintInterface() { |
87 return &g_flash_print_interface; | 138 return &g_flash_print_interface; |
88 } | 139 } |
89 | 140 |
90 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { | 141 bool PPB_Flash_Proxy::OnMessageReceived(const IPC::Message& msg) { |
91 // Prevent the dispatcher from going away during a call to Navigate. | 142 // Prevent the dispatcher from going away during a call to Navigate. |
92 // This must happen OUTSIDE of OnMsgNavigate since the handling code use | 143 // This must happen OUTSIDE of OnMsgNavigate since the handling code use |
93 // the dispatcher upon return of the function (sending the reply message). | 144 // the dispatcher upon return of the function (sending the reply message). |
94 ScopedModuleReference death_grip(dispatcher()); | 145 ScopedModuleReference death_grip(dispatcher()); |
95 | 146 |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 // It's rarely used enough that we just request this interface when needed. | 932 // It's rarely used enough that we just request this interface when needed. |
882 const PPB_Flash_Print_1_0* print_interface = | 933 const PPB_Flash_Print_1_0* print_interface = |
883 static_cast<const PPB_Flash_Print_1_0*>( | 934 static_cast<const PPB_Flash_Print_1_0*>( |
884 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); | 935 dispatcher()->local_get_interface()(PPB_FLASH_PRINT_INTERFACE_1_0)); |
885 if (print_interface) | 936 if (print_interface) |
886 print_interface->InvokePrinting(instance); | 937 print_interface->InvokePrinting(instance); |
887 } | 938 } |
888 | 939 |
889 } // namespace proxy | 940 } // namespace proxy |
890 } // namespace ppapi | 941 } // namespace ppapi |
OLD | NEW |