diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index 8e36eaf4968ab1..08b96a3a6a5057 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -1506,6 +1506,9 @@ void OutOfProcessInstance::DocumentLoadComplete( HistogramEnumeration("PDF.IsLinearized", document_features.is_linearized ? 1 : 0, 2); HistogramEnumeration("PDF.IsTagged", document_features.is_tagged ? 1 : 0, 2); + HistogramEnumeration("PDF.FormType", + static_cast(document_features.form_type), + static_cast(PDFEngine::FormType::kCount)); } void OutOfProcessInstance::RotateClockwise() { diff --git a/pdf/pdf_engine.h b/pdf/pdf_engine.h index 87147187da765c..dfb6323e9afa1d 100644 --- a/pdf/pdf_engine.h +++ b/pdf/pdf_engine.h @@ -58,6 +58,16 @@ class PDFEngine { PERMISSION_PRINT_HIGH_QUALITY, }; + // Values other then |kCount| are persisted to logs as part of metric + // collection, so should not be changed. + enum class FormType { + kNone = 0, + kAcroForm = 1, + kXFAFull = 2, + kXFAForeground = 3, + kCount = 4, + }; + struct DocumentFeatures { // Number of pages in document. size_t page_count = 0; @@ -69,6 +79,8 @@ class PDFEngine { bool is_linearized = false; // Whether the PDF is Tagged (see 10.7 "Tagged PDF" in PDF Reference 1.7). bool is_tagged = false; + // What type of form the document contains. + FormType form_type = FormType::kNone; }; // The interface that's provided to the rendering engine. diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc index d3032e9737ee55..2f53acb9ddaf77 100644 --- a/pdf/pdfium/pdfium_engine.cc +++ b/pdf/pdfium/pdfium_engine.cc @@ -74,6 +74,20 @@ using printing::kPixelsPerInch; namespace chrome_pdf { +static_assert(static_cast(PDFEngine::FormType::kNone) == FORMTYPE_NONE, + "None form types must match"); +static_assert(static_cast(PDFEngine::FormType::kAcroForm) == + FORMTYPE_ACRO_FORM, + "AcroForm form types must match"); +static_assert(static_cast(PDFEngine::FormType::kXFAFull) == + FORMTYPE_XFA_FULL, + "XFA full form types must match"); +static_assert(static_cast(PDFEngine::FormType::kXFAForeground) == + FORMTYPE_XFA_FOREGROUND, + "XFA foreground form types must match"); +static_assert(static_cast(PDFEngine::FormType::kCount) == FORMTYPE_COUNT, + "Form type counts must match"); + namespace { const int32_t kPageShadowTop = 3; @@ -1282,6 +1296,7 @@ void PDFiumEngine::FinishLoadingDocument() { document_features.is_linearized = (FPDFAvail_IsLinearized(fpdf_availability_) == PDF_LINEARIZED); document_features.is_tagged = FPDFCatalog_IsTagged(doc_); + document_features.form_type = static_cast(FPDF_GetFormType(doc_)); client_->DocumentLoadComplete(document_features); } } diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index ad474f5f9505a8..30b405689c8090 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -31229,6 +31229,13 @@ from previous Chrome versions. + + + + + + + diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 0d207876190f26..a039c8203ea9bc 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -58368,6 +58368,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. + + rharrison@chromium.org + + Tracks what types of forms are present in PDF document, logged when the + document finishes loading. + + + hnakashima@chromium.org