diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index ca2cf3efc70bf..9554be02a95c0 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -1497,6 +1497,10 @@ void OutOfProcessInstance::DocumentLoadComplete( pp::PDF::SetContentRestriction(this, content_restrictions); HistogramCustomCounts("PDF.PageCount", document_features.page_count, 1, 1000000, 50); + HistogramEnumeration("PDF.HasAttachment", + document_features.has_attachments ? 1 : 0, 2); + HistogramEnumeration("PDF.IsLinearized", + document_features.is_linearized ? 1 : 0, 2); } void OutOfProcessInstance::RotateClockwise() { diff --git a/pdf/pdf_engine.h b/pdf/pdf_engine.h index 01341761ce41a..eb296670a7c03 100644 --- a/pdf/pdf_engine.h +++ b/pdf/pdf_engine.h @@ -61,6 +61,12 @@ class PDFEngine { struct DocumentFeatures { // Number of pages in document. size_t page_count = 0; + // Whether any files are attached to document (see "File Attachment + // Annotations" on page 637 of PDF Reference 1.7). + bool has_attachments = false; + // Whether the document is linearized (see Appendix F "Linearized PDF" of + // PDF Reference 1.7). + bool is_linearized = false; }; // The interface that's provided to the rendering engine. diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index 8a56dcdd71d9e..fefa26ebf2add 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -51,6 +51,7 @@ #include "printing/pdf_transform.h" #include "printing/units.h" #include "third_party/pdfium/public/fpdf_annot.h" +#include "third_party/pdfium/public/fpdf_attachment.h" #include "third_party/pdfium/public/fpdf_edit.h" #include "third_party/pdfium/public/fpdf_ext.h" #include "third_party/pdfium/public/fpdf_flatten.h" @@ -1281,6 +1282,9 @@ void PDFiumEngine::FinishLoadingDocument() { if (doc_) { DocumentFeatures document_features; document_features.page_count = pages_.size(); + document_features.has_attachments = (FPDFDoc_GetAttachmentCount(doc_) > 0); + document_features.is_linearized = + (FPDFAvail_IsLinearized(fpdf_availability_) == PDF_LINEARIZED); client_->DocumentLoadComplete(document_features); } } diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index e08b7491033b2..c6fe49d8f8637 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -58168,11 +58168,27 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. </summary> </histogram> +<histogram name="PDF.HasAttachment" enum="Boolean"> + <owner>hnakashima@chromium.org</owner> + <summary> + Measures if PDFs opened in the PDF viewer have attachments. This is logged + whenever a document is opened in the PDF viewer. + </summary> +</histogram> + <histogram name="PDF.IsFontSubstituted" enum="Boolean"> <owner>npm@chromium.org</owner> <summary> - Tracks documents opened in the PDF viewer where substitute fonts need to be - used. + Measures if PDFs opened in the PDF viewer require fonts to be substituted. + This is logged whenever a document is opened in the PDF viewer. + </summary> +</histogram> + +<histogram name="PDF.IsLinearized" enum="Boolean"> + <owner>hnakashima@chromium.org</owner> + <summary> + Measures if PDFs opened in the PDF viewer are Linearized PDFs. This is + logged whenever a document is opened in the PDF viewer. </summary> </histogram>