|
@@ -1,5 +1,15 @@
|
|
|
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
+From: Heilig Benedek <[email protected]>
|
|
|
+Date: Thu, 18 Oct 2018 17:08:18 -0700
|
|
|
+Subject: printing.patch
|
|
|
+
|
|
|
+Add changeset that was previously applied to sources in chromium_src. The
|
|
|
+majority of changes originally come from these PRs:
|
|
|
+ * https://github.com/electron/electron/pull/1835
|
|
|
+ * https://github.com/electron/electron/pull/8596
|
|
|
+
|
|
|
diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc
|
|
|
-index 1065e808e621..13715870097b 100644
|
|
|
+index 1065e808e621c087bde9320abe019f05292f977c..13715870097b4f47ae164c12deb2bf783049ca6a 100644
|
|
|
--- a/chrome/browser/printing/print_job_worker.cc
|
|
|
+++ b/chrome/browser/printing/print_job_worker.cc
|
|
|
@@ -20,12 +20,13 @@
|
|
@@ -26,7 +36,7 @@ index 1065e808e621..13715870097b 100644
|
|
|
+ const base::string16& device_name) {
|
|
|
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
|
|
DCHECK_EQ(page_number_, PageNumber::npos());
|
|
|
-
|
|
|
+
|
|
|
@@ -200,6 +202,12 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
|
|
|
base::BindOnce(&PrintJobWorker::GetSettingsWithUI,
|
|
|
base::Unretained(this), document_page_count,
|
|
@@ -43,7 +53,7 @@ index 1065e808e621..13715870097b 100644
|
|
|
@@ -316,6 +324,14 @@ void PrintJobWorker::UseDefaultSettings() {
|
|
|
GetSettingsDone(result);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+void PrintJobWorker::InitWithDeviceName(const base::string16& device_name) {
|
|
|
+ const auto& settings = printing_context_->settings();
|
|
|
+ std::unique_ptr<base::DictionaryValue> dic(new base::DictionaryValue);
|
|
@@ -54,9 +64,9 @@ index 1065e808e621..13715870097b 100644
|
|
|
+
|
|
|
void PrintJobWorker::StartPrinting(PrintedDocument* new_document) {
|
|
|
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
|
|
-
|
|
|
+
|
|
|
diff --git a/chrome/browser/printing/print_job_worker.h b/chrome/browser/printing/print_job_worker.h
|
|
|
-index 182f7563e0c7..eed2230627d6 100644
|
|
|
+index 182f7563e0c7d6486a5d2843d86f66524c02cb10..eed2230627d6b35486081f628a2ee97895bf16cf 100644
|
|
|
--- a/chrome/browser/printing/print_job_worker.h
|
|
|
+++ b/chrome/browser/printing/print_job_worker.h
|
|
|
@@ -54,7 +54,8 @@ class PrintJobWorker {
|
|
@@ -66,21 +76,21 @@ index 182f7563e0c7..eed2230627d6 100644
|
|
|
- bool is_modifiable);
|
|
|
+ bool is_modifiable,
|
|
|
+ const base::string16& device_name);
|
|
|
-
|
|
|
+
|
|
|
// Set the new print settings from a dictionary value.
|
|
|
void SetSettings(std::unique_ptr<base::DictionaryValue> new_settings);
|
|
|
@@ -155,6 +156,9 @@ class PrintJobWorker {
|
|
|
// systems.
|
|
|
void UseDefaultSettings();
|
|
|
-
|
|
|
+
|
|
|
+ // set the printer name
|
|
|
+ void InitWithDeviceName(const base::string16& device_name);
|
|
|
+
|
|
|
// Printing context delegate.
|
|
|
const std::unique_ptr<PrintingContext::Delegate> printing_context_delegate_;
|
|
|
-
|
|
|
+
|
|
|
diff --git a/chrome/browser/printing/print_preview_message_handler.cc b/chrome/browser/printing/print_preview_message_handler.cc
|
|
|
-index e1613a9b52ad..db62078f2c08 100644
|
|
|
+index e1613a9b52ad65afc8290498e8d9877ec58a0a10..db62078f2c084bb20681f7ef5ccccbceafd4f0b1 100644
|
|
|
--- a/chrome/browser/printing/print_preview_message_handler.cc
|
|
|
+++ b/chrome/browser/printing/print_preview_message_handler.cc
|
|
|
@@ -57,7 +57,7 @@ void StopWorker(int document_cookie) {
|
|
@@ -97,11 +107,11 @@ index e1613a9b52ad..db62078f2c08 100644
|
|
|
std::move(shared_buf), data_size);
|
|
|
}
|
|
|
+#endif
|
|
|
-
|
|
|
+
|
|
|
} // namespace
|
|
|
-
|
|
|
+
|
|
|
@@ -81,7 +82,7 @@ PrintPreviewMessageHandler::PrintPreviewMessageHandler(
|
|
|
-
|
|
|
+
|
|
|
PrintPreviewMessageHandler::~PrintPreviewMessageHandler() {
|
|
|
}
|
|
|
-
|
|
@@ -114,7 +124,7 @@ index e1613a9b52ad..db62078f2c08 100644
|
|
|
}
|
|
|
}
|
|
|
+#endif
|
|
|
-
|
|
|
+
|
|
|
void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
|
|
|
content::RenderFrameHost* render_frame_host,
|
|
|
@@ -171,7 +173,8 @@ void PrintPreviewMessageHandler::OnMetafileReadyForPrinting(
|
|
@@ -146,7 +156,7 @@ index e1613a9b52ad..db62078f2c08 100644
|
|
|
@@ -318,15 +322,19 @@ void PrintPreviewMessageHandler::OnCompositePdfDocumentDone(
|
|
|
base::RefCountedSharedMemoryMapping::CreateFromWholeRegion(region));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+#endif
|
|
|
+
|
|
|
bool PrintPreviewMessageHandler::OnMessageReceived(
|
|
@@ -164,7 +174,7 @@ index e1613a9b52ad..db62078f2c08 100644
|
|
|
OnMetafileReadyForPrinting)
|
|
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
|
|
@@ -336,10 +344,13 @@ bool PrintPreviewMessageHandler::OnMessageReceived(
|
|
|
-
|
|
|
+
|
|
|
handled = true;
|
|
|
IPC_BEGIN_MESSAGE_MAP(PrintPreviewMessageHandler, message)
|
|
|
+#if 0
|
|
@@ -186,11 +196,11 @@ index e1613a9b52ad..db62078f2c08 100644
|
|
|
IPC_END_MESSAGE_MAP()
|
|
|
return handled;
|
|
|
diff --git a/chrome/browser/printing/print_preview_message_handler.h b/chrome/browser/printing/print_preview_message_handler.h
|
|
|
-index 6356792f29e8..5592de3c097f 100644
|
|
|
+index 6356792f29e82182c12118825949fe869cc80f9b..5592de3c097fd5d13fb0183fd3627cbb229d57b2 100644
|
|
|
--- a/chrome/browser/printing/print_preview_message_handler.h
|
|
|
+++ b/chrome/browser/printing/print_preview_message_handler.h
|
|
|
@@ -37,8 +37,7 @@ struct PageSizeMargins;
|
|
|
-
|
|
|
+
|
|
|
// Manages the print preview handling for a WebContents.
|
|
|
class PrintPreviewMessageHandler
|
|
|
- : public content::WebContentsObserver,
|
|
@@ -198,16 +208,16 @@ index 6356792f29e8..5592de3c097f 100644
|
|
|
+ : public content::WebContentsObserver {
|
|
|
public:
|
|
|
~PrintPreviewMessageHandler() override;
|
|
|
-
|
|
|
+
|
|
|
@@ -46,10 +45,11 @@ class PrintPreviewMessageHandler
|
|
|
bool OnMessageReceived(const IPC::Message& message,
|
|
|
content::RenderFrameHost* render_frame_host) override;
|
|
|
-
|
|
|
+
|
|
|
- private:
|
|
|
+ protected:
|
|
|
explicit PrintPreviewMessageHandler(content::WebContents* web_contents);
|
|
|
friend class content::WebContentsUserData<PrintPreviewMessageHandler>;
|
|
|
-
|
|
|
+
|
|
|
+#if 0
|
|
|
// Gets the print preview dialog associated with the WebContents being
|
|
|
// observed.
|
|
@@ -235,11 +245,11 @@ index 6356792f29e8..5592de3c097f 100644
|
|
|
mojom::PdfCompositor::Status status,
|
|
|
base::ReadOnlySharedMemoryRegion region);
|
|
|
+#endif
|
|
|
-
|
|
|
+
|
|
|
base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_;
|
|
|
-
|
|
|
+
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc
|
|
|
-index 9b0c15b3c501..388994072186 100644
|
|
|
+index 9b0c15b3c5016707788476295d53ab9d8a80e338..388994072186d1ba7b831f004983d5e087adf891 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_base.cc
|
|
|
+++ b/chrome/browser/printing/print_view_manager_base.cc
|
|
|
@@ -30,7 +30,7 @@
|
|
@@ -253,7 +263,7 @@ index 9b0c15b3c501..388994072186 100644
|
|
|
#include "components/printing/browser/print_manager_utils.h"
|
|
|
@@ -67,6 +67,8 @@ using PrintSettingsCallback =
|
|
|
base::OnceCallback<void(scoped_refptr<PrinterQuery>)>;
|
|
|
-
|
|
|
+
|
|
|
void ShowWarningMessageBox(const base::string16& message) {
|
|
|
+ LOG(ERROR) << "Invalid printer settings " << message;
|
|
|
+#if 0
|
|
@@ -262,11 +272,11 @@ index 9b0c15b3c501..388994072186 100644
|
|
|
if (is_dialog_shown)
|
|
|
@@ -75,6 +77,7 @@ void ShowWarningMessageBox(const base::string16& message) {
|
|
|
base::AutoReset<bool> auto_reset(&is_dialog_shown, true);
|
|
|
-
|
|
|
+
|
|
|
chrome::ShowWarningMessageBox(nullptr, base::string16(), message);
|
|
|
+#endif
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
@@ -112,12 +115,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
|
|
|
queue_(g_browser_process->print_job_manager()->queue()),
|
|
@@ -281,26 +291,26 @@ index 9b0c15b3c501..388994072186 100644
|
|
|
weak_ptr_factory_.GetWeakPtr()));
|
|
|
+#endif
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
PrintViewManagerBase::~PrintViewManagerBase() {
|
|
|
@@ -125,12 +130,16 @@ PrintViewManagerBase::~PrintViewManagerBase() {
|
|
|
DisconnectFromCurrentPrintJob();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
-bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh) {
|
|
|
+bool PrintViewManagerBase::PrintNow(content::RenderFrameHost* rfh,
|
|
|
+ bool silent,
|
|
|
+ bool print_background,
|
|
|
+ const base::string16& device_name) {
|
|
|
DisconnectFromCurrentPrintJob();
|
|
|
-
|
|
|
+
|
|
|
SetPrintingRFH(rfh);
|
|
|
int32_t id = rfh->GetRoutingID();
|
|
|
- return PrintNowInternal(rfh, std::make_unique<PrintMsg_PrintPages>(id));
|
|
|
+ return PrintNowInternal(rfh, std::make_unique<PrintMsg_PrintPages>(
|
|
|
+ id, silent, print_background, device_name));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
@@ -249,7 +258,7 @@ void PrintViewManagerBase::UpdatePrintingEnabled() {
|
|
|
// The Unretained() is safe because ForEachFrame() is synchronous.
|
|
@@ -309,38 +319,38 @@ index 9b0c15b3c501..388994072186 100644
|
|
|
- printing_enabled_.GetValue()));
|
|
|
+ true));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
void PrintViewManagerBase::NavigationStopped() {
|
|
|
@@ -341,8 +350,10 @@ void PrintViewManagerBase::OnDidPrintDocument(
|
|
|
void PrintViewManagerBase::OnPrintingFailed(int cookie) {
|
|
|
PrintManager::OnPrintingFailed(cookie);
|
|
|
-
|
|
|
+
|
|
|
+#if 0
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
ShowPrintErrorDialog();
|
|
|
+#endif
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
ReleasePrinterQuery();
|
|
|
@@ -592,6 +603,10 @@ void PrintViewManagerBase::ReleasePrintJob() {
|
|
|
content::RenderFrameHost* rfh = printing_rfh_;
|
|
|
printing_rfh_ = nullptr;
|
|
|
-
|
|
|
+
|
|
|
+ if (!callback.is_null()) {
|
|
|
+ callback.Run(printing_succeeded_ && print_job_);
|
|
|
+ }
|
|
|
+
|
|
|
if (!print_job_)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h
|
|
|
-index fe0e0b5b065c..6670fc8abd2d 100644
|
|
|
+index fe0e0b5b065cdcc4edd04665271db14b1bf935e3..6670fc8abd2dabe601581cf43e51bb59f5ce577f 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_base.h
|
|
|
+++ b/chrome/browser/printing/print_view_manager_base.h
|
|
|
@@ -7,6 +7,7 @@
|
|
|
-
|
|
|
+
|
|
|
#include <memory>
|
|
|
-
|
|
|
+
|
|
|
+#include "base/callback.h"
|
|
|
#include "base/macros.h"
|
|
|
#include "base/memory/read_only_shared_memory_region.h"
|
|
@@ -354,41 +364,41 @@ index fe0e0b5b065c..6670fc8abd2d 100644
|
|
|
+ bool silent,
|
|
|
+ bool print_background,
|
|
|
+ const base::string16& device_name);
|
|
|
-
|
|
|
+
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
// Prints the document in |print_data| with settings specified in
|
|
|
@@ -72,6 +76,8 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
|
|
-
|
|
|
+
|
|
|
base::string16 RenderSourceName();
|
|
|
-
|
|
|
+
|
|
|
+ void SetCallback(const base::Callback<void(bool)>& cb) { callback = cb; };
|
|
|
+
|
|
|
protected:
|
|
|
explicit PrintViewManagerBase(content::WebContents* web_contents);
|
|
|
-
|
|
|
+
|
|
|
@@ -208,6 +214,8 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
|
|
-
|
|
|
+
|
|
|
scoped_refptr<PrintQueriesQueue> queue_;
|
|
|
-
|
|
|
+
|
|
|
+ base::Callback<void(bool)> callback;
|
|
|
+
|
|
|
base::WeakPtrFactory<PrintViewManagerBase> weak_ptr_factory_;
|
|
|
-
|
|
|
+
|
|
|
DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBase);
|
|
|
diff --git a/chrome/browser/printing/print_view_manager_common.cc b/chrome/browser/printing/print_view_manager_common.cc
|
|
|
-index 3d36b0b972b6..3400f4a3470b 100644
|
|
|
+index 3d36b0b972b681c861c4e5273b3371eeabda1bce..3400f4a3470bda3ebf002417837592a12be4d55a 100644
|
|
|
--- a/chrome/browser/printing/print_view_manager_common.cc
|
|
|
+++ b/chrome/browser/printing/print_view_manager_common.cc
|
|
|
@@ -11,12 +11,12 @@
|
|
|
#include "printing/buildflags/buildflags.h"
|
|
|
#include "url/gurl.h"
|
|
|
-
|
|
|
+
|
|
|
-#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
+#if 0
|
|
|
#include "components/guest_view/browser/guest_view_manager.h"
|
|
|
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
|
|
|
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
-
|
|
|
+
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
+#if 0
|
|
|
#include "chrome/browser/printing/print_view_manager.h"
|
|
@@ -396,7 +406,7 @@ index 3d36b0b972b6..3400f4a3470b 100644
|
|
|
#include "chrome/browser/printing/print_view_manager_basic.h"
|
|
|
@@ -25,7 +25,7 @@
|
|
|
namespace printing {
|
|
|
-
|
|
|
+
|
|
|
namespace {
|
|
|
-#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
+#if 0
|
|
@@ -435,26 +445,26 @@ index 3d36b0b972b6..3400f4a3470b 100644
|
|
|
}
|
|
|
#endif // ENABLE_PRINT_PREVIEW
|
|
|
+#endif
|
|
|
-
|
|
|
+
|
|
|
- print_view_manager->PrintNow(rfh_to_use);
|
|
|
+ print_view_manager->PrintNow(rfh_to_use, false, true, base::string16());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
void StartBasicPrint(content::WebContents* contents) {
|
|
|
+#if 0
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
content::WebContents* contents_to_use = GetWebContentsToUse(contents);
|
|
|
PrintViewManager* print_view_manager =
|
|
|
@@ -111,6 +114,7 @@ void StartBasicPrint(content::WebContents* contents) {
|
|
|
-
|
|
|
+
|
|
|
print_view_manager->BasicPrint(rfh_to_use);
|
|
|
#endif // ENABLE_PRINT_PREVIEW
|
|
|
+#endif
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
content::RenderFrameHost* GetFrameToPrint(content::WebContents* contents) {
|
|
|
diff --git a/chrome/browser/printing/printer_query.cc b/chrome/browser/printing/printer_query.cc
|
|
|
-index cc2368731367..159ec3a04502 100644
|
|
|
+index cc236873136797d90f3f5132726b34e7a3d7a989..159ec3a04502a4462bafbe31e39f58c6104c7e11 100644
|
|
|
--- a/chrome/browser/printing/printer_query.cc
|
|
|
+++ b/chrome/browser/printing/printer_query.cc
|
|
|
@@ -94,7 +94,31 @@ void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
|
|
@@ -488,16 +498,16 @@ index cc2368731367..159ec3a04502 100644
|
|
|
+ has_selection, margin_type, is_scripted, is_modifiable,
|
|
|
+ device_name));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
void PrinterQuery::SetSettings(
|
|
|
diff --git a/chrome/browser/printing/printer_query.h b/chrome/browser/printing/printer_query.h
|
|
|
-index 64db84f9f853..0e12adfe7957 100644
|
|
|
+index 64db84f9f8532e2e53c07206f6d1505cc162df58..0e12adfe7957b071a71e377861a2ea0cf1a57b5e 100644
|
|
|
--- a/chrome/browser/printing/printer_query.h
|
|
|
+++ b/chrome/browser/printing/printer_query.h
|
|
|
@@ -59,6 +59,15 @@ class PrinterQuery : public base::RefCountedThreadSafe<PrinterQuery> {
|
|
|
bool is_modifiable,
|
|
|
base::OnceClosure callback);
|
|
|
-
|
|
|
+
|
|
|
+ void GetSettings(GetSettingsAskParam ask_user_for_settings,
|
|
|
+ int expected_page_count,
|
|
|
+ bool has_selection,
|
|
@@ -511,13 +521,13 @@ index 64db84f9f853..0e12adfe7957 100644
|
|
|
virtual void SetSettings(std::unique_ptr<base::DictionaryValue> new_settings,
|
|
|
base::OnceClosure callback);
|
|
|
diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc
|
|
|
-index 54866fdcdb64..40d6bd62706c 100644
|
|
|
+index 54866fdcdb64f4ffd2414c8637ffa2f8fb10c024..40d6bd62706c1b47aff9ce32df713a47d203538f 100644
|
|
|
--- a/chrome/browser/printing/printing_message_filter.cc
|
|
|
+++ b/chrome/browser/printing/printing_message_filter.cc
|
|
|
@@ -94,12 +94,12 @@ PrintViewManager* GetPrintViewManager(int render_process_id,
|
|
|
-
|
|
|
+
|
|
|
} // namespace
|
|
|
-
|
|
|
+
|
|
|
-PrintingMessageFilter::PrintingMessageFilter(int render_process_id,
|
|
|
- Profile* profile)
|
|
|
+PrintingMessageFilter::PrintingMessageFilter(int render_process_id)
|
|
@@ -535,10 +545,10 @@ index 54866fdcdb64..40d6bd62706c 100644
|
|
|
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
|
|
|
+#endif
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
PrintingMessageFilter::~PrintingMessageFilter() {
|
|
|
@@ -116,7 +117,9 @@ PrintingMessageFilter::~PrintingMessageFilter() {
|
|
|
-
|
|
|
+
|
|
|
void PrintingMessageFilter::ShutdownOnUIThread() {
|
|
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
+#if 0
|
|
@@ -546,7 +556,7 @@ index 54866fdcdb64..40d6bd62706c 100644
|
|
|
+#endif
|
|
|
printing_shutdown_notifier_.reset();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@@ -145,6 +148,8 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
|
|
#endif
|
|
|
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings,
|
|
@@ -568,7 +578,7 @@ index 54866fdcdb64..40d6bd62706c 100644
|
|
|
@@ -208,6 +213,26 @@ void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {
|
|
|
printer_query, reply_msg));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+void PrintingMessageFilter::OnInitSettingWithDeviceName(
|
|
|
+ const base::string16& device_name,
|
|
|
+ IPC::Message* reply_msg) {
|
|
@@ -594,7 +604,7 @@ index 54866fdcdb64..40d6bd62706c 100644
|
|
|
IPC::Message* reply_msg) {
|
|
|
@@ -301,7 +326,7 @@ void PrintingMessageFilter::OnUpdatePrintSettings(
|
|
|
std::unique_ptr<base::DictionaryValue> new_settings(job_settings.DeepCopy());
|
|
|
-
|
|
|
+
|
|
|
scoped_refptr<PrinterQuery> printer_query;
|
|
|
- if (!is_printing_enabled_.GetValue()) {
|
|
|
+ if (false) {
|
|
@@ -604,7 +614,7 @@ index 54866fdcdb64..40d6bd62706c 100644
|
|
|
@@ -361,10 +386,13 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply(
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
void PrintingMessageFilter::OnCheckForCancel(const PrintHostMsg_PreviewIds& ids,
|
|
@@ -614,9 +624,9 @@ index 54866fdcdb64..40d6bd62706c 100644
|
|
|
+#endif
|
|
|
}
|
|
|
#endif
|
|
|
-
|
|
|
+
|
|
|
diff --git a/chrome/browser/printing/printing_message_filter.h b/chrome/browser/printing/printing_message_filter.h
|
|
|
-index a881a853bfb0..46ebeede1955 100644
|
|
|
+index a881a853bfb0b46d0e074b7e86121429a5a761a3..46ebeede19557c718bf14b7feb81cf1acf3ca00a 100644
|
|
|
--- a/chrome/browser/printing/printing_message_filter.h
|
|
|
+++ b/chrome/browser/printing/printing_message_filter.h
|
|
|
@@ -38,7 +38,7 @@ class PrinterQuery;
|
|
@@ -625,11 +635,11 @@ index a881a853bfb0..46ebeede1955 100644
|
|
|
public:
|
|
|
- PrintingMessageFilter(int render_process_id, Profile* profile);
|
|
|
+ PrintingMessageFilter(int render_process_id);
|
|
|
-
|
|
|
+
|
|
|
// content::BrowserMessageFilter methods.
|
|
|
void OverrideThreadForMessage(const IPC::Message& message,
|
|
|
@@ -73,6 +73,11 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
|
|
|
-
|
|
|
+
|
|
|
// Get the default print setting.
|
|
|
void OnGetDefaultPrintSettings(IPC::Message* reply_msg);
|
|
|
+
|
|
@@ -639,15 +649,15 @@ index a881a853bfb0..46ebeede1955 100644
|
|
|
+
|
|
|
void OnGetDefaultPrintSettingsReply(scoped_refptr<PrinterQuery> printer_query,
|
|
|
IPC::Message* reply_msg);
|
|
|
-
|
|
|
+
|
|
|
diff --git a/chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc b/chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
|
|
|
-index 38fd116aa096..62fcfaa00084 100644
|
|
|
+index 38fd116aa096b00266b6015f3196c3f432d23a9e..62fcfaa00084332ba07ff123e5136df606bb8168 100644
|
|
|
--- a/chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
|
|
|
+++ b/chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
|
|
|
@@ -19,7 +19,7 @@
|
|
|
#include "third_party/blink/public/web/web_element.h"
|
|
|
#include "third_party/blink/public/web/web_local_frame.h"
|
|
|
-
|
|
|
+
|
|
|
-#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
+#if 0
|
|
|
#include "chrome/common/extensions/extension_constants.h"
|
|
@@ -663,16 +673,16 @@ index 38fd116aa096..62fcfaa00084 100644
|
|
|
bool inside_print_preview = url.GetOrigin() == chrome::kChromeUIPrintURL;
|
|
|
bool inside_pdf_extension =
|
|
|
@@ -71,7 +71,7 @@ bool ChromePrintRenderFrameHelperDelegate::IsPrintPreviewEnabled() {
|
|
|
-
|
|
|
+
|
|
|
bool ChromePrintRenderFrameHelperDelegate::OverridePrint(
|
|
|
blink::WebLocalFrame* frame) {
|
|
|
-#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
+#if 0
|
|
|
if (!frame->GetDocument().IsPluginDocument())
|
|
|
return false;
|
|
|
-
|
|
|
+
|
|
|
diff --git a/components/printing/common/print_messages.h b/components/printing/common/print_messages.h
|
|
|
-index d29bb6aedecd..bb0bd7bfa494 100644
|
|
|
+index d29bb6aedecd228e4bc02c84b86cce7151f33746..bb0bd7bfa494f813c30b47e84b78d2e0a951a321 100644
|
|
|
--- a/components/printing/common/print_messages.h
|
|
|
+++ b/components/printing/common/print_messages.h
|
|
|
@@ -367,7 +367,10 @@ IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
|
|
@@ -684,13 +694,13 @@ index d29bb6aedecd..bb0bd7bfa494 100644
|
|
|
+ bool /* silent print */,
|
|
|
+ bool /* print page's background */,
|
|
|
+ base::string16 /* device name*/)
|
|
|
-
|
|
|
+
|
|
|
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
|
|
|
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
|
|
|
@@ -425,6 +428,11 @@ IPC_MESSAGE_ROUTED2(PrintHostMsg_DidPrintFrameContent,
|
|
|
IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
|
|
|
PrintMsg_Print_Params /* default_settings */)
|
|
|
-
|
|
|
+
|
|
|
+// you can set the printer
|
|
|
+IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_InitSettingWithDeviceName,
|
|
|
+ base::string16, /* device name */
|
|
@@ -700,20 +710,20 @@ index d29bb6aedecd..bb0bd7bfa494 100644
|
|
|
// |job_settings|.
|
|
|
IPC_SYNC_MESSAGE_ROUTED2_2(PrintHostMsg_UpdatePrintSettings,
|
|
|
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
|
|
|
-index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
+index c7ea5cf76aa629b8feaf99ff6e289140de1d35bd..1c3177e679ff6a3bbaa10cf74b9d538af7e5a588 100644
|
|
|
--- a/components/printing/renderer/print_render_frame_helper.cc
|
|
|
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
|
|
@@ -1093,7 +1093,9 @@ void PrintRenderFrameHelper::OnDestruct() {
|
|
|
delete this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
-void PrintRenderFrameHelper::OnPrintPages() {
|
|
|
+void PrintRenderFrameHelper::OnPrintPages(bool silent,
|
|
|
+ bool print_background,
|
|
|
+ const base::string16& device_name) {
|
|
|
if (ipc_nesting_level_ > 1)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
@@ -1106,7 +1108,7 @@ void PrintRenderFrameHelper::OnPrintPages() {
|
|
|
// If we are printing a PDF extension frame, find the plugin node and print
|
|
|
// that instead.
|
|
@@ -726,14 +736,14 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
@@ -1158,6 +1160,8 @@ void PrintRenderFrameHelper::OnPrintPreview(
|
|
|
if (ipc_nesting_level_ > 1)
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
+ blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
|
|
|
+ print_preview_context_.InitWithFrame(frame);
|
|
|
print_preview_context_.OnPrintPreview();
|
|
|
-
|
|
|
+
|
|
|
UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent",
|
|
|
@@ -1552,7 +1556,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
|
|
-
|
|
|
+
|
|
|
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
const blink::WebNode& node,
|
|
|
- bool is_scripted) {
|
|
@@ -746,7 +756,7 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
return;
|
|
|
@@ -1560,7 +1567,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
FrameReference frame_ref(frame);
|
|
|
-
|
|
|
+
|
|
|
int expected_page_count = 0;
|
|
|
- if (!CalculateNumberOfPages(frame, node, &expected_page_count)) {
|
|
|
+ if (!CalculateNumberOfPages(frame, node, &expected_page_count, device_name)) {
|
|
@@ -754,7 +764,7 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
return; // Failed to init print page settings.
|
|
|
}
|
|
|
@@ -1580,8 +1587,9 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
-
|
|
|
+
|
|
|
PrintMsg_PrintPages_Params print_settings;
|
|
|
auto self = weak_ptr_factory_.GetWeakPtr();
|
|
|
- GetPrintSettingsFromUser(frame_ref.GetFrame(), node, expected_page_count,
|
|
@@ -774,7 +784,7 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
!print_settings.params.document_cookie) {
|
|
|
DidFinishPrinting(OK); // Release resources and fail silently on failure.
|
|
|
@@ -1600,7 +1609,6 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
|
|
-
|
|
|
+
|
|
|
// Render Pages for printing.
|
|
|
if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) {
|
|
|
- LOG(ERROR) << "RenderPagesForPrint failed";
|
|
@@ -784,7 +794,7 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
@@ -1778,10 +1786,17 @@ std::vector<int> PrintRenderFrameHelper::GetPrintedPages(
|
|
|
return printed_pages;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
-bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
|
|
|
+bool PrintRenderFrameHelper::InitPrintSettings(
|
|
|
+ bool fit_to_paper_size,
|
|
@@ -801,7 +811,7 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
// can safely assume there are no printer drivers configured. So we safely
|
|
|
// terminate.
|
|
|
@@ -1803,10 +1818,11 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) {
|
|
|
-
|
|
|
+
|
|
|
bool PrintRenderFrameHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame,
|
|
|
const blink::WebNode& node,
|
|
|
- int* number_of_pages) {
|
|
@@ -817,7 +827,7 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
@@ -1885,11 +1901,13 @@ bool PrintRenderFrameHelper::UpdatePrintSettings(
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+#if 0
|
|
|
if (!job_settings->GetInteger(kPreviewUIID, &settings.params.preview_ui_id)) {
|
|
|
NOTREACHED();
|
|
@@ -825,16 +835,16 @@ index c7ea5cf76aa6..1c3177e679ff 100644
|
|
|
return false;
|
|
|
}
|
|
|
+#endif
|
|
|
-
|
|
|
+
|
|
|
// Validate expected print preview settings.
|
|
|
if (!job_settings->GetInteger(kPreviewRequestID,
|
|
|
diff --git a/components/printing/renderer/print_render_frame_helper.h b/components/printing/renderer/print_render_frame_helper.h
|
|
|
-index 6e2d7e1467b7..0e6e8ea770f5 100644
|
|
|
+index 6e2d7e1467b7bc179b1a0fc30dd656de612708cb..0e6e8ea770f52e5ddfb9f3e2d5793ad8184e8359 100644
|
|
|
--- a/components/printing/renderer/print_render_frame_helper.h
|
|
|
+++ b/components/printing/renderer/print_render_frame_helper.h
|
|
|
@@ -186,7 +186,9 @@ class PrintRenderFrameHelper
|
|
|
bool OnMessageReceived(const IPC::Message& message) override;
|
|
|
-
|
|
|
+
|
|
|
// Message handlers ---------------------------------------------------------
|
|
|
- void OnPrintPages();
|
|
|
+ void OnPrintPages(bool silent,
|
|
@@ -852,17 +862,17 @@ index 6e2d7e1467b7..0e6e8ea770f5 100644
|
|
|
+ bool silent = false,
|
|
|
+ bool print_background = false,
|
|
|
+ const base::string16& device_name = base::string16());
|
|
|
-
|
|
|
+
|
|
|
// Notification when printing is done - signal tear-down/free resources.
|
|
|
void DidFinishPrinting(PrintingResult result);
|
|
|
@@ -247,12 +252,15 @@ class PrintRenderFrameHelper
|
|
|
-
|
|
|
+
|
|
|
// Initialize print page settings with default settings.
|
|
|
// Used only for native printing workflow.
|
|
|
- bool InitPrintSettings(bool fit_to_paper_size);
|
|
|
+ bool InitPrintSettings(bool fit_to_paper_size,
|
|
|
+ const base::string16& device_name = base::string16());
|
|
|
-
|
|
|
+
|
|
|
// Calculate number of pages in source document.
|
|
|
- bool CalculateNumberOfPages(blink::WebLocalFrame* frame,
|
|
|
- const blink::WebNode& node,
|
|
@@ -872,17 +882,17 @@ index 6e2d7e1467b7..0e6e8ea770f5 100644
|
|
|
+ const blink::WebNode& node,
|
|
|
+ int* number_of_pages,
|
|
|
+ const base::string16& device_name = base::string16());
|
|
|
-
|
|
|
+
|
|
|
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
// Set options for print preset from source PDF document.
|
|
|
diff --git a/printing/print_settings_conversion.cc b/printing/print_settings_conversion.cc
|
|
|
-index a4c9f49d65e0..b26eb4186880 100644
|
|
|
+index a4c9f49d65e0f6bccee7d49465cbba5a28785a22..b26eb4186880d869bd7466d1ad7f368aeefb175d 100644
|
|
|
--- a/printing/print_settings_conversion.cc
|
|
|
+++ b/printing/print_settings_conversion.cc
|
|
|
@@ -42,6 +42,19 @@ void GetCustomMarginsFromJobSettings(const base::DictionaryValue& settings,
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+void SetCustomMarginsToJobSettings(const PageSizeMargins& page_size_margins,
|
|
|
+ base::DictionaryValue* settings) {
|
|
|
+ std::unique_ptr<base::DictionaryValue> custom_margins(
|
|
@@ -902,7 +912,7 @@ index a4c9f49d65e0..b26eb4186880 100644
|
|
|
@@ -224,6 +237,72 @@ bool PrintSettingsFromJobSettings(const base::DictionaryValue& job_settings,
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+void PrintSettingsToJobSettings(const PrintSettings& settings,
|
|
|
+ base::DictionaryValue* job_settings) {
|
|
|
+ // header footer
|
|
@@ -973,13 +983,13 @@ index a4c9f49d65e0..b26eb4186880 100644
|
|
|
base::DictionaryValue* job_settings) {
|
|
|
job_settings->SetBoolean(kSettingHeaderFooterEnabled,
|
|
|
diff --git a/printing/print_settings_conversion.h b/printing/print_settings_conversion.h
|
|
|
-index 283c0ff81954..231873a45644 100644
|
|
|
+index 283c0ff81954bb9e777b1e0007a735ec0ad4901e..231873a456442856c43d643e41c1bb22f4203a5c 100644
|
|
|
--- a/printing/print_settings_conversion.h
|
|
|
+++ b/printing/print_settings_conversion.h
|
|
|
@@ -21,6 +21,10 @@ PRINTING_EXPORT bool PrintSettingsFromJobSettings(
|
|
|
const base::DictionaryValue& job_settings,
|
|
|
PrintSettings* print_settings);
|
|
|
-
|
|
|
+
|
|
|
+PRINTING_EXPORT void PrintSettingsToJobSettings(
|
|
|
+ const PrintSettings& settings,
|
|
|
+ base::DictionaryValue* job_settings);
|
|
@@ -987,3 +997,6 @@ index 283c0ff81954..231873a45644 100644
|
|
|
// Use for debug only, because output is not completely consistent with format
|
|
|
// of |PrintSettingsFromJobSettings| input.
|
|
|
void PrintSettingsToJobSettingsDebug(const PrintSettings& settings,
|
|
|
+--
|
|
|
+2.17.0
|
|
|
+
|