Skip to content

Commit

Permalink
[PDF OCR] Record "Accessibility.PDF.HasAccessibleText" only once
Browse files Browse the repository at this point in the history
Add a flag to indicate that a PDF accessibility tree was created once.
It helps that one UMA metric, "Accessibility.PDF.HasAccessibleText",
gets recorded only once when a PDF is opened.

(cherry picked from commit 690f47b)

AX-Relnotes: n/a.
Bug: 1458740
Change-Id: I8af2cd8af5e66fefd0b9be94a30fd85a31eda97c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4655048
Commit-Queue: Kyungjun Lee <kyungjunlee@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1164203}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4678964
Auto-Submit: Kyungjun Lee <kyungjunlee@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5845@{#422}
Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
  • Loading branch information
Kyungjun Lee authored and Chromium LUCI CQ committed Jul 11, 2023
1 parent 5adcd16 commit 214af36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/pdf/renderer/pdf_accessibility_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1784,8 +1784,15 @@ void PdfAccessibilityTree::UnserializeNodes() {
render_accessibility->SetPluginTreeSource(this);
nodes_.clear();

base::UmaHistogramBoolean("Accessibility.PDF.HasAccessibleText",
did_get_a_text_run_);
if (!did_unserialize_nodes_once_) {
// If the user turns on PDF OCR after opening a PDF, its PDF a11y tree gets
// created again. `did_unserialize_nodes_once_` helps to determine whether
// it's first time to create a PDF a11y tree. When a PDF is opened, the UMA
// metric, "Accessibility.PDF.HasAccessibleText", needs be recorded once.
did_unserialize_nodes_once_ = true;
base::UmaHistogramBoolean("Accessibility.PDF.HasAccessibleText",
did_get_a_text_run_);
}
}

#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
Expand Down
1 change: 1 addition & 0 deletions components/pdf/renderer/pdf_accessibility_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class PdfAccessibilityTree : public content::PluginAXTreeSource,
uint32_t next_page_index_ = 0;

bool did_get_a_text_run_ = false;
bool did_unserialize_nodes_once_ = false;

#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
// The status node contains a notification message for the user.
Expand Down

0 comments on commit 214af36

Please sign in to comment.