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

[printing] Move PrintMsg_Print_Params to print.mojom

This CL moves printing::PrintMsg_Print_Params to print.mojom
to pass it to Mojo interfaces. This is a precursor CL to
mojofy PrintHostMsg_GetDefaultPrintSettings.

Bug: 1008939
Change-Id: Ib79a3da03f8cfae58b323324ce4eb2ea3e2ea87b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2335095Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#796679}
parent 1faddf92
...@@ -83,7 +83,7 @@ void AwPrintManager::OnGetDefaultPrintSettings( ...@@ -83,7 +83,7 @@ void AwPrintManager::OnGetDefaultPrintSettings(
IPC::Message* reply_msg) { IPC::Message* reply_msg) {
// Unlike the printing_message_filter, we do process this in UI thread. // Unlike the printing_message_filter, we do process this in UI thread.
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
PrintMsg_Print_Params params; printing::mojom::PrintParams params;
printing::RenderParamsFromPrintSettings(*settings_, &params); printing::RenderParamsFromPrintSettings(*settings_, &params);
params.document_cookie = cookie_; params.document_cookie = cookie_;
PrintHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params); PrintHostMsg_GetDefaultPrintSettings::WriteReplyParams(reply_msg, params);
......
...@@ -126,8 +126,8 @@ class NupPrintingTestDelegate : public PrintingMessageFilter::TestDelegate { ...@@ -126,8 +126,8 @@ class NupPrintingTestDelegate : public PrintingMessageFilter::TestDelegate {
} }
// PrintingMessageFilter::TestDelegate: // PrintingMessageFilter::TestDelegate:
PrintMsg_Print_Params GetPrintParams() override { mojom::PrintParams GetPrintParams() override {
PrintMsg_Print_Params params; mojom::PrintParams params;
params.page_size = gfx::Size(612, 792); params.page_size = gfx::Size(612, 792);
params.content_size = gfx::Size(540, 720); params.content_size = gfx::Size(540, 720);
params.printable_area = gfx::Rect(612, 792); params.printable_area = gfx::Rect(612, 792);
......
...@@ -160,10 +160,8 @@ void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { ...@@ -160,10 +160,8 @@ void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {
void PrintingMessageFilter::OnGetDefaultPrintSettingsReply( void PrintingMessageFilter::OnGetDefaultPrintSettingsReply(
std::unique_ptr<PrinterQuery> printer_query, std::unique_ptr<PrinterQuery> printer_query,
IPC::Message* reply_msg) { IPC::Message* reply_msg) {
PrintMsg_Print_Params params; mojom::PrintParams params;
if (!printer_query || printer_query->last_status() != PrintingContext::OK) { if (printer_query && printer_query->last_status() == PrintingContext::OK) {
params.Reset();
} else {
RenderParamsFromPrintSettings(printer_query->settings(), &params); RenderParamsFromPrintSettings(printer_query->settings(), &params);
params.document_cookie = printer_query->cookie(); params.document_cookie = printer_query->cookie();
} }
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "components/keyed_service/core/keyed_service_shutdown_notifier.h" #include "components/keyed_service/core/keyed_service_shutdown_notifier.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
#include "components/printing/common/print.mojom-forward.h"
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#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; struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_ScriptedPrint_Params; struct PrintHostMsg_ScriptedPrint_Params;
struct PrintMsg_Print_Params;
class Profile; class Profile;
namespace printing { namespace printing {
...@@ -36,7 +36,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter { ...@@ -36,7 +36,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
class TestDelegate { class TestDelegate {
public: public:
// Returns the print params to be used in OnUpdatePrintSettingsReply(). // Returns the print params to be used in OnUpdatePrintSettingsReply().
virtual PrintMsg_Print_Params GetPrintParams() = 0; virtual mojom::PrintParams GetPrintParams() = 0;
protected: protected:
virtual ~TestDelegate() = default; virtual ~TestDelegate() = default;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "components/printing/browser/print_manager_utils.h" #include "components/printing/browser/print_manager_utils.h"
#include "components/printing/browser/print_composite_client.h" #include "components/printing/browser/print_composite_client.h"
#include "components/printing/common/print.mojom.h"
#include "components/printing/common/print_messages.h" #include "components/printing/common/print_messages.h"
#include "content/public/browser/site_isolation_policy.h" #include "content/public/browser/site_isolation_policy.h"
#include "printing/mojom/print.mojom.h" #include "printing/mojom/print.mojom.h"
...@@ -45,7 +46,7 @@ void CreateCompositeClientIfNeeded(content::WebContents* web_contents, ...@@ -45,7 +46,7 @@ void CreateCompositeClientIfNeeded(content::WebContents* web_contents,
} }
void RenderParamsFromPrintSettings(const PrintSettings& settings, void RenderParamsFromPrintSettings(const PrintSettings& settings,
PrintMsg_Print_Params* params) { mojom::PrintParams* params) {
params->page_size = settings.page_setup_device_units().physical_size(); params->page_size = settings.page_setup_device_units().physical_size();
params->content_size.SetSize( params->content_size.SetSize(
settings.page_setup_device_units().content_area().width(), settings.page_setup_device_units().content_area().width(),
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <string> #include <string>
struct PrintMsg_Print_Params; #include "components/printing/common/print.mojom-forward.h"
namespace content { namespace content {
class WebContents; class WebContents;
...@@ -24,10 +24,10 @@ bool IsOopifEnabled(); ...@@ -24,10 +24,10 @@ bool IsOopifEnabled();
void CreateCompositeClientIfNeeded(content::WebContents* web_contents, void CreateCompositeClientIfNeeded(content::WebContents* web_contents,
const std::string& user_agent); const std::string& user_agent);
// Converts given settings to Print_Params and stores them in the output // Converts given settings to PrintParams and stores them in the output
// parameter |params|. // parameter |params|.
void RenderParamsFromPrintSettings(const PrintSettings& settings, void RenderParamsFromPrintSettings(const PrintSettings& settings,
PrintMsg_Print_Params* params); mojom::PrintParams* params);
} // namespace printing } // namespace printing
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
module printing.mojom; module printing.mojom;
import "mojo/public/mojom/base/shared_memory.mojom"; import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/values.mojom"; import "mojo/public/mojom/base/values.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom"; import "mojo/public/mojom/base/unguessable_token.mojom";
import "printing/mojom/print.mojom"; import "printing/mojom/print.mojom";
...@@ -77,6 +78,67 @@ struct DidPreviewDocumentParams { ...@@ -77,6 +78,67 @@ struct DidPreviewDocumentParams {
uint32 expected_pages_count; uint32 expected_pages_count;
}; };
// Parameters for a render request.
struct PrintParams{
// Physical size of the page, including non-printable margins,
// in pixels according to dpi.
gfx.mojom.Size page_size;
// In pixels according to dpi.
gfx.mojom.Size content_size;
// Physical printable area of the page in pixels according to dpi.
gfx.mojom.Rect printable_area;
// The y-offset of the printable area, in pixels according to dpi.
int32 margin_top = 0;
// The x-offset of the printable area, in pixels according to dpi.
int32 margin_left = 0;
// Specifies the page orientation.
PageOrientation page_orientation = kUpright;
// Specifies dots per inch in the x and y direction.
gfx.mojom.Size dpi;
// Specifies the scale factor in percent
double scale_factor = 1.0;
// Cookie for the document to ensure correctness.
int32 document_cookie = 0;
// Should only print currently selected text.
bool selection_only = false;
// Does the printer support alpha blending?
bool supports_alpha_blend = false;
// *** Parameters below are used only for print preview. ***
// The print preview ui associated with this request.
int32 preview_ui_id = -1;
// The id of the preview request.
int32 preview_request_id = 0;
// True if this is the first preview request.
bool is_first_request = false;
// Specifies the page scaling option for preview printing.
PrintScalingOption print_scaling_option = kSourceSize;
// True if print to pdf is requested.
bool print_to_pdf = false;
// Specifies if the header and footer should be rendered.
bool display_header_footer = false;
// Title string to be printed as header if requested by the user.
mojo_base.mojom.String16 title;
// URL string to be printed as footer if requested by the user.
mojo_base.mojom.String16 url;
// HTML template to use as a print header.
mojo_base.mojom.String16 header_template;
// HTML template to use as a print footer.
mojo_base.mojom.String16 footer_template;
// Whether to rasterize a PDF for printing
bool rasterize_pdf = false;
// True if print backgrounds is requested by the user.
bool should_print_backgrounds = false;
// The document type of printed page(s) from render.
SkiaDocumentType printed_doc_type = kPDF;
// True if page size defined by css should be preferred.
bool prefer_css_page_size = false;
// Number of pages per sheet. This parameter is for N-up mode.
// Defaults to 1 if the feature is disabled, and some number greater
// than 1 otherwise. See printing::NupParameters for supported values.
uint32 pages_per_sheet = 1;
};
// Interface implemented by a class that desires to render print documents for // Interface implemented by a class that desires to render print documents for
// Chrome print preview. // Chrome print preview.
interface PrintRenderer { interface PrintRenderer {
......
...@@ -63,60 +63,6 @@ namespace IPC { ...@@ -63,60 +63,6 @@ namespace IPC {
#endif #endif
} // namespace IPC } // namespace IPC
PrintMsg_Print_Params::PrintMsg_Print_Params()
: margin_top(0),
margin_left(0),
page_orientation(printing::mojom::PageOrientation::kUpright),
scale_factor(1.0f),
rasterize_pdf(false),
document_cookie(0),
selection_only(false),
supports_alpha_blend(false),
preview_ui_id(-1),
preview_request_id(0),
is_first_request(false),
print_scaling_option(printing::mojom::PrintScalingOption::kSourceSize),
print_to_pdf(false),
display_header_footer(false),
should_print_backgrounds(false),
printed_doc_type(printing::mojom::SkiaDocumentType::kPDF),
prefer_css_page_size(false),
pages_per_sheet(1) {}
PrintMsg_Print_Params::PrintMsg_Print_Params(
const PrintMsg_Print_Params& other) = default;
PrintMsg_Print_Params::~PrintMsg_Print_Params() {}
void PrintMsg_Print_Params::Reset() {
page_size = gfx::Size();
content_size = gfx::Size();
printable_area = gfx::Rect();
margin_top = 0;
margin_left = 0;
page_orientation = printing::mojom::PageOrientation::kUpright;
dpi = gfx::Size();
scale_factor = 1.0f;
rasterize_pdf = false;
document_cookie = 0;
selection_only = false;
supports_alpha_blend = false;
preview_ui_id = -1;
preview_request_id = 0;
is_first_request = false;
print_scaling_option = printing::mojom::PrintScalingOption::kSourceSize;
print_to_pdf = false;
display_header_footer = false;
title = base::string16();
url = base::string16();
header_template = base::string16();
footer_template = base::string16();
should_print_backgrounds = false;
printed_doc_type = printing::mojom::SkiaDocumentType::kPDF;
prefer_css_page_size = false;
pages_per_sheet = 1;
}
PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params() {} PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params() {}
PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params( PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params(
...@@ -125,7 +71,7 @@ PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params( ...@@ -125,7 +71,7 @@ PrintMsg_PrintPages_Params::PrintMsg_PrintPages_Params(
PrintMsg_PrintPages_Params::~PrintMsg_PrintPages_Params() {} PrintMsg_PrintPages_Params::~PrintMsg_PrintPages_Params() {}
void PrintMsg_PrintPages_Params::Reset() { void PrintMsg_PrintPages_Params::Reset() {
params.Reset(); params = printing::mojom::PrintParams();
pages = std::vector<int>(); pages = std::vector<int>();
} }
......
...@@ -31,42 +31,6 @@ ...@@ -31,42 +31,6 @@
#ifndef INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_ #ifndef INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
#define INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_ #define INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
struct PrintMsg_Print_Params {
PrintMsg_Print_Params();
PrintMsg_Print_Params(const PrintMsg_Print_Params& other);
~PrintMsg_Print_Params();
// Resets the members of the struct to 0.
void Reset();
gfx::Size page_size;
gfx::Size content_size;
gfx::Rect printable_area;
int margin_top;
int margin_left;
printing::mojom::PageOrientation page_orientation;
gfx::Size dpi;
double scale_factor;
bool rasterize_pdf;
int document_cookie;
bool selection_only;
bool supports_alpha_blend;
int32_t preview_ui_id;
int preview_request_id;
bool is_first_request;
printing::mojom::PrintScalingOption print_scaling_option;
bool print_to_pdf;
bool display_header_footer;
base::string16 title;
base::string16 url;
base::string16 header_template;
base::string16 footer_template;
bool should_print_backgrounds;
printing::mojom::SkiaDocumentType printed_doc_type;
bool prefer_css_page_size;
int pages_per_sheet;
};
struct PrintMsg_PrintPages_Params { struct PrintMsg_PrintPages_Params {
PrintMsg_PrintPages_Params(); PrintMsg_PrintPages_Params();
PrintMsg_PrintPages_Params(const PrintMsg_PrintPages_Params& other); PrintMsg_PrintPages_Params(const PrintMsg_PrintPages_Params& other);
...@@ -75,7 +39,7 @@ struct PrintMsg_PrintPages_Params { ...@@ -75,7 +39,7 @@ struct PrintMsg_PrintPages_Params {
// Resets the members of the struct to 0. // Resets the members of the struct to 0.
void Reset(); void Reset();
PrintMsg_Print_Params params; printing::mojom::PrintParams params;
std::vector<int> pages; std::vector<int> pages;
}; };
...@@ -104,13 +68,15 @@ struct PrintHostMsg_PreviewIds { ...@@ -104,13 +68,15 @@ struct PrintHostMsg_PreviewIds {
#define IPC_MESSAGE_START PrintMsgStart #define IPC_MESSAGE_START PrintMsgStart
IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::PageOrientation,
printing::mojom::PageOrientation::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::PrintScalingOption, IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::PrintScalingOption,
printing::mojom::PrintScalingOption::kMaxValue) printing::mojom::PrintScalingOption::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::SkiaDocumentType, IPC_ENUM_TRAITS_MAX_VALUE(printing::mojom::SkiaDocumentType,
printing::mojom::SkiaDocumentType::kMaxValue) printing::mojom::SkiaDocumentType::kMaxValue)
// Parameters for a render request. // Parameters for a render request.
IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params) IPC_STRUCT_TRAITS_BEGIN(printing::mojom::PrintParams)
// Physical size of the page, including non-printable margins, // Physical size of the page, including non-printable margins,
// in pixels according to dpi. // in pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(page_size) IPC_STRUCT_TRAITS_MEMBER(page_size)
...@@ -127,6 +93,9 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params) ...@@ -127,6 +93,9 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params)
// The x-offset of the printable area, in pixels according to dpi. // The x-offset of the printable area, in pixels according to dpi.
IPC_STRUCT_TRAITS_MEMBER(margin_left) IPC_STRUCT_TRAITS_MEMBER(margin_left)
// Specifies the page orientation.
IPC_STRUCT_TRAITS_MEMBER(page_orientation)
// Specifies dots per inch in the x and y direction. // Specifies dots per inch in the x and y direction.
IPC_STRUCT_TRAITS_MEMBER(dpi) IPC_STRUCT_TRAITS_MEMBER(dpi)
...@@ -353,7 +322,7 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_AccessibilityTree, ...@@ -353,7 +322,7 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_AccessibilityTree,
// The renderer wants to know the default print settings. // The renderer wants to know the default print settings.
IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings, IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
PrintMsg_Print_Params /* default_settings */) printing::mojom::PrintParams /* default_settings */)
// The renderer wants to update the current print settings with new // The renderer wants to update the current print settings with new
// |job_settings|. // |job_settings|.
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "third_party/blink/public/web/web_print_params.h" #include "third_party/blink/public/web/web_print_params.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
struct PrintMsg_Print_Params;
struct PrintMsg_PrintPages_Params; struct PrintMsg_PrintPages_Params;
// RenderViewTest-based tests crash on Android // RenderViewTest-based tests crash on Android
...@@ -341,7 +340,7 @@ class PrintRenderFrameHelper ...@@ -341,7 +340,7 @@ class PrintRenderFrameHelper
const blink::WebNode& node); const blink::WebNode& node);
// Platform-specific helper function for rendering page(s) to |metafile|. // Platform-specific helper function for rendering page(s) to |metafile|.
void PrintPageInternal(const PrintMsg_Print_Params& params, void PrintPageInternal(const mojom::PrintParams& params,
int page_number, int page_number,
int page_count, int page_count,
double scale_factor, double scale_factor,
...@@ -373,7 +372,7 @@ class PrintRenderFrameHelper ...@@ -373,7 +372,7 @@ class PrintRenderFrameHelper
static void ComputePageLayoutInPointsForCss( static void ComputePageLayoutInPointsForCss(
blink::WebLocalFrame* frame, blink::WebLocalFrame* frame,
int page_index, int page_index,
const PrintMsg_Print_Params& default_params, const mojom::PrintParams& default_params,
bool ignore_css_margins, bool ignore_css_margins,
double* scale_factor, double* scale_factor,
mojom::PageSizeMargins* page_layout_in_points); mojom::PageSizeMargins* page_layout_in_points);
...@@ -393,7 +392,7 @@ class PrintRenderFrameHelper ...@@ -393,7 +392,7 @@ class PrintRenderFrameHelper
const blink::WebLocalFrame& source_frame, const blink::WebLocalFrame& source_frame,
float webkit_scale_factor, float webkit_scale_factor,
const mojom::PageSizeMargins& page_layout_in_points, const mojom::PageSizeMargins& page_layout_in_points,
const PrintMsg_Print_Params& params); const mojom::PrintParams& params);
// Script Initiated Printing ------------------------------------------------ // Script Initiated Printing ------------------------------------------------
......
...@@ -20,15 +20,14 @@ ...@@ -20,15 +20,14 @@
namespace printing { namespace printing {
void PrintRenderFrameHelper::PrintPageInternal( void PrintRenderFrameHelper::PrintPageInternal(const mojom::PrintParams& params,
const PrintMsg_Print_Params& params, int page_number,
int page_number, int page_count,
int page_count, double scale_factor,
double scale_factor, blink::WebLocalFrame* frame,
blink::WebLocalFrame* frame, MetafileSkia* metafile,
MetafileSkia* metafile, gfx::Size* page_size_in_dpi,
gfx::Size* page_size_in_dpi, gfx::Rect* content_rect_in_dpi) {
gfx::Rect* content_rect_in_dpi) {
double css_scale_factor = scale_factor; double css_scale_factor = scale_factor;
mojom::PageSizeMargins page_layout_in_points; mojom::PageSizeMargins page_layout_in_points;
ComputePageLayoutInPointsForCss(frame, page_number, params, ComputePageLayoutInPointsForCss(frame, page_number, params,
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/printing/common/print.mojom.h"
#include "components/printing/common/print_messages.h" #include "components/printing/common/print_messages.h"
#include "ipc/ipc_message_utils.h" #include "ipc/ipc_message_utils.h"
#include "printing/metafile_skia.h" #include "printing/metafile_skia.h"
...@@ -21,7 +22,9 @@ ...@@ -21,7 +22,9 @@
namespace { namespace {
void UpdateMargins(int margins_type, int dpi, PrintMsg_Print_Params* params) { void UpdateMargins(int margins_type,
int dpi,
printing::mojom::PrintParams* params) {
if (margins_type == printing::NO_MARGINS) { if (margins_type == printing::NO_MARGINS) {
params->content_size.SetSize(static_cast<int>((8.5 * dpi)), params->content_size.SetSize(static_cast<int>((8.5 * dpi)),
static_cast<int>((11.0 * dpi))); static_cast<int>((11.0 * dpi)));
...@@ -42,7 +45,7 @@ void UpdateMargins(int margins_type, int dpi, PrintMsg_Print_Params* params) { ...@@ -42,7 +45,7 @@ void UpdateMargins(int margins_type, int dpi, PrintMsg_Print_Params* params) {
void UpdatePageSizeAndScaling(const gfx::Size& page_size, void UpdatePageSizeAndScaling(const gfx::Size& page_size,
int scale_factor, int scale_factor,
PrintMsg_Print_Params* params) { printing::mojom::PrintParams* params) {
params->page_size = page_size; params->page_size = page_size;
params->scale_factor = static_cast<double>(scale_factor) / 100.0; params->scale_factor = static_cast<double>(scale_factor) / 100.0;
} }
...@@ -97,18 +100,20 @@ void MockPrinter::ResetPrinter() { ...@@ -97,18 +100,20 @@ void MockPrinter::ResetPrinter() {
document_cookie_ = -1; document_cookie_ = -1;
} }
void MockPrinter::GetDefaultPrintSettings(PrintMsg_Print_Params* params) { void MockPrinter::GetDefaultPrintSettings(
printing::mojom::PrintParams* params) {
// Verify this printer is not processing a job. // Verify this printer is not processing a job.
// Sorry, this mock printer is very fragile. // Sorry, this mock printer is very fragile.
EXPECT_EQ(-1, document_cookie_); EXPECT_EQ(-1, document_cookie_);
// Assign a unit document cookie and set the print settings. // Assign a unit document cookie and set the print settings.
document_cookie_ = CreateDocumentCookie(); document_cookie_ = CreateDocumentCookie();
params->Reset(); *params = printing::mojom::PrintParams();
SetPrintParams(params); SetPrintParams(params);
} }
void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { void MockPrinter::SetDefaultPrintSettings(
const printing::mojom::PrintParams& params) {
// Use the same logic as in printing/print_settings.h // Use the same logic as in printing/print_settings.h
dpi_ = std::max(params.dpi.width(), params.dpi.height()); dpi_ = std::max(params.dpi.width(), params.dpi.height());
selection_only_ = params.selection_only; selection_only_ = params.selection_only;
...@@ -125,7 +130,7 @@ void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) { ...@@ -125,7 +130,7 @@ void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) {
void MockPrinter::UseInvalidSettings() { void MockPrinter::UseInvalidSettings() {
use_invalid_settings_ = true; use_invalid_settings_ = true;
PrintMsg_Print_Params empty_param; printing::mojom::PrintParams empty_param;
SetDefaultPrintSettings(empty_param); SetDefaultPrintSettings(empty_param);
} }
...@@ -282,7 +287,7 @@ int MockPrinter::CreateDocumentCookie() { ...@@ -282,7 +287,7 @@ int MockPrinter::CreateDocumentCookie() {
return use_invalid_settings_ ? 0 : ++current_document_cookie_; return use_invalid_settings_ ? 0 : ++current_document_cookie_;
} }
void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) { void MockPrinter::SetPrintParams(printing::mojom::PrintParams* params) {
params->dpi = gfx::Size(dpi_, dpi_); params->dpi = gfx::Size(dpi_, dpi_);
params->selection_only = selection_only_; params->selection_only = selection_only_;
params->should_print_backgrounds = should_print_backgrounds_; params->should_print_backgrounds = should_print_backgrounds_;
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/printing/common/print.mojom-forward.h"
#include "printing/image.h" #include "printing/image.h"
#include "printing/mojom/print.mojom.h" #include "printing/mojom/print.mojom.h"
#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 PrintMsg_Print_Params;
struct PrintMsg_PrintPages_Params; struct PrintMsg_PrintPages_Params;
struct PrintHostMsg_DidPrintDocument_Params; struct PrintHostMsg_DidPrintDocument_Params;
...@@ -71,13 +71,13 @@ class MockPrinter { ...@@ -71,13 +71,13 @@ class MockPrinter {
// Functions that changes settings of a pseudo printer. // Functions that changes settings of a pseudo printer.
void ResetPrinter(); void ResetPrinter();
void SetDefaultPrintSettings(const PrintMsg_Print_Params& params); void SetDefaultPrintSettings(const printing::mojom::PrintParams& params);
void UseInvalidSettings(); void UseInvalidSettings();
void UseInvalidPageSize(); void UseInvalidPageSize();
void UseInvalidContentSize(); void UseInvalidContentSize();
// Functions that handles IPC events. // Functions that handles IPC events.
void GetDefaultPrintSettings(PrintMsg_Print_Params* params); void GetDefaultPrintSettings(printing::mojom::PrintParams* params);
void ScriptedPrint(int cookie, void ScriptedPrint(int cookie,
int expected_pages_count, int expected_pages_count,
bool has_selection, bool has_selection,
...@@ -112,7 +112,7 @@ class MockPrinter { ...@@ -112,7 +112,7 @@ class MockPrinter {
private: private:
// Helper function to fill the fields in |params|. // Helper function to fill the fields in |params|.
void SetPrintParams(PrintMsg_Print_Params* params); void SetPrintParams(printing::mojom::PrintParams* params);
// In pixels according to dpi_x and dpi_y. // In pixels according to dpi_x and dpi_y.
gfx::Size page_size_; gfx::Size page_size_;
......
...@@ -71,7 +71,7 @@ bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) { ...@@ -71,7 +71,7 @@ bool PrintMockRenderThread::OnMessageReceived(const IPC::Message& msg) {
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
void PrintMockRenderThread::OnGetDefaultPrintSettings( void PrintMockRenderThread::OnGetDefaultPrintSettings(
PrintMsg_Print_Params* params) { printing::mojom::PrintParams* params) {
printer_->GetDefaultPrintSettings(params); printer_->GetDefaultPrintSettings(params);
} }
......
...@@ -29,7 +29,6 @@ struct PrintHostMsg_DidPrintDocument_Params; ...@@ -29,7 +29,6 @@ struct PrintHostMsg_DidPrintDocument_Params;
struct PrintHostMsg_PreviewIds; struct PrintHostMsg_PreviewIds;
struct PrintHostMsg_ScriptedPrint_Params; struct PrintHostMsg_ScriptedPrint_Params;
struct PrintMsg_PrintPages_Params; struct PrintMsg_PrintPages_Params;
struct PrintMsg_Print_Params;
// Extends content::MockRenderThread to know about printing // Extends content::MockRenderThread to know about printing
class PrintMockRenderThread : public content::MockRenderThread { class PrintMockRenderThread : public content::MockRenderThread {
...@@ -70,7 +69,7 @@ class PrintMockRenderThread : public content::MockRenderThread { ...@@ -70,7 +69,7 @@ class PrintMockRenderThread : public content::MockRenderThread {
#if BUILDFLAG(ENABLE_PRINTING) #if BUILDFLAG(ENABLE_PRINTING)
// PrintRenderFrameHelper expects default print settings. // PrintRenderFrameHelper expects default print settings.
void OnGetDefaultPrintSettings(PrintMsg_Print_Params* setting); void OnGetDefaultPrintSettings(printing::mojom::PrintParams* setting);
// PrintRenderFrameHelper expects final print settings from the user. // PrintRenderFrameHelper expects final print settings from the user.
void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params, void OnScriptedPrint(const PrintHostMsg_ScriptedPrint_Params& params,
......
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