summaryrefslogtreecommitdiffstats
path: root/src/core/printing
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/printing')
-rw-r--r--src/core/printing/print_view_manager_base_qt.cpp106
-rw-r--r--src/core/printing/print_view_manager_base_qt.h13
-rw-r--r--src/core/printing/print_view_manager_qt.cpp165
-rw-r--r--src/core/printing/print_view_manager_qt.h38
-rw-r--r--src/core/printing/printing_message_filter_qt.cpp131
-rw-r--r--src/core/printing/printing_message_filter_qt.h99
6 files changed, 161 insertions, 391 deletions
diff --git a/src/core/printing/print_view_manager_base_qt.cpp b/src/core/printing/print_view_manager_base_qt.cpp
index 3e740726a..9f745a9e0 100644
--- a/src/core/printing/print_view_manager_base_qt.cpp
+++ b/src/core/printing/print_view_manager_base_qt.cpp
@@ -60,7 +60,6 @@
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print.mojom.h"
-#include "components/printing/common/print_messages.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@@ -192,6 +191,75 @@ void UpdatePrintSettingsOnIO(int32_t cookie,
process_id, routing_id));
}
+// Runs |callback| with |params| to reply to
+// mojom::PrintManagerHost::ScriptedPrint.
+void ScriptedPrintReply(printing::mojom::PrintManagerHost::ScriptedPrintCallback callback,
+ printing::mojom::PrintPagesParamsPtr params,
+ int process_id)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ if (!content::RenderProcessHost::FromID(process_id)) {
+ // Early return if the renderer is not alive.
+ return;
+ }
+
+ if (!params) {
+ // Fills |params| with initial values.
+ params = printing::mojom::PrintPagesParams::New();
+ params->params = printing::mojom::PrintParams::New();
+ }
+ std::move(callback).Run(std::move(params));
+}
+
+void ScriptedPrintReplyOnIO(scoped_refptr<printing::PrintQueriesQueue> queue,
+ std::unique_ptr<printing::PrinterQuery> printer_query,
+ printing::mojom::PrintManagerHost::ScriptedPrintCallback callback,
+ int process_id)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ auto params = printing::mojom::PrintPagesParams::New();
+ params->params = printing::mojom::PrintParams::New();
+ if (printer_query->last_status() == printing::PrintingContext::OK &&
+ printer_query->settings().dpi()) {
+ RenderParamsFromPrintSettings(printer_query->settings(), params->params.get());
+ params->params->document_cookie = printer_query->cookie();
+ params->pages = printing::PageRange::GetPages(printer_query->settings().ranges());
+ }
+ bool has_valid_cookie = params->params->document_cookie;
+ bool has_dpi = !params->params->dpi.IsEmpty();
+ content::GetUIThreadTaskRunner({})->PostTask(
+ FROM_HERE, base::BindOnce(&ScriptedPrintReply, std::move(callback),
+ std::move(params), process_id));
+
+ if (has_dpi && has_valid_cookie) {
+ queue->QueuePrinterQuery(std::move(printer_query));
+ } else {
+ printer_query->StopWorker();
+ }
+}
+
+void ScriptedPrintOnIO(printing::mojom::ScriptedPrintParamsPtr params,
+ printing::mojom::PrintManagerHost::ScriptedPrintCallback callback,
+ scoped_refptr<printing::PrintQueriesQueue> queue,
+ int process_id,
+ int routing_id)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ std::unique_ptr<printing::PrinterQuery> printer_query = queue->PopPrinterQuery(params->cookie);
+ if (!printer_query)
+ printer_query = queue->CreatePrinterQuery(process_id, routing_id);
+
+ auto *printer_query_ptr = printer_query.get();
+ printer_query_ptr->GetSettings(
+ printing::PrinterQuery::GetSettingsAskParam::ASK_USER, params->expected_pages_count,
+ params->has_selection, params->margin_type, params->is_scripted,
+ params->is_modifiable,
+ base::BindOnce(&ScriptedPrintReplyOnIO, queue, std::move(printer_query),
+ std::move(callback), process_id));
+}
+
} // namespace
PrintViewManagerBaseQt::PrintViewManagerBaseQt(content::WebContents *contents)
@@ -272,18 +340,19 @@ bool PrintViewManagerBaseQt::PrintJobHasDocument(int cookie)
return document && document->cookie() == cookie;
}
-// IPC handlers
-void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*render_frame_host*/,
- const printing::mojom::DidPrintDocumentParams &params,
- std::unique_ptr<DelayedFrameDispatchHelper> helper)
+void PrintViewManagerBaseQt::DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params,
+ DidPrintDocumentCallback callback)
{
- if (!PrintJobHasDocument(params.document_cookie))
+ if (!PrintJobHasDocument(params->document_cookie)) {
+ std::move(callback).Run(false);
return;
+ }
- const printing::mojom::DidPrintContentParams &content = *params.content;
+ const printing::mojom::DidPrintContentParams &content = *params->content;
if (!content.metafile_data_region.IsValid()) {
NOTREACHED() << "invalid memory handle";
web_contents()->Stop();
+ std::move(callback).Run(false);
return;
}
@@ -291,13 +360,13 @@ void PrintViewManagerBaseQt::OnDidPrintDocument(content::RenderFrameHost* /*rend
if (!data) {
NOTREACHED() << "couldn't map";
web_contents()->Stop();
+ std::move(callback).Run(false);
return;
}
- PrintDocument(data, params.page_size, params.content_area,
- params.physical_offsets);
- if (helper)
- helper->SendCompleted();
+ PrintDocument(data, params->page_size, params->content_area,
+ params->physical_offsets);
+ std::move(callback).Run(true);
}
void PrintViewManagerBaseQt::GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback)
@@ -324,11 +393,18 @@ void PrintViewManagerBaseQt::PrintingFailed(int32_t cookie)
content::NotificationService::NoDetails());
}
-void PrintViewManagerBaseQt::OnScriptedPrint(content::RenderFrameHost *render_frame_host,
- const printing::mojom::ScriptedPrintParams &params,
- IPC::Message *reply_msg)
+void PrintViewManagerBaseQt::ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params,
+ printing::mojom::PrintManagerHost::ScriptedPrintCallback callback)
{
- NOTREACHED() << "should be handled by printing::PrintingMessageFilter";
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ content::RenderFrameHost *render_frame_host =
+ print_manager_host_receivers_.GetCurrentTargetFrame();
+
+ content::GetIOThreadTaskRunner({})->PostTask(
+ FROM_HERE,
+ base::BindOnce(&ScriptedPrintOnIO, std::move(params), std::move(callback),
+ m_printerQueriesQueue, render_frame_host->GetProcess()->GetID(),
+ render_frame_host->GetRoutingID()));
}
void PrintViewManagerBaseQt::ShowInvalidPrinterSettingsError()
diff --git a/src/core/printing/print_view_manager_base_qt.h b/src/core/printing/print_view_manager_base_qt.h
index 14adb928a..21069af67 100644
--- a/src/core/printing/print_view_manager_base_qt.h
+++ b/src/core/printing/print_view_manager_base_qt.h
@@ -81,9 +81,13 @@ public:
// mojom::PrintManagerHost:
void DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) override;
+ void DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params,
+ DidPrintDocumentCallback callback) override;
void GetDefaultPrintSettings(GetDefaultPrintSettingsCallback callback) override;
void UpdatePrintSettings(int32_t cookie, base::Value job_settings,
UpdatePrintSettingsCallback callback) override;
+ void ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr,
+ printing::mojom::PrintManagerHost::ScriptedPrintCallback) override;
void ShowInvalidPrinterSettingsError() override;
void PrintingFailed(int32_t cookie) override;
@@ -119,15 +123,6 @@ private:
// content::WebContentsObserver implementation.
void DidStartLoading() override;
- // printing::PrintManager:
- void OnDidPrintDocument(
- content::RenderFrameHost *render_frame_host,
- const printing::mojom::DidPrintDocumentParams &params,
- std::unique_ptr<DelayedFrameDispatchHelper> helper) override;
- void OnScriptedPrint(content::RenderFrameHost *render_frame_host,
- const printing::mojom::ScriptedPrintParams &params,
- IPC::Message *reply_msg) override;
-
// Processes a NOTIFY_PRINT_JOB_EVENT notification.
void OnNotifyPrintJobEvent(const printing::JobEventDetails &event_details);
diff --git a/src/core/printing/print_view_manager_qt.cpp b/src/core/printing/print_view_manager_qt.cpp
index 32e636e6d..3b66ad29d 100644
--- a/src/core/printing/print_view_manager_qt.cpp
+++ b/src/core/printing/print_view_manager_qt.cpp
@@ -59,7 +59,6 @@
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "components/printing/common/print.mojom.h"
-#include "components/printing/common/print_messages.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_task_traits.h"
@@ -202,19 +201,6 @@ static base::ListValue *createPageRangeSettings(const QList<QPageRanges::Range>
namespace QtWebEngineCore {
-struct PrintViewManagerQt::FrameDispatchHelper {
- PrintViewManagerQt* m_manager;
- content::RenderFrameHost* m_renderFrameHost;
-
- bool Send(IPC::Message* msg) {
- return m_renderFrameHost->Send(msg);
- }
-
- void OnSetupScriptedPrintPreview(IPC::Message* reply_msg) {
- m_manager->OnSetupScriptedPrintPreview(m_renderFrameHost, reply_msg);
- }
-};
-
PrintViewManagerQt::~PrintViewManagerQt()
{
}
@@ -303,51 +289,6 @@ PrintViewManagerQt::PrintViewManagerQt(content::WebContents *contents)
}
-// content::WebContentsObserver implementation.
-bool PrintViewManagerQt::OnMessageReceived(const IPC::Message& message,
- content::RenderFrameHost* render_frame_host)
-{
- FrameDispatchHelper helper = {this, render_frame_host};
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(PrintViewManagerQt, message, render_frame_host);
- IPC_MESSAGE_HANDLER(PrintHostMsg_RequestPrintPreview, OnRequestPrintPreview)
- IPC_MESSAGE_HANDLER(PrintHostMsg_MetafileReadyForPrinting, OnMetafileReadyForPrinting);
- IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage)
- IPC_MESSAGE_FORWARD_DELAY_REPLY(
- PrintHostMsg_SetupScriptedPrintPreview, &helper,
- FrameDispatchHelper::OnSetupScriptedPrintPreview)
- IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview,
- OnShowScriptedPrintPreview)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled || PrintViewManagerBaseQt::OnMessageReceived(message, render_frame_host);
-}
-
-void PrintViewManagerQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host)
-{
- if (render_frame_host == m_printPreviewRfh)
- PrintPreviewDone();
- PrintViewManagerBaseQt::RenderFrameDeleted(render_frame_host);
- m_printRenderFrames.erase(render_frame_host);
-}
-
-const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> &PrintViewManagerQt::GetPrintRenderFrame(content::RenderFrameHost *rfh)
-{
- auto it = m_printRenderFrames.find(rfh);
- if (it == m_printRenderFrames.end()) {
- mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> remote;
- rfh->GetRemoteAssociatedInterfaces()->GetInterface(&remote);
- it = m_printRenderFrames.insert(std::make_pair(rfh, std::move(remote))).first;
- } else if (it->second.is_bound() && !it->second.is_connected()) {
- // When print preview is closed, the remote is disconnected from the
- // receiver. Reset and bind the remote before using it again.
- it->second.reset();
- rfh->GetRemoteAssociatedInterfaces()->GetInterface(&it->second);
- }
-
- return it->second;
-}
-
void PrintViewManagerQt::resetPdfState()
{
m_pdfOutputPath.clear();
@@ -356,44 +297,11 @@ void PrintViewManagerQt::resetPdfState()
m_printSettings.reset();
}
-// IPC handlers
-
-void PrintViewManagerQt::OnRequestPrintPreview(
- const PrintHostMsg_RequestPrintPreview_Params & /*params*/)
-{
- mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> printRenderFrame;
- m_printPreviewRfh->GetRemoteAssociatedInterfaces()->GetInterface(&printRenderFrame);
- printRenderFrame->PrintPreview(m_printSettings->Clone());
- PrintPreviewDone();
-}
-
-void PrintViewManagerQt::OnMetafileReadyForPrinting(content::RenderFrameHost* rfh,
- const printing::mojom::DidPreviewDocumentParams& params,
- const printing::mojom::PreviewIds &ids)
-{
- StopWorker(params.document_cookie);
-
- // Create local copies so we can reset the state and take a new pdf print job.
- PrintToPDFCallback pdf_print_callback = std::move(m_pdfPrintCallback);
- PrintToPDFFileCallback pdf_save_callback = std::move(m_pdfSaveCallback);
- base::FilePath pdfOutputPath = m_pdfOutputPath;
-
- resetPdfState();
-
- if (!pdf_print_callback.is_null()) {
- QSharedPointer<QByteArray> data_array = GetStdVectorFromHandle(params.content->metafile_data_region);
- base::PostTask(FROM_HERE, {content::BrowserThread::UI},
- base::BindOnce(pdf_print_callback, data_array));
- } else {
- scoped_refptr<base::RefCountedBytes> data_bytes = GetBytesFromHandle(params.content->metafile_data_region);
- base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()},
- base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback));
- }
-}
-
-// content::WebContentsObserver implementation.
-void PrintViewManagerQt::DidStartLoading()
+void PrintViewManagerQt::PrintPreviewDone()
{
+ if (IsPrintRenderFrameConnected(m_printPreviewRfh))
+ GetPrintRenderFrame(m_printPreviewRfh)->OnPrintPreviewDialogClosed();
+ m_printPreviewRfh = nullptr;
}
// content::WebContentsObserver implementation.
@@ -418,40 +326,77 @@ void PrintViewManagerQt::RenderProcessGone(base::TerminationStatus status)
resetPdfState();
}
-void PrintViewManagerQt::OnDidPreviewPage(content::RenderFrameHost* rfh,
- const printing::mojom::DidPreviewPageParams &params,
- const printing::mojom::PreviewIds& ids)
+void PrintViewManagerQt::RenderFrameDeleted(content::RenderFrameHost *render_frame_host)
{
- // just consume the message, this is just for sending 'page-preview-ready' for webui
+ if (render_frame_host == m_printPreviewRfh)
+ PrintPreviewDone();
+ PrintViewManagerBaseQt::RenderFrameDeleted(render_frame_host);
}
-void PrintViewManagerQt::OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh,
- IPC::Message* reply_msg)
+// mojom::PrintManagerHost:
+void PrintViewManagerQt::SetupScriptedPrintPreview(SetupScriptedPrintPreviewCallback callback)
{
// ignore the scripted print
- rfh->Send(reply_msg);
+ std::move(callback).Run();
content::WebContentsView *view = static_cast<content::WebContentsImpl*>(web_contents())->GetView();
WebContentsAdapterClient *client = WebContentsViewQt::from(view)->client();
-
+ content::RenderFrameHost *rfh =
+ print_manager_host_receivers_.GetCurrentTargetFrame();
if (!client)
return;
// close preview
- GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed();
+ if (rfh)
+ GetPrintRenderFrame(rfh)->OnPrintPreviewDialogClosed();
client->printRequested();
}
-void PrintViewManagerQt::OnShowScriptedPrintPreview(content::RenderFrameHost* rfh,
- bool source_is_modifiable)
+void PrintViewManagerQt::ShowScriptedPrintPreview(bool /*source_is_modifiable*/)
{
// ignore for now
}
-void PrintViewManagerQt::PrintPreviewDone() {
- GetPrintRenderFrame(m_printPreviewRfh)->OnPrintPreviewDialogClosed();
- m_printPreviewRfh = nullptr;
+void PrintViewManagerQt::RequestPrintPreview(printing::mojom::RequestPrintPreviewParamsPtr /*params*/)
+{
+ mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> printRenderFrame;
+ m_printPreviewRfh->GetRemoteAssociatedInterfaces()->GetInterface(&printRenderFrame);
+ printRenderFrame->PrintPreview(m_printSettings->Clone());
+ PrintPreviewDone();
+}
+
+void PrintViewManagerQt::CheckForCancel(int32_t preview_ui_id,
+ int32_t request_id,
+ CheckForCancelCallback callback)
+{
+ Q_UNUSED(preview_ui_id);
+ Q_UNUSED(request_id);
+ std::move(callback).Run(false);
+}
+
+void PrintViewManagerQt::MetafileReadyForPrinting(printing::mojom::DidPreviewDocumentParamsPtr params,
+ int32_t preview_ui_id)
+{
+ Q_UNUSED(preview_ui_id);
+ StopWorker(params->document_cookie);
+
+ // Create local copies so we can reset the state and take a new pdf print job.
+ PrintToPDFCallback pdf_print_callback = std::move(m_pdfPrintCallback);
+ PrintToPDFFileCallback pdf_save_callback = std::move(m_pdfSaveCallback);
+ base::FilePath pdfOutputPath = m_pdfOutputPath;
+
+ resetPdfState();
+
+ if (!pdf_print_callback.is_null()) {
+ QSharedPointer<QByteArray> data_array = GetStdVectorFromHandle(params->content->metafile_data_region);
+ base::PostTask(FROM_HERE, {content::BrowserThread::UI},
+ base::BindOnce(pdf_print_callback, data_array));
+ } else {
+ scoped_refptr<base::RefCountedBytes> data_bytes = GetBytesFromHandle(params->content->metafile_data_region);
+ base::PostTask(FROM_HERE, {base::ThreadPool(), base::MayBlock()},
+ base::BindOnce(&SavePdfFile, data_bytes, pdfOutputPath, pdf_save_callback));
+ }
}
WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerQt)
diff --git a/src/core/printing/print_view_manager_qt.h b/src/core/printing/print_view_manager_qt.h
index 7405d95df..0496a9ba7 100644
--- a/src/core/printing/print_view_manager_qt.h
+++ b/src/core/printing/print_view_manager_qt.h
@@ -52,7 +52,6 @@
#include "base/strings/string16.h"
#include "components/prefs/pref_member.h"
#include "components/printing/common/print.mojom.h"
-#include "components/printing/common/print_messages.h"
#include "content/public/browser/web_contents_user_data.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
@@ -89,6 +88,8 @@ public:
protected:
explicit PrintViewManagerQt(content::WebContents*);
+ bool PrintToPDFInternal(const QPageLayout &, const QPageRanges &, bool printInColor, bool useCustomMargins = true);
+
// content::WebContentsObserver implementation.
// Cancels the print job.
void NavigationStopped() override;
@@ -96,35 +97,21 @@ protected:
// Terminates or cancels the print job if one was pending.
void RenderProcessGone(base::TerminationStatus status) override;
- // content::WebContentsObserver implementation.
- bool OnMessageReceived(const IPC::Message& message,
- content::RenderFrameHost* render_frame_host) override;
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
- // IPC handlers
- void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&);
- void OnMetafileReadyForPrinting(content::RenderFrameHost* rfh,
- const printing::mojom::DidPreviewDocumentParams& params,
- const printing::mojom::PreviewIds &ids);
- void OnSetupScriptedPrintPreview(content::RenderFrameHost* rfh,
- IPC::Message* reply_msg);
- void OnDidPreviewPage(content::RenderFrameHost* rfh,
- const printing::mojom::DidPreviewPageParams& params,
- const printing::mojom::PreviewIds& ids);
- void OnShowScriptedPrintPreview(content::RenderFrameHost* rfh,
- bool source_is_modifiable);
- bool PrintToPDFInternal(const QPageLayout &, const QPageRanges &,
- bool printInColor, bool useCustomMargins = true);
+ // mojom::PrintManagerHost:
+ void SetupScriptedPrintPreview(SetupScriptedPrintPreviewCallback callback) override;
+ void ShowScriptedPrintPreview(bool source_is_modifiable) override;
+ void RequestPrintPreview(printing::mojom::RequestPrintPreviewParamsPtr params) override;
+ void CheckForCancel(int32_t preview_ui_id,
+ int32_t request_id,
+ CheckForCancelCallback callback) override;
+ void MetafileReadyForPrinting(printing::mojom::DidPreviewDocumentParamsPtr params,
+ int32_t preview_ui_id) override;
private:
void resetPdfState();
- // Helper method to fetch the PrintRenderFrame associated remote interface
- // pointer.
- const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> &GetPrintRenderFrame(content::RenderFrameHost *rfh);
-
- // content::WebContentsObserver implementation.
- void DidStartLoading() override;
void PrintPreviewDone();
private:
@@ -135,11 +122,8 @@ private:
PrintToPDFFileCallback m_pdfSaveCallback;
std::unique_ptr<base::DictionaryValue> m_printSettings;
- std::map<content::RenderFrameHost*,mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>> m_printRenderFrames;
-
friend class content::WebContentsUserData<PrintViewManagerQt>;
DISALLOW_COPY_AND_ASSIGN(PrintViewManagerQt);
- struct FrameDispatchHelper;
};
} // namespace QtWebEngineCore
diff --git a/src/core/printing/printing_message_filter_qt.cpp b/src/core/printing/printing_message_filter_qt.cpp
deleted file mode 100644
index f31a8a6a8..000000000
--- a/src/core/printing/printing_message_filter_qt.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// Based on chrome/browser/printing/printing_message_filter.cc:
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE.Chromium file.
-
-#include "printing_message_filter_qt.h"
-
-#include "web_engine_context.h"
-
-#include "base/bind.h"
-#include "chrome/browser/printing/print_job_manager.h"
-#include "chrome/browser/printing/printer_query.h"
-#include "components/printing/browser/print_manager_utils.h"
-#include "components/printing/common/print_messages.h"
-
-namespace QtWebEngineCore {
-
-PrintingMessageFilterQt::PrintingMessageFilterQt(int render_process_id)
- : BrowserMessageFilter(PrintMsgStart),
- render_process_id_(render_process_id),
- queue_(WebEngineContext::current()->getPrintJobManager()->queue()) {
- DCHECK(queue_.get());
-}
-
-PrintingMessageFilterQt::~PrintingMessageFilterQt() {
-}
-
-void PrintingMessageFilterQt::OnDestruct() const
-{
- content::BrowserThread::DeleteOnUIThread::Destruct(this);
-}
-
-bool PrintingMessageFilterQt::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilterQt, message)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
- IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- return handled;
-}
-
-void PrintingMessageFilterQt::OnScriptedPrint(
- const printing::mojom::ScriptedPrintParams& params,
- IPC::Message* reply_msg) {
- std::unique_ptr<printing::PrinterQuery> printer_query =
- queue_->PopPrinterQuery(params.cookie);
- if (!printer_query.get()) {
- printer_query =
- queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id());
- }
- printer_query->GetSettings(
- printing::PrinterQuery::GetSettingsAskParam::ASK_USER,
- params.expected_pages_count,
- params.has_selection,
- params.margin_type,
- params.is_scripted,
- params.is_modifiable,
- base::BindOnce(&PrintingMessageFilterQt::OnScriptedPrintReply,
- this,
- std::move(printer_query),
- reply_msg));
-}
-
-void PrintingMessageFilterQt::OnScriptedPrintReply(
- std::unique_ptr<printing::PrinterQuery> printer_query,
- IPC::Message* reply_msg) {
- printing::mojom::PrintPagesParams params;
- params.params = printing::mojom::PrintParams::New();
- if (printer_query->last_status() != printing::PrintingContext::OK ||
- !printer_query->settings().dpi()) {
- params.params.reset();
- } else {
- RenderParamsFromPrintSettings(printer_query->settings(), params.params.get());
- params.params->document_cookie = printer_query->cookie();
- params.pages = printing::PageRange::GetPages(printer_query->settings().ranges());
- }
- PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params);
- Send(reply_msg);
- if (!params.params->dpi.IsEmpty() && params.params->document_cookie) {
- queue_->QueuePrinterQuery(std::move(printer_query));
- } else {
- printer_query->StopWorker();
- }
-}
-
-void PrintingMessageFilterQt::OnCheckForCancel(const printing::mojom::PreviewIds& ids,
- bool* cancel) {
- *cancel = false;
-}
-
-} // namespace QtWebEngineCore
diff --git a/src/core/printing/printing_message_filter_qt.h b/src/core/printing/printing_message_filter_qt.h
deleted file mode 100644
index 4597f7e6a..000000000
--- a/src/core/printing/printing_message_filter_qt.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE.Chromium file.
-
-#ifndef PRINTING_PRINTING_MESSAGE_FILTER_QT_H_
-#define PRINTING_PRINTING_MESSAGE_FILTER_QT_H_
-
-#include <string>
-
-#include "content/public/browser/browser_message_filter.h"
-
-namespace printing {
-namespace mojom {
-class ScriptedPrintParams;
-class PreviewIds;
-}
-class PrintQueriesQueue;
-class PrinterQuery;
-}
-
-namespace QtWebEngineCore {
-
-// This class filters out incoming printing related IPC messages for the
-// renderer process on the IPC thread.
-class PrintingMessageFilterQt : public content::BrowserMessageFilter {
- public:
- PrintingMessageFilterQt(int render_process_id);
-
- // content::BrowserMessageFilter methods.
- bool OnMessageReceived(const IPC::Message& message) override;
-
- private:
- friend class base::DeleteHelper<PrintingMessageFilterQt>;
- friend class content::BrowserThread;
-
- ~PrintingMessageFilterQt() override;
-
- void OnDestruct() const override;
-
- // The renderer host have to show to the user the print dialog and returns
- // the selected print settings. The task is handled by the print worker
- // thread and the UI thread. The reply occurs on the IO thread.
- void OnScriptedPrint(const printing::mojom::ScriptedPrintParams& params,
- IPC::Message* reply_msg);
- void OnScriptedPrintReply(std::unique_ptr<printing::PrinterQuery> printer_query,
- IPC::Message* reply_msg);
-
- // Check to see if print preview has been cancelled.
- void OnCheckForCancel(const printing::mojom::PreviewIds& ids, bool* cancel);
-
- const int render_process_id_;
-
- scoped_refptr<printing::PrintQueriesQueue> queue_;
-
- DISALLOW_COPY_AND_ASSIGN(PrintingMessageFilterQt);
-};
-
-} // namespace QtWebEngineCore
-
-#endif // PRINTING_PRINTING_MESSAGE_FILTER_QT_H_