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 "chrome/renderer/pepper/ppb_pdf_impl.h" | 5 #include "chrome/renderer/pepper/ppb_pdf_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/safe_numerics.h" | 9 #include "base/safe_numerics.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "ui/base/layout.h" | 37 #include "ui/base/layout.h" |
38 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
39 | 39 |
40 using ppapi::PpapiGlobals; | 40 using ppapi::PpapiGlobals; |
41 using WebKit::WebElement; | 41 using WebKit::WebElement; |
42 using WebKit::WebView; | 42 using WebKit::WebView; |
43 using content::RenderThread; | 43 using content::RenderThread; |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 47 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ |
| 48 !defined(OS_NACL) |
48 class PrivateFontFile : public ppapi::Resource { | 49 class PrivateFontFile : public ppapi::Resource { |
49 public: | 50 public: |
50 PrivateFontFile(PP_Instance instance, int fd) | 51 PrivateFontFile(PP_Instance instance, int fd) |
51 : Resource(ppapi::OBJECT_IS_IMPL, instance), | 52 : Resource(ppapi::OBJECT_IS_IMPL, instance), |
52 fd_(fd) { | 53 fd_(fd) { |
53 } | 54 } |
54 | 55 |
55 bool GetFontTable(uint32_t table, | 56 bool GetFontTable(uint32_t table, |
56 void* output, | 57 void* output, |
57 uint32_t* output_length) { | 58 uint32_t* output_length) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 NOTREACHED(); | 186 NOTREACHED(); |
186 } | 187 } |
187 | 188 |
188 return ppapi::StringVar::StringToPPVar(rv); | 189 return ppapi::StringVar::StringToPPVar(rv); |
189 } | 190 } |
190 | 191 |
191 PP_Resource GetFontFileWithFallback( | 192 PP_Resource GetFontFileWithFallback( |
192 PP_Instance instance_id, | 193 PP_Instance instance_id, |
193 const PP_BrowserFont_Trusted_Description* description, | 194 const PP_BrowserFont_Trusted_Description* description, |
194 PP_PrivateFontCharset charset) { | 195 PP_PrivateFontCharset charset) { |
195 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 196 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ |
| 197 !defined(OS_NACL) |
196 // Validate the instance before using it below. | 198 // Validate the instance before using it below. |
197 if (!content::PepperPluginInstance::Get(instance_id)) | 199 if (!content::PepperPluginInstance::Get(instance_id)) |
198 return 0; | 200 return 0; |
199 | 201 |
200 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( | 202 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( |
201 description->face)); | 203 description->face)); |
202 if (!face_name.get()) | 204 if (!face_name.get()) |
203 return 0; | 205 return 0; |
204 | 206 |
205 int fd = content::MatchFontWithFallback( | 207 int fd = content::MatchFontWithFallback( |
(...skipping 11 matching lines...) Expand all Loading... |
217 // For trusted PPAPI plugins, this is only needed in Linux since font loading | 219 // For trusted PPAPI plugins, this is only needed in Linux since font loading |
218 // on Windows and Mac works through the renderer sandbox. | 220 // on Windows and Mac works through the renderer sandbox. |
219 return 0; | 221 return 0; |
220 #endif | 222 #endif |
221 } | 223 } |
222 | 224 |
223 bool GetFontTableForPrivateFontFile(PP_Resource font_file, | 225 bool GetFontTableForPrivateFontFile(PP_Resource font_file, |
224 uint32_t table, | 226 uint32_t table, |
225 void* output, | 227 void* output, |
226 uint32_t* output_length) { | 228 uint32_t* output_length) { |
227 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 229 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ |
| 230 !defined(OS_NACL) |
228 ppapi::Resource* resource = | 231 ppapi::Resource* resource = |
229 PpapiGlobals::Get()->GetResourceTracker()->GetResource(font_file); | 232 PpapiGlobals::Get()->GetResourceTracker()->GetResource(font_file); |
230 if (!resource) | 233 if (!resource) |
231 return false; | 234 return false; |
232 | 235 |
233 PrivateFontFile* font = static_cast<PrivateFontFile*>(resource); | 236 PrivateFontFile* font = static_cast<PrivateFontFile*>(resource); |
234 return font->GetFontTable(table, output, output_length); | 237 return font->GetFontTable(table, output, output_length); |
235 #else | 238 #else |
236 return false; | 239 return false; |
237 #endif | 240 #endif |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 | 428 |
426 // static | 429 // static |
427 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 430 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
428 #if defined(ENABLE_PRINTING) | 431 #if defined(ENABLE_PRINTING) |
429 WebKit::WebElement element = GetWebElement(instance_id); | 432 WebKit::WebElement element = GetWebElement(instance_id); |
430 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | 433 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); |
431 if (helper) | 434 if (helper) |
432 helper->PrintNode(element); | 435 helper->PrintNode(element); |
433 #endif // ENABLE_PRINTING | 436 #endif // ENABLE_PRINTING |
434 } | 437 } |
OLD | NEW |