0

Add more metrics for PDF Searchify.

Add two more values to PDF.Actions to record COPY and FIND actions
for searchified PDFs.
Add PDF.SearchifySuccessful metric to record if searchify was successful
for PDFs which could benefit from it.

Bug: 360803943
Change-Id: Ie9519d714a740ee2ba5484deb82f016882285b65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6000169
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Alan Screen <awscreen@chromium.org>
Reviewed-by: Andy Phan <andyphan@chromium.org>
Auto-Submit: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1380578}
This commit is contained in:
Ramin Halavati
2024-11-08 20:31:24 +00:00
committed by Chromium LUCI CQ
parent c26127f14e
commit f6a13f3227
5 changed files with 40 additions and 7 deletions
chrome/browser/resources/pdf
pdf/pdfium
tools/metrics/histograms/metadata/pdf

@ -204,7 +204,7 @@ export enum UserAction {
SELECT_SIDENAV_ATTACHMENT_FIRST = 65,
SELECT_SIDENAV_ATTACHMENT = 66,
// Recorded cut/copy/paste commands.
// Recorded cut/copy/paste/find commands.
CUT_FIRST = 67,
CUT = 68,
COPY_FIRST = 69,
@ -214,7 +214,13 @@ export enum UserAction {
FIND_IN_PAGE_FIRST = 73,
FIND_IN_PAGE = 74,
NUMBER_OF_ACTIONS = 75,
// Recorded copy/find commands for searchified PDFs.
COPY_SEARCHIFIED_FIRST = 75,
COPY_SEARCHIFIED = 76,
FIND_IN_PAGE_SEARCHIFIED_FIRST = 77,
FIND_IN_PAGE_SEARCHIFIED = 78,
NUMBER_OF_ACTIONS = 79,
}
function createFirstMap(): Map<UserAction, UserAction> {

@ -290,6 +290,7 @@ export class PdfViewerElement extends PdfViewerBaseElement {
protected twoUpViewEnabled_: boolean = false;
protected viewportZoom_: number = 1;
protected zoomBounds_: ZoomBounds = {min: 0, max: 0};
private hasSearchifyText_: boolean = false;
// <if expr="enable_ink">
private inkController_: InkController = InkController.getInstance();
@ -864,6 +865,9 @@ export class PdfViewerElement extends PdfViewerBaseElement {
return;
case 'Copy':
record(UserAction.COPY);
if (this.hasSearchifyText_) {
record(UserAction.COPY_SEARCHIFIED);
}
return;
case 'Paste':
record(UserAction.PASTE);
@ -913,13 +917,17 @@ export class PdfViewerElement extends PdfViewerBaseElement {
this.hasEdits_ = true;
return;
case 'setHasSearchifyText':
// TODO(crbug.com/360803943): Add separate metrics for searchified PDFs.
// TODO(crbug.com/360803943): Add test for metrics.
this.hasSearchifyText_ = true;
return;
case 'showSearchifyInProgress':
// TODO(crbug.com/360803943): Trigger showing/hiding searchify progress.
return;
case 'startedFindInPage':
record(UserAction.FIND_IN_PAGE);
if (this.hasSearchifyText_) {
record(UserAction.FIND_IN_PAGE_SEARCHIFIED);
}
return;
case 'touchSelectionOccurred':
this.sendScriptingMessage({

@ -578,14 +578,19 @@ PDFiumEngine::~PDFiumEngine() {
base::UmaHistogramLongTimes("PDF.EngineLifetime",
base::TimeTicks::Now() - engine_creation_time_);
}
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
// `searchifier_` is created when at least one page needs searchify.
if (searchifier_) {
base::UmaHistogramBoolean("PDF.SearchifySuccessful", has_searchify_text_);
}
// Should be reset before document is unloaded.
searchifier_.reset();
#endif
// Clear all the containers that can prevent unloading.
find_results_.clear();
selection_.clear();
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
// Should be reset before document is unloaded.
searchifier_.reset();
#endif
for (auto& page : pages_)
page->Unload();

@ -102,6 +102,10 @@ chromium-metrics-reviews@google.com.
<int value="72" label="Paste"/>
<int value="73" label="FindInPageFirst"/>
<int value="74" label="FindInPage"/>
<int value="75" label="CopySearchifiedFirst"/>
<int value="76" label="CopySearchified"/>
<int value="77" label="FindInPageSearchifiedFirst"/>
<int value="78" label="FindInPageSearchified"/>
</enum>
<enum name="ChromePDFViewerLoadStatus">

@ -135,6 +135,16 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>
<histogram name="PDF.SearchifySuccessful" enum="Boolean"
expires_after="2025-11-01">
<owner>rhalavati@chromium.org</owner>
<owner>thestig@chromium.org</owner>
<summary>
Tracks the number of PDF documents that Searchify is run on, and whether
Searchify could add any text to them or not.
</summary>
</histogram>
<histogram name="PDF.Version" enum="PDFVersion" expires_after="2025-03-09">
<owner>dhoss@chromium.org</owner>
<owner>thestig@chromium.org</owner>