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 "chrome/renderer/chrome_ppb_pdf_impl.h" | 5 #include "chrome/renderer/chrome_ppb_pdf_impl.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
| 11 #include "content/common/child_process_sandbox_support_linux.h" |
11 #include "content/renderer/pepper_plugin_delegate_impl.h" | 12 #include "content/renderer/pepper_plugin_delegate_impl.h" |
12 #include "content/renderer/render_thread.h" | 13 #include "content/renderer/render_thread.h" |
13 #include "grit/webkit_resources.h" | 14 #include "grit/webkit_resources.h" |
14 #include "grit/webkit_strings.h" | 15 #include "grit/webkit_strings.h" |
15 #include "ppapi/c/pp_resource.h" | 16 #include "ppapi/c/pp_resource.h" |
16 #include "ppapi/c/private/ppb_pdf.h" | 17 #include "ppapi/c/private/ppb_pdf.h" |
17 #include "ppapi/shared_impl/resource.h" | 18 #include "ppapi/shared_impl/resource.h" |
18 #include "ppapi/shared_impl/resource_tracker.h" | 19 #include "ppapi/shared_impl/resource_tracker.h" |
19 #include "ppapi/shared_impl/tracker_base.h" | 20 #include "ppapi/shared_impl/tracker_base.h" |
20 #include "ppapi/shared_impl/var.h" | 21 #include "ppapi/shared_impl/var.h" |
21 #include "skia/ext/platform_canvas.h" | 22 #include "skia/ext/platform_canvas.h" |
22 #include "third_party/skia/include/core/SkBitmap.h" | 23 #include "third_party/skia/include/core/SkBitmap.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "unicode/usearch.h" | 26 #include "unicode/usearch.h" |
26 #include "webkit/glue/webkit_glue.h" | |
27 #include "webkit/plugins/ppapi/plugin_delegate.h" | 27 #include "webkit/plugins/ppapi/plugin_delegate.h" |
28 #include "webkit/plugins/ppapi/plugin_module.h" | 28 #include "webkit/plugins/ppapi/plugin_module.h" |
29 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 29 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
30 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" | 30 #include "webkit/plugins/ppapi/ppb_image_data_impl.h" |
31 #include "webkit/plugins/ppapi/resource_tracker.h" | 31 #include "webkit/plugins/ppapi/resource_tracker.h" |
32 | 32 |
33 namespace chrome { | 33 namespace chrome { |
34 | 34 |
35 #if defined(OS_LINUX) | 35 #if defined(OS_LINUX) |
36 class PrivateFontFile : public ppapi::Resource { | 36 class PrivateFontFile : public ppapi::Resource { |
37 public: | 37 public: |
38 PrivateFontFile(PP_Instance instance, int fd) : Resource(instance), fd_(fd) { | 38 PrivateFontFile(PP_Instance instance, int fd) : Resource(instance), fd_(fd) { |
39 } | 39 } |
40 virtual ~PrivateFontFile() { | 40 virtual ~PrivateFontFile() { |
41 } | 41 } |
42 | 42 |
43 bool GetFontTable(uint32_t table, | 43 bool GetFontTable(uint32_t table, |
44 void* output, | 44 void* output, |
45 uint32_t* output_length) { | 45 uint32_t* output_length) { |
46 size_t temp_size = static_cast<size_t>(*output_length); | 46 size_t temp_size = static_cast<size_t>(*output_length); |
47 bool rv = webkit_glue::GetFontTable( | 47 bool rv = child_process_sandbox_support::GetFontTable( |
48 fd_, table, static_cast<uint8_t*>(output), &temp_size); | 48 fd_, table, static_cast<uint8_t*>(output), &temp_size); |
49 *output_length = static_cast<uint32_t>(temp_size); | 49 *output_length = static_cast<uint32_t>(temp_size); |
50 return rv; | 50 return rv; |
51 } | 51 } |
52 | 52 |
53 private: | 53 private: |
54 int fd_; | 54 int fd_; |
55 }; | 55 }; |
56 #endif | 56 #endif |
57 | 57 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 #if defined(OS_LINUX) | 180 #if defined(OS_LINUX) |
181 // Validate the instance before using it below. | 181 // Validate the instance before using it below. |
182 if (!webkit::ppapi::ResourceTracker::Get()->GetInstance(instance_id)) | 182 if (!webkit::ppapi::ResourceTracker::Get()->GetInstance(instance_id)) |
183 return 0; | 183 return 0; |
184 | 184 |
185 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( | 185 scoped_refptr<ppapi::StringVar> face_name(ppapi::StringVar::FromPPVar( |
186 description->face)); | 186 description->face)); |
187 if (!face_name) | 187 if (!face_name) |
188 return 0; | 188 return 0; |
189 | 189 |
190 int fd = webkit_glue::MatchFontWithFallback( | 190 int fd = child_process_sandbox_support::MatchFontWithFallback( |
191 face_name->value().c_str(), | 191 face_name->value().c_str(), |
192 description->weight >= PP_FONTWEIGHT_BOLD, | 192 description->weight >= PP_FONTWEIGHT_BOLD, |
193 description->italic, | 193 description->italic, |
194 charset); | 194 charset); |
195 if (fd == -1) | 195 if (fd == -1) |
196 return 0; | 196 return 0; |
197 | 197 |
198 scoped_refptr<PrivateFontFile> font(new PrivateFontFile(instance_id, fd)); | 198 scoped_refptr<PrivateFontFile> font(new PrivateFontFile(instance_id, fd)); |
199 | 199 |
200 return font->GetReference(); | 200 return font->GetReference(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 &SaveAs | 349 &SaveAs |
350 }; | 350 }; |
351 | 351 |
352 // static | 352 // static |
353 const PPB_PDF* PPB_PDF_Impl::GetInterface() { | 353 const PPB_PDF* PPB_PDF_Impl::GetInterface() { |
354 return &ppb_pdf; | 354 return &ppb_pdf; |
355 } | 355 } |
356 | 356 |
357 } // namespace chrome | 357 } // namespace chrome |
358 | 358 |
OLD | NEW |