Commit ec9f86b2 authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Chromium LUCI CQ

[printing] Convert PrintHostMsg_ShowScriptedPrintPreview to Mojo

This CL converts PrintHostMsg_ShowScriptedPrintPreview message
to ShowScriptedPrintPreview() in mojom::PrintManagerHost.

Bug: 1008939
Change-Id: I28a6b7a9b21f7ce0b0dab1147946d39ac56cd69c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2569567Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarWei Li <weili@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#834548}
parent 23a9aa71
...@@ -295,13 +295,13 @@ void PrintViewManager::OnSetupScriptedPrintPreview( ...@@ -295,13 +295,13 @@ void PrintViewManager::OnSetupScriptedPrintPreview(
} }
} }
void PrintViewManager::OnShowScriptedPrintPreview(content::RenderFrameHost* rfh, void PrintViewManager::ShowScriptedPrintPreview(bool source_is_modifiable) {
bool source_is_modifiable) {
if (print_preview_state_ != SCRIPTED_PREVIEW) if (print_preview_state_ != SCRIPTED_PREVIEW)
return; return;
DCHECK(print_preview_rfh_); DCHECK(print_preview_rfh_);
if (rfh != print_preview_rfh_) if (print_manager_host_receivers_.GetCurrentTargetFrame() !=
print_preview_rfh_)
return; return;
PrintPreviewDialogController* dialog_controller = PrintPreviewDialogController* dialog_controller =
...@@ -337,8 +337,6 @@ bool PrintViewManager::OnMessageReceived( ...@@ -337,8 +337,6 @@ bool PrintViewManager::OnMessageReceived(
IPC_MESSAGE_FORWARD_DELAY_REPLY( IPC_MESSAGE_FORWARD_DELAY_REPLY(
PrintHostMsg_SetupScriptedPrintPreview, &helper, PrintHostMsg_SetupScriptedPrintPreview, &helper,
FrameDispatchHelper::OnSetupScriptedPrintPreview) FrameDispatchHelper::OnSetupScriptedPrintPreview)
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview,
OnShowScriptedPrintPreview)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
......
...@@ -64,6 +64,7 @@ class PrintViewManager : public PrintViewManagerBase, ...@@ -64,6 +64,7 @@ class PrintViewManager : public PrintViewManagerBase,
// mojom::PrintManagerHost: // mojom::PrintManagerHost:
void DidShowPrintDialog() override; void DidShowPrintDialog() override;
void ShowScriptedPrintPreview(bool source_is_modifiable) override;
// content::WebContentsObserver implementation. // content::WebContentsObserver implementation.
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
...@@ -100,8 +101,6 @@ class PrintViewManager : public PrintViewManagerBase, ...@@ -100,8 +101,6 @@ class PrintViewManager : public PrintViewManagerBase,
// IPC Message handlers. // IPC Message handlers.
void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh, void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh,
IPC::Message* reply_msg); IPC::Message* reply_msg);
void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh,
bool source_is_modifiable);
void OnScriptedPrintPreviewReply(IPC::Message* reply_msg); void OnScriptedPrintPreviewReply(IPC::Message* reply_msg);
void MaybeUnblockScriptedPreviewRPH(); void MaybeUnblockScriptedPreviewRPH();
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/printing/print_job.h" #include "chrome/browser/printing/print_job.h"
#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/print_view_manager_common.h" #include "chrome/browser/printing/print_view_manager_common.h"
#include "chrome/browser/printing/printer_query.h" #include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -64,6 +63,7 @@ ...@@ -64,6 +63,7 @@
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_error_dialog.h" #include "chrome/browser/printing/print_error_dialog.h"
#include "chrome/browser/printing/print_view_manager.h"
#endif #endif
namespace printing { namespace printing {
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/printer_query.h" #include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
......
...@@ -92,6 +92,10 @@ void PrintManager::PrintingFailed(int32_t cookie) { ...@@ -92,6 +92,10 @@ void PrintManager::PrintingFailed(int32_t cookie) {
#endif #endif
} }
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintManager::ShowScriptedPrintPreview(bool source_is_modifiable) {}
#endif
const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>& const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>&
PrintManager::GetPrintRenderFrame(content::RenderFrameHost* rfh) { PrintManager::GetPrintRenderFrame(content::RenderFrameHost* rfh) {
auto it = print_render_frames_.find(rfh); auto it = print_render_frames_.find(rfh);
......
...@@ -60,6 +60,9 @@ class PrintManager : public content::WebContentsObserver, ...@@ -60,6 +60,9 @@ class PrintManager : public content::WebContentsObserver,
void DidShowPrintDialog() override; void DidShowPrintDialog() override;
void ShowInvalidPrinterSettingsError() override; void ShowInvalidPrinterSettingsError() override;
void PrintingFailed(int32_t cookie) override; void PrintingFailed(int32_t cookie) override;
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void ShowScriptedPrintPreview(bool source_is_modifiable) override;
#endif
protected: protected:
explicit PrintManager(content::WebContents* contents); explicit PrintManager(content::WebContents* contents);
......
...@@ -313,4 +313,10 @@ interface PrintManagerHost { ...@@ -313,4 +313,10 @@ interface PrintManagerHost {
// Tells the browser printing failed. // Tells the browser printing failed.
PrintingFailed(int32 cookie); PrintingFailed(int32 cookie);
// Tells the browser to show the print preview, when the document is
// sufficiently loaded such that the renderer can determine whether it is
// modifiable or not.
[EnableIf=enable_print_preview]
ShowScriptedPrintPreview(bool is_modifiable);
}; };
...@@ -325,11 +325,6 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting, ...@@ -325,11 +325,6 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting,
// Run a nested run loop in the renderer until print preview for // Run a nested run loop in the renderer until print preview for
// window.print() finishes. // window.print() finishes.
IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview) IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)
// Tell the browser to show the print preview, when the document is sufficiently
// loaded such that the renderer can determine whether it is modifiable or not.
IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
bool /* is_modifiable */)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_ #endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
...@@ -2381,8 +2381,8 @@ void PrintRenderFrameHelper::PrintPageInternal(const mojom::PrintParams& params, ...@@ -2381,8 +2381,8 @@ void PrintRenderFrameHelper::PrintPageInternal(const mojom::PrintParams& params,
void PrintRenderFrameHelper::ShowScriptedPrintPreview() { void PrintRenderFrameHelper::ShowScriptedPrintPreview() {
if (is_scripted_preview_delayed_) { if (is_scripted_preview_delayed_) {
is_scripted_preview_delayed_ = false; is_scripted_preview_delayed_ = false;
Send(new PrintHostMsg_ShowScriptedPrintPreview( GetPrintManagerHost()->ShowScriptedPrintPreview(
routing_id(), print_preview_context_.IsModifiable())); print_preview_context_.IsModifiable());
} }
} }
...@@ -2414,8 +2414,8 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type) { ...@@ -2414,8 +2414,8 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type) {
// Shows scripted print preview in two stages. // Shows scripted print preview in two stages.
// 1. PrintHostMsg_SetupScriptedPrintPreview blocks this call and JS by // 1. PrintHostMsg_SetupScriptedPrintPreview blocks this call and JS by
// pumping messages here. // pumping messages here.
// 2. PrintHostMsg_ShowScriptedPrintPreview shows preview once the // 2. ShowScriptedPrintPreview() shows preview once the document has been
// document has been loaded. // loaded.
is_scripted_preview_delayed_ = true; is_scripted_preview_delayed_ = true;
if (is_loading_ && print_preview_context_.IsPlugin()) { if (is_loading_ && print_preview_context_.IsPlugin()) {
// Wait for DidStopLoading. Plugins may not know the correct // Wait for DidStopLoading. Plugins may not know the correct
......
...@@ -329,8 +329,10 @@ class TestPrintManagerHost ...@@ -329,8 +329,10 @@ class TestPrintManagerHost
params->params->should_print_backgrounds = should_print_backgrounds.value(); params->params->should_print_backgrounds = should_print_backgrounds.value();
std::move(callback).Run(std::move(params), canceled); std::move(callback).Run(std::move(params), canceled);
} }
void DidShowPrintDialog() override {} void DidShowPrintDialog() override {}
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void ShowScriptedPrintPreview(bool source_is_modifiable) override {}
#endif
bool IsPrinted() { return is_printed_; } bool IsPrinted() { return is_printed_; }
void SetExpectedPagesCount(uint32_t number_pages) { void SetExpectedPagesCount(uint32_t number_pages) {
......
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