Commit 5b7b42ca authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

[printing] Move PrintHostMsg_PreviewIds to print.mojom

This CL moves printing::PrintHostMsg_PreviewIds to print.mojom
to pass it to Mojo interfaces. This is a precursor CL to
move PrintPreviewUI implementations to PrintPreviewMessageHandler
and use WebContentsFrameReceiverSet instead of having its own pipe.

Bug: 1122515, 1008939
Change-Id: I034e05f64f2de565dcf6a7d9724b78e822bf2114
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379455
Commit-Queue: Julie Kim <jkim@igalia.com>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarKevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804163}
parent 23ae5a29
...@@ -111,7 +111,7 @@ void PrintPreviewMessageHandler::OnRequestPrintPreview( ...@@ -111,7 +111,7 @@ void PrintPreviewMessageHandler::OnRequestPrintPreview(
void PrintPreviewMessageHandler::OnDidStartPreview( void PrintPreviewMessageHandler::OnDidStartPreview(
const mojom::DidStartPreviewParams& params, const mojom::DidStartPreviewParams& params,
const PrintHostMsg_PreviewIds& ids) { const mojom::PreviewIds& ids) {
if (params.page_count <= 0 || params.pages_to_render.empty()) { if (params.page_count <= 0 || params.pages_to_render.empty()) {
NOTREACHED(); NOTREACHED();
return; return;
...@@ -144,7 +144,7 @@ void PrintPreviewMessageHandler::OnDidStartPreview( ...@@ -144,7 +144,7 @@ void PrintPreviewMessageHandler::OnDidStartPreview(
void PrintPreviewMessageHandler::OnDidPrepareForDocumentToPdf( void PrintPreviewMessageHandler::OnDidPrepareForDocumentToPdf(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
int document_cookie, int document_cookie,
const PrintHostMsg_PreviewIds& ids) { const mojom::PreviewIds& ids) {
PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(ids.ui_id); PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(ids.ui_id);
if (!print_preview_ui) if (!print_preview_ui)
return; return;
...@@ -175,7 +175,7 @@ void PrintPreviewMessageHandler::OnDidPrepareForDocumentToPdf( ...@@ -175,7 +175,7 @@ void PrintPreviewMessageHandler::OnDidPrepareForDocumentToPdf(
void PrintPreviewMessageHandler::OnDidPreviewPage( void PrintPreviewMessageHandler::OnDidPreviewPage(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const mojom::DidPreviewPageParams& params, const mojom::DidPreviewPageParams& params,
const PrintHostMsg_PreviewIds& ids) { const mojom::PreviewIds& ids) {
int page_number = params.page_number; int page_number = params.page_number;
const mojom::DidPrintContentParams& content = *params.content; const mojom::DidPrintContentParams& content = *params.content;
if (page_number < FIRST_PAGE_INDEX || !content.metafile_data_region.IsValid()) if (page_number < FIRST_PAGE_INDEX || !content.metafile_data_region.IsValid())
...@@ -218,7 +218,7 @@ void PrintPreviewMessageHandler::OnDidPreviewPage( ...@@ -218,7 +218,7 @@ void PrintPreviewMessageHandler::OnDidPreviewPage(
void PrintPreviewMessageHandler::OnMetafileReadyForPrinting( void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
const mojom::DidPreviewDocumentParams& params, const mojom::DidPreviewDocumentParams& params,
const PrintHostMsg_PreviewIds& ids) { const mojom::PreviewIds& ids) {
// Always try to stop the worker. // Always try to stop the worker.
StopWorker(params.document_cookie); StopWorker(params.document_cookie);
...@@ -273,7 +273,7 @@ void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout( ...@@ -273,7 +273,7 @@ void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout(
const mojom::PageSizeMargins& page_layout_in_points, const mojom::PageSizeMargins& page_layout_in_points,
const gfx::Rect& printable_area_in_points, const gfx::Rect& printable_area_in_points,
bool has_custom_page_size_style, bool has_custom_page_size_style,
const PrintHostMsg_PreviewIds& ids) { const mojom::PreviewIds& ids) {
PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(ids.ui_id); PrintPreviewUI* print_preview_ui = GetPrintPreviewUI(ids.ui_id);
if (!print_preview_ui) if (!print_preview_ui)
return; return;
...@@ -286,7 +286,7 @@ void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout( ...@@ -286,7 +286,7 @@ void PrintPreviewMessageHandler::OnDidGetDefaultPageLayout(
void PrintPreviewMessageHandler::NotifyUIPreviewPageReady( void PrintPreviewMessageHandler::NotifyUIPreviewPageReady(
PrintPreviewUI* print_preview_ui, PrintPreviewUI* print_preview_ui,
int page_number, int page_number,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
scoped_refptr<base::RefCountedMemory> data_bytes) { scoped_refptr<base::RefCountedMemory> data_bytes) {
if (!data_bytes || !data_bytes->size()) if (!data_bytes || !data_bytes->size())
return; return;
...@@ -301,7 +301,7 @@ void PrintPreviewMessageHandler::NotifyUIPreviewPageReady( ...@@ -301,7 +301,7 @@ void PrintPreviewMessageHandler::NotifyUIPreviewPageReady(
void PrintPreviewMessageHandler::NotifyUIPreviewDocumentReady( void PrintPreviewMessageHandler::NotifyUIPreviewDocumentReady(
PrintPreviewUI* print_preview_ui, PrintPreviewUI* print_preview_ui,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
scoped_refptr<base::RefCountedMemory> data_bytes) { scoped_refptr<base::RefCountedMemory> data_bytes) {
if (!data_bytes || !data_bytes->size()) if (!data_bytes || !data_bytes->size())
return; return;
...@@ -317,7 +317,7 @@ void PrintPreviewMessageHandler::NotifyUIPreviewDocumentReady( ...@@ -317,7 +317,7 @@ void PrintPreviewMessageHandler::NotifyUIPreviewDocumentReady(
void PrintPreviewMessageHandler::OnCompositePdfPageDone( void PrintPreviewMessageHandler::OnCompositePdfPageDone(
int page_number, int page_number,
int document_cookie, int document_cookie,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PrintCompositor::Status status, mojom::PrintCompositor::Status status,
base::ReadOnlySharedMemoryRegion region) { base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
...@@ -377,7 +377,7 @@ void PrintPreviewMessageHandler::OnCompositePdfPageDone( ...@@ -377,7 +377,7 @@ void PrintPreviewMessageHandler::OnCompositePdfPageDone(
void PrintPreviewMessageHandler::OnNupPdfConvertDone( void PrintPreviewMessageHandler::OnNupPdfConvertDone(
int page_number, int page_number,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PdfNupConverter::Status status, mojom::PdfNupConverter::Status status,
base::ReadOnlySharedMemoryRegion region) { base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
...@@ -399,7 +399,7 @@ void PrintPreviewMessageHandler::OnNupPdfConvertDone( ...@@ -399,7 +399,7 @@ void PrintPreviewMessageHandler::OnNupPdfConvertDone(
void PrintPreviewMessageHandler::OnCompositeToPdfDone( void PrintPreviewMessageHandler::OnCompositeToPdfDone(
int document_cookie, int document_cookie,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PrintCompositor::Status status, mojom::PrintCompositor::Status status,
base::ReadOnlySharedMemoryRegion region) { base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
...@@ -444,7 +444,7 @@ void PrintPreviewMessageHandler::OnCompositeToPdfDone( ...@@ -444,7 +444,7 @@ void PrintPreviewMessageHandler::OnCompositeToPdfDone(
} }
void PrintPreviewMessageHandler::OnPrepareForDocumentToPdfDone( void PrintPreviewMessageHandler::OnPrepareForDocumentToPdfDone(
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PrintCompositor::Status status) { mojom::PrintCompositor::Status status) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
...@@ -459,7 +459,7 @@ void PrintPreviewMessageHandler::OnPrepareForDocumentToPdfDone( ...@@ -459,7 +459,7 @@ void PrintPreviewMessageHandler::OnPrepareForDocumentToPdfDone(
} }
void PrintPreviewMessageHandler::OnNupPdfDocumentConvertDone( void PrintPreviewMessageHandler::OnNupPdfDocumentConvertDone(
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PdfNupConverter::Status status, mojom::PdfNupConverter::Status status,
base::ReadOnlySharedMemoryRegion region) { base::ReadOnlySharedMemoryRegion region) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "printing/mojom/print.mojom-forward.h" #include "printing/mojom/print.mojom-forward.h"
struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_RequestPrintPreview_Params;
namespace base { namespace base {
...@@ -67,47 +66,47 @@ class PrintPreviewMessageHandler ...@@ -67,47 +66,47 @@ class PrintPreviewMessageHandler
const mojom::PageSizeMargins& page_layout_in_points, const mojom::PageSizeMargins& page_layout_in_points,
const gfx::Rect& printable_area_in_points, const gfx::Rect& printable_area_in_points,
bool has_custom_page_size_style, bool has_custom_page_size_style,
const PrintHostMsg_PreviewIds& ids); const mojom::PreviewIds& ids);
void OnDidStartPreview(const mojom::DidStartPreviewParams& params, void OnDidStartPreview(const mojom::DidStartPreviewParams& params,
const PrintHostMsg_PreviewIds& ids); const mojom::PreviewIds& ids);
void OnDidPrepareForDocumentToPdf(content::RenderFrameHost* render_frame_host, void OnDidPrepareForDocumentToPdf(content::RenderFrameHost* render_frame_host,
int document_cookie, int document_cookie,
const PrintHostMsg_PreviewIds& ids); const mojom::PreviewIds& ids);
void OnDidPreviewPage(content::RenderFrameHost* render_frame_host, void OnDidPreviewPage(content::RenderFrameHost* render_frame_host,
const mojom::DidPreviewPageParams& params, const mojom::DidPreviewPageParams& params,
const PrintHostMsg_PreviewIds& ids); const mojom::PreviewIds& ids);
void OnMetafileReadyForPrinting(content::RenderFrameHost* render_frame_host, void OnMetafileReadyForPrinting(content::RenderFrameHost* render_frame_host,
const mojom::DidPreviewDocumentParams& params, const mojom::DidPreviewDocumentParams& params,
const PrintHostMsg_PreviewIds& ids); const mojom::PreviewIds& ids);
void NotifyUIPreviewPageReady( void NotifyUIPreviewPageReady(
PrintPreviewUI* print_preview_ui, PrintPreviewUI* print_preview_ui,
int page_number, int page_number,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
scoped_refptr<base::RefCountedMemory> data_bytes); scoped_refptr<base::RefCountedMemory> data_bytes);
void NotifyUIPreviewDocumentReady( void NotifyUIPreviewDocumentReady(
PrintPreviewUI* print_preview_ui, PrintPreviewUI* print_preview_ui,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
scoped_refptr<base::RefCountedMemory> data_bytes); scoped_refptr<base::RefCountedMemory> data_bytes);
// Callbacks for print compositor client. // Callbacks for print compositor client.
void OnCompositePdfPageDone(int page_number, void OnCompositePdfPageDone(int page_number,
int document_cookie, int document_cookie,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PrintCompositor::Status status, mojom::PrintCompositor::Status status,
base::ReadOnlySharedMemoryRegion region); base::ReadOnlySharedMemoryRegion region);
void OnCompositeToPdfDone(int document_cookie, void OnCompositeToPdfDone(int document_cookie,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PrintCompositor::Status status, mojom::PrintCompositor::Status status,
base::ReadOnlySharedMemoryRegion region); base::ReadOnlySharedMemoryRegion region);
void OnPrepareForDocumentToPdfDone(const PrintHostMsg_PreviewIds& ids, void OnPrepareForDocumentToPdfDone(const mojom::PreviewIds& ids,
mojom::PrintCompositor::Status status); mojom::PrintCompositor::Status status);
void OnNupPdfConvertDone(int page_number, void OnNupPdfConvertDone(int page_number,
const PrintHostMsg_PreviewIds& ids, const mojom::PreviewIds& ids,
mojom::PdfNupConverter::Status status, mojom::PdfNupConverter::Status status,
base::ReadOnlySharedMemoryRegion region); base::ReadOnlySharedMemoryRegion region);
void OnNupPdfDocumentConvertDone(const PrintHostMsg_PreviewIds& ids, void OnNupPdfDocumentConvertDone(const mojom::PreviewIds& ids,
mojom::PdfNupConverter::Status status, mojom::PdfNupConverter::Status status,
base::ReadOnlySharedMemoryRegion region); base::ReadOnlySharedMemoryRegion region);
......
...@@ -273,7 +273,7 @@ class PrintPreviewObserver : public WebContentsObserver { ...@@ -273,7 +273,7 @@ class PrintPreviewObserver : public WebContentsObserver {
// Called when the observer gets the IPC message with the preview document's // Called when the observer gets the IPC message with the preview document's
// properties. // properties.
void OnDidStartPreview(const mojom::DidStartPreviewParams& params, void OnDidStartPreview(const mojom::DidStartPreviewParams& params,
const PrintHostMsg_PreviewIds& ids) { const printing::mojom::PreviewIds& ids) {
WebContents* web_contents = GetDialog(); WebContents* web_contents = GetDialog();
ASSERT_TRUE(web_contents); ASSERT_TRUE(web_contents);
Observe(web_contents); Observe(web_contents);
......
...@@ -300,7 +300,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply( ...@@ -300,7 +300,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply(
} }
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintingMessageFilter::OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, void PrintingMessageFilter::OnCheckForCancel(const mojom::PreviewIds& ids,
bool* cancel) { bool* cancel) {
*cancel = PrintPreviewUI::ShouldCancelRequest(ids); *cancel = PrintPreviewUI::ShouldCancelRequest(ids);
} }
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "printing/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h"
struct PrintHostMsg_PreviewIds;
class Profile; class Profile;
namespace printing { namespace printing {
...@@ -83,7 +82,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter { ...@@ -83,7 +82,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Check to see if print preview has been cancelled. // Check to see if print preview has been cancelled.
void OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, bool* cancel); void OnCheckForCancel(const mojom::PreviewIds& ids, bool* cancel);
#if defined(OS_WIN) #if defined(OS_WIN)
void NotifySystemDialogCancelled(int routing_id); void NotifySystemDialogCancelled(int routing_id);
#endif #endif
......
...@@ -648,7 +648,7 @@ void PrintPreviewUI::SetInitialParams( ...@@ -648,7 +648,7 @@ void PrintPreviewUI::SetInitialParams(
} }
// static // static
bool PrintPreviewUI::ShouldCancelRequest(const PrintHostMsg_PreviewIds& ids) { bool PrintPreviewUI::ShouldCancelRequest(const mojom::PreviewIds& ids) {
int current_id = -1; int current_id = -1;
if (!g_print_preview_request_id_map.Get().Get(ids.ui_id, &current_id)) if (!g_print_preview_request_id_map.Get().Get(ids.ui_id, &current_id))
return true; return true;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_RequestPrintPreview_Params; struct PrintHostMsg_RequestPrintPreview_Params;
namespace base { namespace base {
...@@ -132,7 +131,7 @@ class PrintPreviewUI : public ConstrainedWebDialogUI, ...@@ -132,7 +131,7 @@ class PrintPreviewUI : public ConstrainedWebDialogUI,
// Determines whether to cancel a print preview request based on the request // Determines whether to cancel a print preview request based on the request
// and UI ids in |ids|. // and UI ids in |ids|.
// Can be called from any thread. // Can be called from any thread.
static bool ShouldCancelRequest(const PrintHostMsg_PreviewIds& ids); static bool ShouldCancelRequest(const mojom::PreviewIds& ids);
// Returns an id to uniquely identify this PrintPreviewUI. // Returns an id to uniquely identify this PrintPreviewUI.
base::Optional<int32_t> GetIDForPrintPreviewUI() const; base::Optional<int32_t> GetIDForPrintPreviewUI() const;
......
...@@ -11,6 +11,14 @@ import "mojo/public/mojom/base/unguessable_token.mojom"; ...@@ -11,6 +11,14 @@ import "mojo/public/mojom/base/unguessable_token.mojom";
import "printing/mojom/print.mojom"; import "printing/mojom/print.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom";
// Preview Ids, the id of the preview request and the print preview ui
// associated with this request.
[EnableIf=enable_print_preview]
struct PreviewIds {
int32 request_id = -1;
int32 ui_id = -1;
};
// Parameters required to print the content of an out-of-process subframe. // Parameters required to print the content of an out-of-process subframe.
struct PrintFrameContentParams { struct PrintFrameContentParams {
// Physical printable area of the page in pixels according to dpi. // Physical printable area of the page in pixels according to dpi.
......
...@@ -75,12 +75,4 @@ PrintHostMsg_RequestPrintPreview_Params:: ...@@ -75,12 +75,4 @@ PrintHostMsg_RequestPrintPreview_Params::
PrintHostMsg_RequestPrintPreview_Params:: PrintHostMsg_RequestPrintPreview_Params::
~PrintHostMsg_RequestPrintPreview_Params() {} ~PrintHostMsg_RequestPrintPreview_Params() {}
PrintHostMsg_PreviewIds::PrintHostMsg_PreviewIds()
: request_id(-1), ui_id(-1) {}
PrintHostMsg_PreviewIds::PrintHostMsg_PreviewIds(int request_id, int ui_id)
: request_id(request_id), ui_id(ui_id) {}
PrintHostMsg_PreviewIds::~PrintHostMsg_PreviewIds() {}
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
...@@ -42,14 +42,6 @@ struct PrintHostMsg_RequestPrintPreview_Params { ...@@ -42,14 +42,6 @@ struct PrintHostMsg_RequestPrintPreview_Params {
bool has_selection; bool has_selection;
bool selection_only; bool selection_only;
}; };
struct PrintHostMsg_PreviewIds {
PrintHostMsg_PreviewIds();
PrintHostMsg_PreviewIds(int request_id, int ui_id);
~PrintHostMsg_PreviewIds();
int request_id;
int ui_id;
};
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_ #endif // INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
...@@ -164,7 +156,7 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params) ...@@ -164,7 +156,7 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
IPC_STRUCT_TRAITS_MEMBER(selection_only) IPC_STRUCT_TRAITS_MEMBER(selection_only)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_PreviewIds) IPC_STRUCT_TRAITS_BEGIN(printing::mojom::PreviewIds)
IPC_STRUCT_TRAITS_MEMBER(request_id) IPC_STRUCT_TRAITS_MEMBER(request_id)
IPC_STRUCT_TRAITS_MEMBER(ui_id) IPC_STRUCT_TRAITS_MEMBER(ui_id)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
...@@ -324,14 +316,14 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview, ...@@ -324,14 +316,14 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
// Notify the browser the about the to-be-rendered print preview document. // Notify the browser the about the to-be-rendered print preview document.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidStartPreview, IPC_MESSAGE_ROUTED2(PrintHostMsg_DidStartPreview,
printing::mojom::DidStartPreviewParams /* params */, printing::mojom::DidStartPreviewParams /* params */,
PrintHostMsg_PreviewIds /* ids */) printing::mojom::PreviewIds /* ids */)
// Notify the browser of preparing to print the document, for cases where // Notify the browser of preparing to print the document, for cases where
// the document will be collected from the individual pages instead of being // the document will be collected from the individual pages instead of being
// provided by an extra metafile at end containing all pages. // provided by an extra metafile at end containing all pages.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPrepareDocumentForPreview, IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPrepareDocumentForPreview,
int /* document_cookie */, int /* document_cookie */,
PrintHostMsg_PreviewIds /* ids */) printing::mojom::PreviewIds /* ids */)
// Notify the browser of the default page layout according to the currently // Notify the browser of the default page layout according to the currently
// selected printer and page size. // selected printer and page size.
...@@ -343,16 +335,16 @@ IPC_MESSAGE_ROUTED4( ...@@ -343,16 +335,16 @@ IPC_MESSAGE_ROUTED4(
printing::mojom::PageSizeMargins /* page layout in points */, printing::mojom::PageSizeMargins /* page layout in points */,
gfx::Rect /* printable area in points */, gfx::Rect /* printable area in points */,
bool /* has custom page size style */, bool /* has custom page size style */,
PrintHostMsg_PreviewIds /* ids */) printing::mojom::PreviewIds /* ids */)
// Notify the browser a print preview page has been rendered. // Notify the browser a print preview page has been rendered.
IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPreviewPage, IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPreviewPage,
printing::mojom::DidPreviewPageParams /* params */, printing::mojom::DidPreviewPageParams /* params */,
PrintHostMsg_PreviewIds /* ids */) printing::mojom::PreviewIds /* ids */)
// Asks the browser whether the print preview has been cancelled. // Asks the browser whether the print preview has been cancelled.
IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel, IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel,
PrintHostMsg_PreviewIds /* ids */, printing::mojom::PreviewIds /* ids */,
bool /* print preview cancelled */) bool /* print preview cancelled */)
// Sends back to the browser the complete rendered document (non-draft mode, // Sends back to the browser the complete rendered document (non-draft mode,
...@@ -360,7 +352,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel, ...@@ -360,7 +352,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel,
// The memory handle in this message is already valid in the browser process. // The memory handle in this message is already valid in the browser process.
IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting, IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting,
printing::mojom::DidPreviewDocumentParams /* params */, printing::mojom::DidPreviewDocumentParams /* params */,
PrintHostMsg_PreviewIds /* ids */) printing::mojom::PreviewIds /* ids */)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
// This is sent when there are invalid printer settings. // This is sent when there are invalid printer settings.
......
...@@ -1548,8 +1548,8 @@ PrintRenderFrameHelper::CreatePreviewDocument() { ...@@ -1548,8 +1548,8 @@ PrintRenderFrameHelper::CreatePreviewDocument() {
ConvertUnit(print_params.printable_area.width(), dpi, kPointsPerInch), ConvertUnit(print_params.printable_area.width(), dpi, kPointsPerInch),
ConvertUnit(print_params.printable_area.height(), dpi, kPointsPerInch)); ConvertUnit(print_params.printable_area.height(), dpi, kPointsPerInch));
PrintHostMsg_PreviewIds ids(print_params.preview_request_id, mojom::PreviewIds ids(print_params.preview_request_id,
print_params.preview_ui_id); print_params.preview_ui_id);
// Margins: Send default page layout to browser process. // Margins: Send default page layout to browser process.
Send(new PrintHostMsg_DidGetDefaultPageLayout( Send(new PrintHostMsg_DidGetDefaultPageLayout(
...@@ -1697,8 +1697,8 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() { ...@@ -1697,8 +1697,8 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() {
preview_params.expected_pages_count = preview_params.expected_pages_count =
print_preview_context_.pages_rendered_count(); print_preview_context_.pages_rendered_count();
PrintHostMsg_PreviewIds ids(print_pages_params_->params->preview_request_id, mojom::PreviewIds ids(print_pages_params_->params->preview_request_id,
print_pages_params_->params->preview_ui_id); print_pages_params_->params->preview_ui_id);
is_print_ready_metafile_sent_ = true; is_print_ready_metafile_sent_ = true;
...@@ -1909,7 +1909,7 @@ void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) { ...@@ -1909,7 +1909,7 @@ void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) {
int cookie = int cookie =
print_pages_params_ ? print_pages_params_->params->document_cookie : 0; print_pages_params_ ? print_pages_params_->params->document_cookie : 0;
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
PrintHostMsg_PreviewIds ids; mojom::PreviewIds ids;
if (print_pages_params_) { if (print_pages_params_) {
ids.ui_id = print_pages_params_->params->preview_ui_id; ids.ui_id = print_pages_params_->params->preview_ui_id;
ids.request_id = print_pages_params_->params->preview_request_id; ids.request_id = print_pages_params_->params->preview_request_id;
...@@ -2494,8 +2494,8 @@ bool PrintRenderFrameHelper::CheckForCancel() { ...@@ -2494,8 +2494,8 @@ bool PrintRenderFrameHelper::CheckForCancel() {
bool cancel = false; bool cancel = false;
Send(new PrintHostMsg_CheckForCancel( Send(new PrintHostMsg_CheckForCancel(
routing_id(), routing_id(),
PrintHostMsg_PreviewIds(print_params.preview_request_id, mojom::PreviewIds(print_params.preview_request_id,
print_params.preview_ui_id), print_params.preview_ui_id),
&cancel)); &cancel));
if (cancel) if (cancel)
notify_browser_of_print_failure_ = false; notify_browser_of_print_failure_ = false;
...@@ -2541,8 +2541,8 @@ bool PrintRenderFrameHelper::PreviewPageRendered( ...@@ -2541,8 +2541,8 @@ bool PrintRenderFrameHelper::PreviewPageRendered(
preview_page_params.document_cookie = preview_page_params.document_cookie =
print_pages_params_->params->document_cookie; print_pages_params_->params->document_cookie;
PrintHostMsg_PreviewIds ids(print_pages_params_->params->preview_request_id, mojom::PreviewIds ids(print_pages_params_->params->preview_request_id,
print_pages_params_->params->preview_ui_id); print_pages_params_->params->preview_ui_id);
Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params, ids)); Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params, ids));
return true; return true;
......
...@@ -102,13 +102,13 @@ void PrintMockRenderThread::OnDidPrintDocument( ...@@ -102,13 +102,13 @@ void PrintMockRenderThread::OnDidPrintDocument(
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintMockRenderThread::OnDidStartPreview( void PrintMockRenderThread::OnDidStartPreview(
const printing::mojom::DidStartPreviewParams& params, const printing::mojom::DidStartPreviewParams& params,
const PrintHostMsg_PreviewIds& ids) { const printing::mojom::PreviewIds& ids) {
print_preview_pages_remaining_ = params.page_count; print_preview_pages_remaining_ = params.page_count;
} }
void PrintMockRenderThread::OnDidPreviewPage( void PrintMockRenderThread::OnDidPreviewPage(
const printing::mojom::DidPreviewPageParams& params, const printing::mojom::DidPreviewPageParams& params,
const PrintHostMsg_PreviewIds& ids) { const printing::mojom::PreviewIds& ids) {
int page_number = params.page_number; int page_number = params.page_number;
DCHECK_GE(page_number, printing::FIRST_PAGE_INDEX); DCHECK_GE(page_number, printing::FIRST_PAGE_INDEX);
print_preview_pages_remaining_--; print_preview_pages_remaining_--;
...@@ -116,8 +116,9 @@ void PrintMockRenderThread::OnDidPreviewPage( ...@@ -116,8 +116,9 @@ void PrintMockRenderThread::OnDidPreviewPage(
params.page_number, params.content->metafile_data_region.GetSize()); params.page_number, params.content->metafile_data_region.GetSize());
} }
void PrintMockRenderThread::OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, void PrintMockRenderThread::OnCheckForCancel(
bool* cancel) { const printing::mojom::PreviewIds& ids,
bool* cancel) {
*cancel = *cancel =
(print_preview_pages_remaining_ == print_preview_cancel_page_number_); (print_preview_pages_remaining_ == print_preview_cancel_page_number_);
} }
......
...@@ -24,7 +24,6 @@ class DictionaryValue; ...@@ -24,7 +24,6 @@ class DictionaryValue;
} }
class MockPrinter; class MockPrinter;
struct PrintHostMsg_PreviewIds;
// Extends content::MockRenderThread to know about printing // Extends content::MockRenderThread to know about printing
class PrintMockRenderThread : public content::MockRenderThread { class PrintMockRenderThread : public content::MockRenderThread {
...@@ -79,10 +78,10 @@ class PrintMockRenderThread : public content::MockRenderThread { ...@@ -79,10 +78,10 @@ class PrintMockRenderThread : public content::MockRenderThread {
IPC::Message* reply_msg); IPC::Message* reply_msg);
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnDidStartPreview(const printing::mojom::DidStartPreviewParams& params, void OnDidStartPreview(const printing::mojom::DidStartPreviewParams& params,
const PrintHostMsg_PreviewIds& ids); const printing::mojom::PreviewIds& ids);
void OnDidPreviewPage(const printing::mojom::DidPreviewPageParams& params, void OnDidPreviewPage(const printing::mojom::DidPreviewPageParams& params,
const PrintHostMsg_PreviewIds& ids); const printing::mojom::PreviewIds& ids);
void OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, bool* cancel); void OnCheckForCancel(const printing::mojom::PreviewIds& ids, bool* cancel);
#endif #endif
// For print preview, PrintRenderFrameHelper will update settings. // For print preview, PrintRenderFrameHelper will update settings.
......
...@@ -196,7 +196,7 @@ class PrintPreviewWaiter : public content::BrowserMessageFilter { ...@@ -196,7 +196,7 @@ class PrintPreviewWaiter : public content::BrowserMessageFilter {
} }
void OnDidStartPreview(const printing::mojom::DidStartPreviewParams& params, void OnDidStartPreview(const printing::mojom::DidStartPreviewParams& params,
const PrintHostMsg_PreviewIds& ids) { const printing::mojom::PreviewIds& ids) {
// Expect that there is at least one page. // Expect that there is at least one page.
did_load_ = true; did_load_ = true;
run_loop_.Quit(); run_loop_.Quit();
......
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