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

[printing] Convert PrintHostMsg_ShowInvalidPrinterSettingsError to Mojo

This CL converts PrintHostMsg_ShowInvalidPrinterSettingsError
message to ShowInvalidPrinterSettingsError() in
mojom::PrintManagerHost.

Bug: 1008939
Change-Id: I711f255d964ef3089de1b55e08b0b0bde38f9e63
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2374929Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatarEric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#804521}
parent a0917790
...@@ -379,7 +379,7 @@ void PrintViewManagerBase::OnScriptedPrint( ...@@ -379,7 +379,7 @@ void PrintViewManagerBase::OnScriptedPrint(
NOTREACHED() << "should be handled by printing:: PrintingMessageFilter"; NOTREACHED() << "should be handled by printing:: PrintingMessageFilter";
} }
void PrintViewManagerBase::OnShowInvalidPrinterSettingsError() { void PrintViewManagerBase::ShowInvalidPrinterSettingsError() {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&ShowWarningMessageBox, FROM_HERE, base::BindOnce(&ShowWarningMessageBox,
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
...@@ -429,18 +429,6 @@ void PrintViewManagerBase::SystemDialogCancelled() { ...@@ -429,18 +429,6 @@ void PrintViewManagerBase::SystemDialogCancelled() {
} }
#endif #endif
bool PrintViewManagerBase::OnMessageReceived(
const IPC::Message& message,
content::RenderFrameHost* render_frame_host) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBase, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
OnShowInvalidPrinterSettingsError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled || PrintManager::OnMessageReceived(message, render_frame_host);
}
void PrintViewManagerBase::Observe( void PrintViewManagerBase::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
......
...@@ -73,6 +73,7 @@ class PrintViewManagerBase : public content::NotificationObserver, ...@@ -73,6 +73,7 @@ class PrintViewManagerBase : public content::NotificationObserver,
// mojom::PrintManagerHost: // mojom::PrintManagerHost:
void DidGetPrintedPagesCount(int32_t cookie, int32_t number_pages) override; void DidGetPrintedPagesCount(int32_t cookie, int32_t number_pages) override;
void ShowInvalidPrinterSettingsError() override;
protected: protected:
explicit PrintViewManagerBase(content::WebContents* web_contents); explicit PrintViewManagerBase(content::WebContents* web_contents);
...@@ -88,8 +89,6 @@ class PrintViewManagerBase : public content::NotificationObserver, ...@@ -88,8 +89,6 @@ class PrintViewManagerBase : public content::NotificationObserver,
// content::WebContentsObserver implementation. // content::WebContentsObserver implementation.
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
bool OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* render_frame_host) override;
// Creates a new empty print job. It has no settings loaded. If there is // Creates a new empty print job. It has no settings loaded. If there is
// currently a print job, safely disconnect from it. Returns false if it is // currently a print job, safely disconnect from it. Returns false if it is
...@@ -128,8 +127,6 @@ class PrintViewManagerBase : public content::NotificationObserver, ...@@ -128,8 +127,6 @@ class PrintViewManagerBase : public content::NotificationObserver,
const mojom::ScriptedPrintParams& params, const mojom::ScriptedPrintParams& params,
IPC::Message* reply_msg) override; IPC::Message* reply_msg) override;
void OnShowInvalidPrinterSettingsError();
// IPC message handlers for service. // IPC message handlers for service.
void OnComposePdfDone(const gfx::Size& page_size, void OnComposePdfDone(const gfx::Size& page_size,
const gfx::Rect& content_area, const gfx::Rect& content_area,
......
...@@ -117,6 +117,8 @@ void PrintManager::DidGetDocumentCookie(int32_t cookie) { ...@@ -117,6 +117,8 @@ void PrintManager::DidGetDocumentCookie(int32_t cookie) {
void PrintManager::DidShowPrintDialog() {} void PrintManager::DidShowPrintDialog() {}
void PrintManager::ShowInvalidPrinterSettingsError() {}
void PrintManager::OnPrintingFailed(int cookie) { void PrintManager::OnPrintingFailed(int cookie) {
if (cookie != cookie_) { if (cookie != cookie_) {
NOTREACHED(); NOTREACHED();
......
...@@ -39,10 +39,11 @@ class PrintManager : public content::WebContentsObserver, ...@@ -39,10 +39,11 @@ class PrintManager : public content::WebContentsObserver,
virtual void PdfWritingDone(int page_count) = 0; virtual void PdfWritingDone(int page_count) = 0;
#endif #endif
// printing::mojom::PrintManager: // printing::mojom::PrintManagerHost:
void DidGetPrintedPagesCount(int32_t cookie, int32_t number_pages) override; void DidGetPrintedPagesCount(int32_t cookie, int32_t number_pages) override;
void DidGetDocumentCookie(int32_t cookie) override; void DidGetDocumentCookie(int32_t cookie) override;
void DidShowPrintDialog() override; void DidShowPrintDialog() override;
void ShowInvalidPrinterSettingsError() override;
protected: protected:
explicit PrintManager(content::WebContents* contents); explicit PrintManager(content::WebContents* contents);
......
...@@ -282,4 +282,7 @@ interface PrintManagerHost { ...@@ -282,4 +282,7 @@ interface PrintManagerHost {
// Tells the browser that the print dialog has been shown. // Tells the browser that the print dialog has been shown.
DidShowPrintDialog(); DidShowPrintDialog();
// Tells the browser that there are invalid printer settings.
ShowInvalidPrinterSettingsError();
}; };
...@@ -355,9 +355,6 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting, ...@@ -355,9 +355,6 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting,
printing::mojom::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.
IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
// Tell the browser printing failed. // Tell the browser printing failed.
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed, IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
int /* document cookie */) int /* document cookie */)
......
...@@ -2152,7 +2152,7 @@ bool PrintRenderFrameHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame, ...@@ -2152,7 +2152,7 @@ bool PrintRenderFrameHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame,
bool fit_to_paper_size = !IsPrintingNodeOrPdfFrame(frame, node); bool fit_to_paper_size = !IsPrintingNodeOrPdfFrame(frame, node);
if (!InitPrintSettings(fit_to_paper_size)) { if (!InitPrintSettings(fit_to_paper_size)) {
notify_browser_of_print_failure_ = false; notify_browser_of_print_failure_ = false;
Send(new PrintHostMsg_ShowInvalidPrinterSettingsError(routing_id())); GetPrintManagerHost()->ShowInvalidPrinterSettingsError();
return false; return false;
} }
......
...@@ -214,13 +214,7 @@ bool HeadlessPrintManager::OnMessageReceived( ...@@ -214,13 +214,7 @@ bool HeadlessPrintManager::OnMessageReceived(
return true; return true;
} }
bool handled = true; return PrintManager::OnMessageReceived(message, render_frame_host);
IPC_BEGIN_MESSAGE_MAP(HeadlessPrintManager, message)
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
OnShowInvalidPrinterSettingsError)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled || PrintManager::OnMessageReceived(message, render_frame_host);
} }
void HeadlessPrintManager::OnGetDefaultPrintSettings( void HeadlessPrintManager::OnGetDefaultPrintSettings(
...@@ -261,7 +255,7 @@ void HeadlessPrintManager::OnScriptedPrint( ...@@ -261,7 +255,7 @@ void HeadlessPrintManager::OnScriptedPrint(
} }
} }
void HeadlessPrintManager::OnShowInvalidPrinterSettingsError() { void HeadlessPrintManager::ShowInvalidPrinterSettingsError() {
ReleaseJob(INVALID_PRINTER_SETTINGS); ReleaseJob(INVALID_PRINTER_SETTINGS);
} }
......
...@@ -68,6 +68,9 @@ class HeadlessPrintManager ...@@ -68,6 +68,9 @@ class HeadlessPrintManager
~HeadlessPrintManager() override; ~HeadlessPrintManager() override;
// printing::mojom::PrintManagerHost:
void ShowInvalidPrinterSettingsError() override;
static std::string PrintResultToString(PrintResult result); static std::string PrintResultToString(PrintResult result);
// Exported for tests. // Exported for tests.
HEADLESS_EXPORT static PageRangeStatus PageRangeTextToPages( HEADLESS_EXPORT static PageRangeStatus PageRangeTextToPages(
...@@ -106,7 +109,6 @@ class HeadlessPrintManager ...@@ -106,7 +109,6 @@ class HeadlessPrintManager
const printing::mojom::ScriptedPrintParams& params, const printing::mojom::ScriptedPrintParams& params,
IPC::Message* reply_msg) override; IPC::Message* reply_msg) override;
void OnShowInvalidPrinterSettingsError();
void Reset(); void Reset();
void ReleaseJob(PrintResult result); void ReleaseJob(PrintResult result);
......
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