Add Accessibility.ScreenAI.Searchify.ScreenReaderModeEnabled metric.
Add a new metric that records if screen reader mode was enabled when PDF Searchify added text to a PDF for the first time. The metric helps to evaluate how much Searchify feature was used by assistive technology users. AX-Relnotes: n/a Bug: 360803943 Change-Id: Ic7833f598816a776768e74d81f0b3aa3bc8cb640 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6080372 Reviewed-by: Mark Schillaci <mschillaci@google.com> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ramin Halavati <rhalavati@chromium.org> Cr-Commit-Position: refs/heads/main@{#1395413}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d801ec45e6
commit
a77a7608bc
chrome/browser/pdf
components/pdf/renderer
pdf
tools/metrics/histograms/metadata/accessibility
@ -1515,17 +1515,31 @@ IN_PROC_BROWSER_TEST_P(PdfOcrIntegrationTest, HelloWorld) {
|
||||
base::HistogramTester histograms;
|
||||
RunPDFAXTreeDumpTest("hello-world-in-image.pdf",
|
||||
GetExpectedStatus(/*has_content=*/true));
|
||||
|
||||
metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting();
|
||||
histograms.ExpectBucketCount("Accessibility.PDF.HasAccessibleText2",
|
||||
/*sample=*/false,
|
||||
/*expected_count=*/1);
|
||||
histograms.ExpectTotalCount("Accessibility.PDF.HasAccessibleText2",
|
||||
/*expected_count=*/1);
|
||||
histograms.ExpectUniqueSample("Accessibility.PDF.HasAccessibleText2",
|
||||
/*sample=*/false,
|
||||
/*expected_count=*/1);
|
||||
|
||||
int expected_count = (IsSearchifyEnabled() && IsOcrAvailable()) ? 1 : 0;
|
||||
// Screen Reader is always enabled for this test.
|
||||
// TODO(crbug.com/360803943): Try adding Searchify browser test without
|
||||
// screen reader.
|
||||
histograms.ExpectUniqueSample(
|
||||
"Accessibility.ScreenAI.Searchify.ScreenReaderModeEnabled",
|
||||
/*sample=*/true, expected_count);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_P(PdfOcrIntegrationTest, ThreePagePDF) {
|
||||
base::HistogramTester histograms;
|
||||
RunPDFAXTreeDumpTest("inaccessible-text-in-three-page.pdf",
|
||||
GetExpectedStatus(/*has_content=*/true));
|
||||
|
||||
metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting();
|
||||
int expected_count = (IsSearchifyEnabled() && IsOcrAvailable()) ? 1 : 0;
|
||||
histograms.ExpectUniqueSample(
|
||||
"Accessibility.ScreenAI.Searchify.ScreenReaderModeEnabled",
|
||||
/*sample=*/true, expected_count);
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_P(PdfOcrIntegrationTest, TestBatchingWithTwentyPagePDF) {
|
||||
|
@ -536,6 +536,21 @@ void PdfAccessibilityTree::SetAccessibilityPageInfo(
|
||||
std::move(chars), std::move(page_objects)));
|
||||
}
|
||||
|
||||
void PdfAccessibilityTree::OnHasSearchifyText() {
|
||||
// TODO(crbug.com/360803943): Look into if `render_frame()` can be null, why
|
||||
// it is assumed to be not null in `SetOcrCompleteStatus()`, and create a
|
||||
// better distinction between `render_frame()` and `render_frame_`.
|
||||
// TODO(accessibility): remove this dependency.
|
||||
content::RenderAccessibility* render_accessibility =
|
||||
render_frame() ? render_frame()->GetRenderAccessibility() : nullptr;
|
||||
bool screen_reader_mode =
|
||||
(render_accessibility &&
|
||||
render_accessibility->GetAXMode().has_mode(ui::AXMode::kScreenReader));
|
||||
base::UmaHistogramBoolean(
|
||||
"Accessibility.ScreenAI.Searchify.ScreenReaderModeEnabled",
|
||||
screen_reader_mode);
|
||||
}
|
||||
|
||||
void PdfAccessibilityTree::DoSetAccessibilityPageInfo(
|
||||
const chrome_pdf::AccessibilityPageInfo& page_info,
|
||||
const std::vector<chrome_pdf::AccessibilityTextRunInfo>& text_runs,
|
||||
|
@ -96,6 +96,9 @@ class PdfAccessibilityTree : public ui::AXTreeSource<const ui::AXNode*,
|
||||
std::vector<chrome_pdf::AccessibilityTextRunInfo> text_runs,
|
||||
std::vector<chrome_pdf::AccessibilityCharInfo> chars,
|
||||
chrome_pdf::AccessibilityPageObjects page_objects) override;
|
||||
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
|
||||
void OnHasSearchifyText() override;
|
||||
#endif
|
||||
|
||||
void HandleAction(const chrome_pdf::AccessibilityActionData& action_data);
|
||||
std::optional<AnnotationInfo> GetPdfAnnotationInfoFromAXNode(
|
||||
|
@ -325,6 +325,7 @@ if (enable_pdf) {
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//services/screen_ai/buildflags",
|
||||
"//skia",
|
||||
"//ui/gfx/geometry",
|
||||
]
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "services/screen_ai/buildflags/buildflags.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
struct AccessibilityCharInfo;
|
||||
@ -28,6 +30,12 @@ class PdfAccessibilityDataHandler {
|
||||
std::vector<AccessibilityTextRunInfo> text_runs,
|
||||
std::vector<AccessibilityCharInfo> chars,
|
||||
AccessibilityPageObjects page_objects) = 0;
|
||||
|
||||
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
|
||||
// Notifies that at least one page is searchified. This function is called at
|
||||
// most once.
|
||||
virtual void OnHasSearchifyText() = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace chrome_pdf
|
||||
|
@ -1509,6 +1509,7 @@ void PdfViewWebPlugin::OnHasSearchifyText() {
|
||||
base::Value::Dict message;
|
||||
message.Set("type", "setHasSearchifyText");
|
||||
client_->PostMessage(std::move(message));
|
||||
pdf_accessibility_data_handler_->OnHasSearchifyText();
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
|
||||
|
||||
|
@ -211,6 +211,9 @@ class MockPdfAccessibilityDataHandler : public PdfAccessibilityDataHandler {
|
||||
std::vector<AccessibilityCharInfo>,
|
||||
AccessibilityPageObjects),
|
||||
(override));
|
||||
#if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE)
|
||||
MOCK_METHOD(void, OnHasSearchifyText, (), (override));
|
||||
#endif
|
||||
};
|
||||
|
||||
class FakePdfViewWebPluginClient : public PdfViewWebPlugin::Client {
|
||||
|
@ -208,7 +208,8 @@ class PDFiumEngineClient {
|
||||
// See the comment for `OnSearchifyStateChange` in pdf/pdfium/pdfium_engine.h.
|
||||
virtual void OnSearchifyStateChange(bool busy) = 0;
|
||||
|
||||
// Notifies that at least one page is searchified.
|
||||
// Notifies that at least one page is searchified. This function is called at
|
||||
// most once.
|
||||
virtual void OnHasSearchifyText() = 0;
|
||||
#endif
|
||||
};
|
||||
|
@ -2960,6 +2960,22 @@ even if they fit the naming pattern. -->
|
||||
</token>
|
||||
</histogram>
|
||||
|
||||
<histogram name="Accessibility.ScreenAI.Searchify.ScreenReaderModeEnabled"
|
||||
enum="Boolean" expires_after="2025-11-01">
|
||||
<owner>rhalavati@chromium.org</owner>
|
||||
<owner>thestig@chromium.org</owner>
|
||||
<owner>chrome-a11y-core@google.com</owner>
|
||||
<summary>
|
||||
Tracks if screen reader mode was enabled in the browser when PDF Searchifier
|
||||
added text to a PDF. This metric is recorded only once for each PDF, and
|
||||
records the status when searchify adds the first text to the page. If screen
|
||||
reader status changes after the first page is searchified, it's not
|
||||
recorded. The metric is recorded when browser is in screen reader compatible
|
||||
mode and it does not necessarily mean that a screen reader is running on the
|
||||
OS.
|
||||
</summary>
|
||||
</histogram>
|
||||
|
||||
<histogram name="Accessibility.ScreenAI.Service.Initialization"
|
||||
enum="BooleanSuccess" expires_after="2025-04-13">
|
||||
<owner>rhalavati@chromium.org</owner>
|
||||
|
Reference in New Issue
Block a user