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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 const PPB_PDF pdf_interface = { | 114 const PPB_PDF pdf_interface = { |
115 NULL, // &GetLocalizedString, | 115 NULL, // &GetLocalizedString, |
116 NULL, // &GetResourceImage, | 116 NULL, // &GetResourceImage, |
117 &GetFontFileWithFallback, | 117 &GetFontFileWithFallback, |
118 &GetFontTableForPrivateFontFile, | 118 &GetFontTableForPrivateFontFile, |
119 }; | 119 }; |
120 | 120 |
121 InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher) { | 121 InterfaceProxy* CreatePDFProxy(Dispatcher* dispatcher, |
122 return new PPB_PDF_Proxy(dispatcher); | 122 const void* target_interface) { |
| 123 return new PPB_PDF_Proxy(dispatcher, target_interface); |
123 } | 124 } |
124 | 125 |
125 } // namespace | 126 } // namespace |
126 | 127 |
127 PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher) | 128 PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher, |
128 : InterfaceProxy(dispatcher), | 129 const void* target_interface) |
129 ppb_pdf_impl_(NULL) { | 130 : InterfaceProxy(dispatcher, target_interface) { |
130 if (!dispatcher->IsPlugin()) { | |
131 ppb_pdf_impl_ = static_cast<const PPB_PDF*>( | |
132 dispatcher->local_get_interface()(PPB_PDF_INTERFACE)); | |
133 } | |
134 } | 131 } |
135 | 132 |
136 PPB_PDF_Proxy::~PPB_PDF_Proxy() { | 133 PPB_PDF_Proxy::~PPB_PDF_Proxy() { |
137 } | 134 } |
138 | 135 |
139 // static | 136 // static |
140 const InterfaceProxy::Info* PPB_PDF_Proxy::GetInfo() { | 137 const InterfaceProxy::Info* PPB_PDF_Proxy::GetInfo() { |
141 static const Info info = { | 138 static const Info info = { |
142 &pdf_interface, | 139 &pdf_interface, |
143 PPB_PDF_INTERFACE, | 140 PPB_PDF_INTERFACE, |
(...skipping 18 matching lines...) Expand all Loading... |
162 } | 159 } |
163 | 160 |
164 void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback( | 161 void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback( |
165 PP_Instance instance, | 162 PP_Instance instance, |
166 const SerializedFontDescription& in_desc, | 163 const SerializedFontDescription& in_desc, |
167 int32_t charset, | 164 int32_t charset, |
168 HostResource* result) { | 165 HostResource* result) { |
169 PP_FontDescription_Dev desc; | 166 PP_FontDescription_Dev desc; |
170 in_desc.SetToPPFontDescription(dispatcher(), &desc, false); | 167 in_desc.SetToPPFontDescription(dispatcher(), &desc, false); |
171 result->SetHostResource(instance, | 168 result->SetHostResource(instance, |
172 ppb_pdf_impl_->GetFontFileWithFallback( | 169 ppb_pdf_target()->GetFontFileWithFallback( |
173 instance, &desc, static_cast<PP_PrivateFontCharset>(charset))); | 170 instance, &desc, static_cast<PP_PrivateFontCharset>(charset))); |
174 } | 171 } |
175 | 172 |
176 void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile( | 173 void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile( |
177 const HostResource& font_file, | 174 const HostResource& font_file, |
178 uint32_t table, | 175 uint32_t table, |
179 std::string* result) { | 176 std::string* result) { |
180 // TODO(brettw): It would be nice not to copy here. At least on Linux, | 177 // TODO(brettw): It would be nice not to copy here. At least on Linux, |
181 // we can map the font file into shared memory and read it that way. | 178 // we can map the font file into shared memory and read it that way. |
182 uint32_t table_length = 0; | 179 uint32_t table_length = 0; |
183 if (!ppb_pdf_impl_->GetFontTableForPrivateFontFile( | 180 if (!ppb_pdf_target()->GetFontTableForPrivateFontFile( |
184 font_file.host_resource(), table, NULL, &table_length)) | 181 font_file.host_resource(), table, NULL, &table_length)) |
185 return; | 182 return; |
186 | 183 |
187 result->resize(table_length); | 184 result->resize(table_length); |
188 ppb_pdf_impl_->GetFontTableForPrivateFontFile(font_file.host_resource(), | 185 ppb_pdf_target()->GetFontTableForPrivateFontFile(font_file.host_resource(), |
189 table, const_cast<char*>(result->c_str()), &table_length); | 186 table, const_cast<char*>(result->c_str()), &table_length); |
190 } | 187 } |
191 | 188 |
192 } // namespace proxy | 189 } // namespace proxy |
193 } // namespace ppapi | 190 } // namespace ppapi |
OLD | NEW |