Commit e2cbe8d4 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

[printing] Convert PrintHostMsg_AccessibilityTree to Mojo

This CL converts PrintHostMsg_AccessibilityTree message to
SetAccessibilityTree() in mojom::PrintManagerHost.

Bug: 1008939
Change-Id: I8f21acd96b472da4e7312805ed7fd51f44162405
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377666
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804594}
parent 36f741c8
......@@ -279,6 +279,15 @@ void PrintViewManagerBase::DidGetPrintedPagesCount(int32_t cookie,
OpportunisticallyCreatePrintJob(cookie);
}
#if BUILDFLAG(ENABLE_TAGGED_PDF)
void PrintViewManagerBase::SetAccessibilityTree(
int32_t cookie,
const ui::AXTreeUpdate& accessibility_tree) {
PrintCompositeClient::FromWebContents(web_contents())
->SetAccessibilityTree(cookie, accessibility_tree);
}
#endif
bool PrintViewManagerBase::PrintJobHasDocument(int cookie) {
if (!OpportunisticallyCreatePrintJob(cookie))
return false;
......
......@@ -23,6 +23,10 @@
#include "content/public/browser/notification_registrar.h"
#include "printing/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_TAGGED_PDF)
#include "ui/accessibility/ax_tree_update_forward.h"
#endif
namespace base {
class RefCountedMemory;
}
......@@ -73,6 +77,11 @@ class PrintViewManagerBase : public content::NotificationObserver,
// mojom::PrintManagerHost:
void DidGetPrintedPagesCount(int32_t cookie, int32_t number_pages) override;
#if BUILDFLAG(ENABLE_TAGGED_PDF)
void SetAccessibilityTree(
int32_t cookie,
const ui::AXTreeUpdate& accessibility_tree) override;
#endif
void ShowInvalidPrinterSettingsError() override;
void PrintingFailed(int32_t cookie) override;
......
......@@ -77,22 +77,6 @@ PrintCompositeClient::PrintCompositeClient(content::WebContents* web_contents)
PrintCompositeClient::~PrintCompositeClient() {}
bool PrintCompositeClient::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
#if BUILDFLAG(ENABLE_TAGGED_PDF)
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PrintCompositeClient, message,
render_frame_host)
IPC_MESSAGE_HANDLER(PrintHostMsg_AccessibilityTree, OnAccessibilityTree)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
#else
return false;
#endif
}
void PrintCompositeClient::RenderFrameDeleted(
content::RenderFrameHost* render_frame_host) {
if (document_cookie_ == 0) {
......@@ -160,7 +144,7 @@ void PrintCompositeClient::OnDidPrintFrameContent(
}
#if BUILDFLAG(ENABLE_TAGGED_PDF)
void PrintCompositeClient::OnAccessibilityTree(
void PrintCompositeClient::SetAccessibilityTree(
int document_cookie,
const ui::AXTreeUpdate& accessibility_tree) {
if (!IsDocumentCookieValid(document_cookie))
......
......@@ -18,7 +18,10 @@
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "printing/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_TAGGED_PDF)
#include "ui/accessibility/ax_tree_update_forward.h"
#endif
namespace printing {
......@@ -36,13 +39,10 @@ class PrintCompositeClient
~PrintCompositeClient() override;
// content::WebContentsObserver
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
// IPC message handler.
#if BUILDFLAG(ENABLE_TAGGED_PDF)
void OnAccessibilityTree(int document_cookie,
void SetAccessibilityTree(int document_cookie,
const ui::AXTreeUpdate& accessibility_tree);
#endif
......
......@@ -113,6 +113,12 @@ void PrintManager::DidGetDocumentCookie(int32_t cookie) {
cookie_ = cookie;
}
#if BUILDFLAG(ENABLE_TAGGED_PDF)
void PrintManager::SetAccessibilityTree(
int32_t cookie,
const ui::AXTreeUpdate& accessibility_tree) {}
#endif
void PrintManager::DidShowPrintDialog() {}
void PrintManager::ShowInvalidPrinterSettingsError() {}
......
......@@ -13,11 +13,16 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_receiver_set.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "printing/buildflags/buildflags.h"
#if defined(OS_ANDROID)
#include "base/callback.h"
#endif
#if BUILDFLAG(ENABLE_TAGGED_PDF)
#include "ui/accessibility/ax_tree_update_forward.h"
#endif
namespace IPC {
class Message;
}
......@@ -42,6 +47,11 @@ class PrintManager : public content::WebContentsObserver,
// printing::mojom::PrintManagerHost:
void DidGetPrintedPagesCount(int32_t cookie, int32_t number_pages) override;
void DidGetDocumentCookie(int32_t cookie) override;
#if BUILDFLAG(ENABLE_TAGGED_PDF)
void SetAccessibilityTree(
int32_t cookie,
const ui::AXTreeUpdate& accessibility_tree) override;
#endif
void DidShowPrintDialog() override;
void ShowInvalidPrinterSettingsError() override;
void PrintingFailed(int32_t cookie) override;
......
......@@ -45,6 +45,10 @@ mojom("mojo_interfaces") {
if (enable_print_preview) {
enabled_features = [ "enable_print_preview" ]
}
if (enable_tagged_pdf) {
public_deps += [ "//ui/accessibility/mojom" ]
enabled_features += [ "enable_tagged_pdf" ]
}
}
source_set("unit_tests") {
......@@ -54,6 +58,7 @@ source_set("unit_tests") {
":common",
"//ipc:test_support",
"//printing/mojom",
"//skia",
"//testing/gtest",
"//ui/gfx/geometry",
]
......
......@@ -11,6 +11,9 @@ import "mojo/public/mojom/base/unguessable_token.mojom";
import "printing/mojom/print.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
[EnableIf=enable_tagged_pdf]
import "ui/accessibility/mojom/ax_tree_update.mojom";
// Preview Ids, the id of the preview request and the print preview ui
// associated with this request.
[EnableIf=enable_print_preview]
......@@ -280,6 +283,11 @@ interface PrintManagerHost {
// Sends the document cookie of the current printer query to the browser.
DidGetDocumentCookie(int32 cookie);
// Sends the accessibility tree corresponding to a document being
// printed, needed for a tagged (accessible) PDF.
[EnableIf=enable_tagged_pdf]
SetAccessibilityTree(int32 cookie, ax.mojom.AXTreeUpdate accessibility_tree);
// Tells the browser that the print dialog has been shown.
DidShowPrintDialog();
......
......@@ -22,7 +22,6 @@
#include "printing/mojom/print.mojom.h"
#include "printing/page_range.h"
#include "printing/print_job_constants.h"
#include "ui/accessibility/ax_param_traits.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/ipc/geometry/gfx_param_traits.h"
......@@ -278,14 +277,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DidPrintDocument,
/* page content */,
bool /* completed */)
#if BUILDFLAG(ENABLE_TAGGED_PDF)
// Sends the accessibility tree corresponding to a document being
// printed, needed for a tagged (accessible) PDF.
IPC_MESSAGE_ROUTED2(PrintHostMsg_AccessibilityTree,
int /* rendered document cookie */,
ui::AXTreeUpdate)
#endif
// The renderer wants to know the default print settings.
IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
printing::mojom::PrintParams /* default_settings */)
......
......@@ -71,6 +71,10 @@
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/resource/resource_bundle.h"
#if BUILDFLAG(ENABLE_TAGGED_PDF)
#include "ui/accessibility/ax_tree_update.h"
#endif
using content::WebPreferences;
namespace printing {
......@@ -2522,9 +2526,8 @@ bool PrintRenderFrameHelper::PreviewPageRendered(
if (snapshotter_ && page_number == 0) {
ui::AXTreeUpdate accessibility_tree;
snapshotter_->Snapshot(ui::AXMode::kPDF, 0, &accessibility_tree);
Send(new PrintHostMsg_AccessibilityTree(
routing_id(), print_pages_params_->params->document_cookie,
accessibility_tree));
GetPrintManagerHost()->SetAccessibilityTree(
print_pages_params_->params->document_cookie, accessibility_tree);
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment