| 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_pdf_proxy.h" | 5 #include "ppapi/proxy/ppb_pdf_proxy.h" |
| 6 | 6 |
| 7 #include <string.h> // For memcpy. | 7 #include <string.h> // For memcpy. |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return false; | 100 return false; |
| 101 contents = object->AddFontTable(table, deserialized); | 101 contents = object->AddFontTable(table, deserialized); |
| 102 } | 102 } |
| 103 | 103 |
| 104 *output_length = static_cast<uint32_t>(contents->size()); | 104 *output_length = static_cast<uint32_t>(contents->size()); |
| 105 if (output) | 105 if (output) |
| 106 memcpy(output, contents->c_str(), *output_length); | 106 memcpy(output, contents->c_str(), *output_length); |
| 107 return true; | 107 return true; |
| 108 } | 108 } |
| 109 | 109 |
| 110 const PPB_PDF ppb_pdf = { | 110 const PPB_PDF pdf_interface = { |
| 111 NULL, // &GetLocalizedString, | 111 NULL, // &GetLocalizedString, |
| 112 NULL, // &GetResourceImage, | 112 NULL, // &GetResourceImage, |
| 113 &GetFontFileWithFallback, | 113 &GetFontFileWithFallback, |
| 114 &GetFontTableForPrivateFontFile, | 114 &GetFontTableForPrivateFontFile, |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher, |
| 118 const void* target_interface) { |
| 119 return new PPB_PDF_Proxy(dispatcher, target_interface); |
| 120 } |
| 121 |
| 117 } // namespace | 122 } // namespace |
| 118 | 123 |
| 119 PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher, | 124 PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher, |
| 120 const void* target_interface) | 125 const void* target_interface) |
| 121 : InterfaceProxy(dispatcher, target_interface) { | 126 : InterfaceProxy(dispatcher, target_interface) { |
| 122 } | 127 } |
| 123 | 128 |
| 124 PPB_PDF_Proxy::~PPB_PDF_Proxy() { | 129 PPB_PDF_Proxy::~PPB_PDF_Proxy() { |
| 125 } | 130 } |
| 126 | 131 |
| 127 const void* PPB_PDF_Proxy::GetSourceInterface() const { | 132 // static |
| 128 return &ppb_pdf; | 133 const InterfaceProxy::Info* PPB_PDF_Proxy::GetInfo() { |
| 129 } | 134 static const Info info = { |
| 130 | 135 &pdf_interface, |
| 131 InterfaceID PPB_PDF_Proxy::GetInterfaceId() const { | 136 PPB_PDF_INTERFACE, |
| 132 return INTERFACE_ID_PPB_PDF; | 137 INTERFACE_ID_PPB_PDF, |
| 138 true, |
| 139 &CreatePDFProxy, |
| 140 }; |
| 141 return &info; |
| 133 } | 142 } |
| 134 | 143 |
| 135 bool PPB_PDF_Proxy::OnMessageReceived(const IPC::Message& msg) { | 144 bool PPB_PDF_Proxy::OnMessageReceived(const IPC::Message& msg) { |
| 136 bool handled = true; | 145 bool handled = true; |
| 137 IPC_BEGIN_MESSAGE_MAP(PPB_PDF_Proxy, msg) | 146 IPC_BEGIN_MESSAGE_MAP(PPB_PDF_Proxy, msg) |
| 138 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPDF_GetFontFileWithFallback, | 147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPDF_GetFontFileWithFallback, |
| 139 OnMsgGetFontFileWithFallback) | 148 OnMsgGetFontFileWithFallback) |
| 140 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile, | 149 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile, |
| 141 OnMsgGetFontTableForPrivateFontFile) | 150 OnMsgGetFontTableForPrivateFontFile) |
| 142 IPC_MESSAGE_UNHANDLED(handled = false) | 151 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 168 font_file.host_resource(), table, NULL, &table_length)) | 177 font_file.host_resource(), table, NULL, &table_length)) |
| 169 return; | 178 return; |
| 170 | 179 |
| 171 result->resize(table_length); | 180 result->resize(table_length); |
| 172 ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), | 181 ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), |
| 173 table, const_cast<char*>(result->c_str()), &table_length); | 182 table, const_cast<char*>(result->c_str()), &table_length); |
| 174 } | 183 } |
| 175 | 184 |
| 176 } // namespace proxy | 185 } // namespace proxy |
| 177 } // namespace pp | 186 } // namespace pp |
| OLD | NEW |