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/numerics/safe_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/render_messages.h" | 13 #include "chrome/common/render_messages.h" |
14 #include "chrome/renderer/printing/print_web_view_helper.h" | 14 #include "chrome/renderer/printing/print_web_view_helper.h" |
15 #include "content/public/common/child_process_sandbox_support_linux.h" | 15 #include "content/public/common/child_process_sandbox_support_linux.h" |
16 #include "content/public/common/referrer.h" | 16 #include "content/public/common/referrer.h" |
17 #include "content/public/renderer/pepper_plugin_instance.h" | 17 #include "content/public/renderer/pepper_plugin_instance.h" |
18 #include "content/public/renderer/render_thread.h" | 18 #include "content/public/renderer/render_thread.h" |
19 #include "content/public/renderer/render_view.h" | 19 #include "content/public/renderer/render_view.h" |
20 #include "grit/webkit_resources.h" | 20 #include "grit/webkit_resources.h" |
21 #include "grit/webkit_strings.h" | 21 #include "grit/webkit_strings.h" |
22 #include "ppapi/c/pp_resource.h" | 22 #include "ppapi/c/pp_resource.h" |
23 #include "ppapi/c/private/ppb_pdf.h" | 23 #include "ppapi/c/private/ppb_pdf.h" |
24 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" | 24 #include "ppapi/c/trusted/ppb_browser_font_trusted.h" |
25 #include "ppapi/shared_impl/ppapi_globals.h" | 25 #include "ppapi/shared_impl/ppapi_globals.h" |
26 #include "ppapi/shared_impl/resource.h" | 26 #include "ppapi/shared_impl/resource.h" |
27 #include "ppapi/shared_impl/resource_tracker.h" | 27 #include "ppapi/shared_impl/resource_tracker.h" |
28 #include "ppapi/shared_impl/var.h" | 28 #include "ppapi/shared_impl/var.h" |
29 #include "third_party/skia/include/core/SkBitmap.h" | |
30 #include "third_party/WebKit/public/web/WebDocument.h" | 29 #include "third_party/WebKit/public/web/WebDocument.h" |
31 #include "third_party/WebKit/public/web/WebElement.h" | 30 #include "third_party/WebKit/public/web/WebElement.h" |
32 #include "third_party/WebKit/public/web/WebFrame.h" | 31 #include "third_party/WebKit/public/web/WebFrame.h" |
33 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 32 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
34 #include "third_party/WebKit/public/web/WebView.h" | 33 #include "third_party/WebKit/public/web/WebView.h" |
35 #include "third_party/icu/source/i18n/unicode/usearch.h" | 34 #include "third_party/icu/source/i18n/unicode/usearch.h" |
| 35 #include "third_party/skia/include/core/SkBitmap.h" |
36 #include "ui/base/l10n/l10n_util.h" | 36 #include "ui/base/l10n/l10n_util.h" |
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 blink::WebElement; | 41 using blink::WebElement; |
42 using blink::WebView; | 42 using blink::WebView; |
43 using content::RenderThread; | 43 using content::RenderThread; |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 47 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
48 class PrivateFontFile : public ppapi::Resource { | 48 class PrivateFontFile : public ppapi::Resource { |
49 public: | 49 public: |
50 PrivateFontFile(PP_Instance instance, int fd) | 50 PrivateFontFile(PP_Instance instance, int fd) |
51 : Resource(ppapi::OBJECT_IS_IMPL, instance), | 51 : Resource(ppapi::OBJECT_IS_IMPL, instance), |
52 fd_(fd) { | 52 fd_(fd) { |
53 } | 53 } |
54 | 54 |
55 bool GetFontTable(uint32_t table, | 55 bool GetFontTable(uint32_t table, |
56 void* output, | 56 void* output, |
57 uint32_t* output_length) { | 57 uint32_t* output_length) { |
58 size_t temp_size = static_cast<size_t>(*output_length); | 58 size_t temp_size = static_cast<size_t>(*output_length); |
59 bool rv = content::GetFontTable( | 59 bool rv = content::GetFontTable( |
60 fd_, table, 0 /* offset */, static_cast<uint8_t*>(output), &temp_size); | 60 fd_, table, 0 /* offset */, static_cast<uint8_t*>(output), &temp_size); |
61 *output_length = base::checked_numeric_cast<uint32_t>(temp_size); | 61 *output_length = base::checked_cast<uint32_t>(temp_size); |
62 return rv; | 62 return rv; |
63 } | 63 } |
64 | 64 |
65 protected: | 65 protected: |
66 virtual ~PrivateFontFile() {} | 66 virtual ~PrivateFontFile() {} |
67 | 67 |
68 private: | 68 private: |
69 int fd_; | 69 int fd_; |
70 }; | 70 }; |
71 #endif | 71 #endif |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 460 |
461 // static | 461 // static |
462 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 462 void PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
463 #if defined(ENABLE_FULL_PRINTING) | 463 #if defined(ENABLE_FULL_PRINTING) |
464 blink::WebElement element = GetWebElement(instance_id); | 464 blink::WebElement element = GetWebElement(instance_id); |
465 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); | 465 printing::PrintWebViewHelper* helper = GetPrintWebViewHelper(element); |
466 if (helper) | 466 if (helper) |
467 helper->PrintNode(element); | 467 helper->PrintNode(element); |
468 #endif // ENABLE_FULL_PRINTING | 468 #endif // ENABLE_FULL_PRINTING |
469 } | 469 } |
OLD | NEW |