| 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 "components/pdf/renderer/ppb_pdf_impl.h" | 5 #include "components/pdf/renderer/ppb_pdf_impl.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_file.h" | 7 #include "base/files/scoped_file.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 PP_Instance instance_id, | 75 PP_Instance instance_id, |
| 76 const PP_BrowserFont_Trusted_Description* description, | 76 const PP_BrowserFont_Trusted_Description* description, |
| 77 PP_PrivateFontCharset charset) { | 77 PP_PrivateFontCharset charset) { |
| 78 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 78 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 79 // Validate the instance before using it below. | 79 // Validate the instance before using it below. |
| 80 if (!content::PepperPluginInstance::Get(instance_id)) | 80 if (!content::PepperPluginInstance::Get(instance_id)) |
| 81 return 0; | 81 return 0; |
| 82 | 82 |
| 83 scoped_refptr<ppapi::StringVar> face_name( | 83 scoped_refptr<ppapi::StringVar> face_name( |
| 84 ppapi::StringVar::FromPPVar(description->face)); | 84 ppapi::StringVar::FromPPVar(description->face)); |
| 85 if (!face_name) | 85 if (!face_name.get()) |
| 86 return 0; | 86 return 0; |
| 87 | 87 |
| 88 int fd = content::MatchFontWithFallback( | 88 int fd = content::MatchFontWithFallback( |
| 89 face_name->value().c_str(), | 89 face_name->value().c_str(), |
| 90 description->weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD, | 90 description->weight >= PP_BROWSERFONT_TRUSTED_WEIGHT_BOLD, |
| 91 description->italic, | 91 description->italic, |
| 92 charset, | 92 charset, |
| 93 description->family); | 93 description->family); |
| 94 if (fd == -1) | 94 if (fd == -1) |
| 95 return 0; | 95 return 0; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 instance->GetRenderView()->GetRoutingID(), restrictions)); | 202 instance->GetRenderView()->GetRoutingID(), restrictions)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void HistogramPDFPageCount(PP_Instance instance, int count) { | 205 void HistogramPDFPageCount(PP_Instance instance, int count) { |
| 206 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); | 206 UMA_HISTOGRAM_COUNTS_10000("PDF.PageCount", count); |
| 207 } | 207 } |
| 208 | 208 |
| 209 void UserMetricsRecordAction(PP_Instance instance, PP_Var action) { | 209 void UserMetricsRecordAction(PP_Instance instance, PP_Var action) { |
| 210 scoped_refptr<ppapi::StringVar> action_str( | 210 scoped_refptr<ppapi::StringVar> action_str( |
| 211 ppapi::StringVar::FromPPVar(action)); | 211 ppapi::StringVar::FromPPVar(action)); |
| 212 if (action_str) | 212 if (action_str.get()) |
| 213 content::RenderThread::Get()->RecordComputedAction(action_str->value()); | 213 content::RenderThread::Get()->RecordComputedAction(action_str->value()); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void HasUnsupportedFeature(PP_Instance instance_id) { | 216 void HasUnsupportedFeature(PP_Instance instance_id) { |
| 217 content::PepperPluginInstance* instance = | 217 content::PepperPluginInstance* instance = |
| 218 content::PepperPluginInstance::Get(instance_id); | 218 content::PepperPluginInstance::Get(instance_id); |
| 219 if (!instance) | 219 if (!instance) |
| 220 return; | 220 return; |
| 221 | 221 |
| 222 // Only want to show an info bar if the pdf is the whole tab. | 222 // Only want to show an info bar if the pdf is the whole tab. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 bool PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { | 353 bool PPB_PDF_Impl::InvokePrintingForInstance(PP_Instance instance_id) { |
| 354 return g_print_client ? g_print_client->Print(instance_id) : false; | 354 return g_print_client ? g_print_client->Print(instance_id) : false; |
| 355 } | 355 } |
| 356 | 356 |
| 357 void PPB_PDF_Impl::SetPrintClient(PPB_PDF_Impl::PrintClient* client) { | 357 void PPB_PDF_Impl::SetPrintClient(PPB_PDF_Impl::PrintClient* client) { |
| 358 CHECK(!g_print_client) << "There should only be a single PrintClient."; | 358 CHECK(!g_print_client) << "There should only be a single PrintClient."; |
| 359 g_print_client = client; | 359 g_print_client = client; |
| 360 } | 360 } |
| 361 | 361 |
| 362 } // namespace pdf | 362 } // namespace pdf |
| OLD | NEW |