2016-07-14 03:35:07 +02:00
|
|
|
diff --git chrome/browser/ui/cocoa/applescript/tab_applescript.mm chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
2017-09-06 23:40:58 +02:00
|
|
|
index 0cd84f38c229..2f872dd3dfe2 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
|
|
|
+++ chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
2016-11-23 21:54:29 +01:00
|
|
|
@@ -9,7 +9,6 @@
|
2016-07-14 03:35:07 +02:00
|
|
|
#include "base/logging.h"
|
|
|
|
#import "base/mac/scoped_nsobject.h"
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
-#include "chrome/browser/printing/print_view_manager.h"
|
2016-07-14 03:35:07 +02:00
|
|
|
#include "chrome/browser/sessions/session_tab_helper.h"
|
|
|
|
#include "chrome/browser/ui/cocoa/applescript/apple_event_util.h"
|
|
|
|
#include "chrome/browser/ui/cocoa/applescript/error_applescript.h"
|
2016-11-23 21:54:29 +01:00
|
|
|
@@ -25,8 +24,13 @@
|
|
|
|
#include "content/public/browser/save_page_type.h"
|
|
|
|
#include "content/public/browser/web_contents.h"
|
|
|
|
#include "content/public/browser/web_contents_delegate.h"
|
|
|
|
+#include "printing/features/features.h"
|
|
|
|
#include "url/gurl.h"
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#include "chrome/browser/printing/print_view_manager.h"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
using content::NavigationController;
|
|
|
|
using content::NavigationEntry;
|
|
|
|
using content::OpenURLParams;
|
2017-01-23 18:36:54 +01:00
|
|
|
@@ -231,11 +235,15 @@ void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id,
|
2016-07-14 03:35:07 +02:00
|
|
|
|
|
|
|
- (void)handlesPrintScriptCommand:(NSScriptCommand*)command {
|
|
|
|
AppleScript::LogAppleScriptUMA(AppleScript::AppleScriptCommand::TAB_PRINT);
|
2016-11-23 21:54:29 +01:00
|
|
|
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
bool initiated = printing::PrintViewManager::FromWebContents(webContents_)
|
|
|
|
->PrintNow(webContents_->GetMainFrame());
|
2016-07-14 03:35:07 +02:00
|
|
|
if (!initiated) {
|
|
|
|
AppleScript::SetError(AppleScript::errInitiatePrinting);
|
|
|
|
}
|
|
|
|
+#else
|
|
|
|
+ NOTIMPLEMENTED();
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)handlesSaveScriptCommand:(NSScriptCommand*)command {
|
2017-03-03 23:37:23 +01:00
|
|
|
diff --git chrome/common/chrome_utility_printing_messages.h chrome/common/chrome_utility_printing_messages.h
|
2017-09-06 23:40:58 +02:00
|
|
|
index f5712a7a5bb8..11c03661412b 100644
|
2017-03-03 23:37:23 +01:00
|
|
|
--- chrome/common/chrome_utility_printing_messages.h
|
|
|
|
+++ chrome/common/chrome_utility_printing_messages.h
|
|
|
|
@@ -26,7 +26,6 @@
|
|
|
|
#define IPC_MESSAGE_START ChromeUtilityPrintingMsgStart
|
|
|
|
|
|
|
|
// Preview and Cloud Print messages.
|
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_ENUM_TRAITS_MAX_VALUE(printing::PdfRenderSettings::Mode,
|
|
|
|
printing::PdfRenderSettings::Mode::LAST)
|
|
|
|
|
|
|
|
@@ -38,6 +37,7 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PdfRenderSettings)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(mode)
|
|
|
|
IPC_STRUCT_TRAITS_END()
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
|
2016-07-14 03:35:07 +02:00
|
|
|
diff --git components/printing/common/print_messages.cc components/printing/common/print_messages.cc
|
2017-09-06 23:40:58 +02:00
|
|
|
index 4a7c94d1cdd0..7bf3e6ae072c 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/common/print_messages.cc
|
|
|
|
+++ components/printing/common/print_messages.cc
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -107,7 +107,6 @@ void PrintMsg_PrintPages_Params::Reset() {
|
2016-02-02 22:32:44 +01:00
|
|
|
pages = std::vector<int>();
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
PrintHostMsg_RequestPrintPreview_Params::
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params()
|
|
|
|
: is_modifiable(false),
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -129,4 +128,3 @@ PrintHostMsg_SetOptionsFromDocument_Params::
|
2016-02-02 22:32:44 +01:00
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params::
|
|
|
|
~PrintHostMsg_SetOptionsFromDocument_Params() {
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-07-14 03:35:07 +02:00
|
|
|
diff --git components/printing/common/print_messages.h components/printing/common/print_messages.h
|
2017-09-06 23:40:58 +02:00
|
|
|
index f9b1daf905f2..971b92bccfdc 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/common/print_messages.h
|
|
|
|
+++ components/printing/common/print_messages.h
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -76,7 +76,6 @@ struct PrintMsg_PrintPages_Params {
|
2016-02-02 22:32:44 +01:00
|
|
|
std::vector<int> pages;
|
|
|
|
};
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
struct PrintHostMsg_RequestPrintPreview_Params {
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params();
|
|
|
|
~PrintHostMsg_RequestPrintPreview_Params();
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -95,7 +94,6 @@ struct PrintHostMsg_SetOptionsFromDocument_Params {
|
2016-02-02 22:32:44 +01:00
|
|
|
printing::DuplexMode duplex;
|
|
|
|
printing::PageRanges page_ranges;
|
|
|
|
};
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -180,7 +178,6 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_STRUCT_TRAITS_MEMBER(to)
|
|
|
|
IPC_STRUCT_TRAITS_END()
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(webnode_only)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -201,7 +198,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_SetOptionsFromDocument_Params)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Specifies page range to be printed.
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(page_ranges)
|
|
|
|
IPC_STRUCT_TRAITS_END()
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(content_width)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -221,7 +217,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_STRUCT_TRAITS_MEMBER(pages)
|
|
|
|
IPC_STRUCT_TRAITS_END()
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Parameters to describe a rendered document.
|
|
|
|
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
|
|
|
|
// A shared memory handle to metafile data.
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -272,7 +267,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Indicates whether the existing preview data needs to be cleared or not.
|
|
|
|
IPC_STRUCT_MEMBER(bool, clear_preview_data)
|
|
|
|
IPC_STRUCT_END()
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// Parameters to describe a rendered page.
|
|
|
|
IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -315,22 +309,20 @@ IPC_STRUCT_END()
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// Messages sent from the browser to the renderer.
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Tells the RenderFrame to initiate print preview for the entire document.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* has_selection */)
|
|
|
|
-#endif
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
// Tells the RenderFrame to initiate printing or print preview for a particular
|
|
|
|
// node, depending on which mode the RenderFrame is in.
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Tells the renderer to print the print preview tab's PDF plugin without
|
|
|
|
// showing the print dialog. (This is the final step in the print preview
|
|
|
|
// workflow.)
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
|
|
|
|
base::DictionaryValue /* settings */)
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
|
|
|
// Tells the RenderFrame to switch the CSS to print media type, renders every
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -348,13 +340,11 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
|
2016-11-23 21:54:29 +01:00
|
|
|
// Tells the RenderFrame whether printing is enabled or not.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintMsg_SetPrintingEnabled, bool /* enabled */)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Tells the RenderFrame to switch the CSS to print media type, renders every
|
2016-02-02 22:32:44 +01:00
|
|
|
// requested pages for print preview using the given |settings|. This gets
|
|
|
|
// called multiple times as the user updates settings.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
|
|
|
|
base::DictionaryValue /* settings */)
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// Messages sent from the renderer to the browser.
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -411,7 +401,6 @@ IPC_MESSAGE_CONTROL3(PrintHostMsg_TempFileForPrintingWritten,
|
2017-07-27 01:19:27 +02:00
|
|
|
int /* page count */)
|
2016-02-02 22:32:44 +01:00
|
|
|
#endif // defined(OS_ANDROID)
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Asks the browser to do print preview.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params /* params */)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -445,7 +434,6 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel,
|
2016-02-02 22:32:44 +01:00
|
|
|
// The memory handle in this message is already valid in the browser process.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
|
|
|
|
PrintHostMsg_DidPreviewDocument_Params /* params */)
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// This is sent when there are invalid printer settings.
|
|
|
|
IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -454,7 +442,6 @@ IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
|
|
|
|
int /* document cookie */)
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Tell the browser print preview failed.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
|
|
|
|
int /* document cookie */)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -481,4 +468,3 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
|
2016-02-02 22:32:44 +01:00
|
|
|
// Notify the browser to set print presets based on source PDF document.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_SetOptionsFromDocument,
|
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params /* params */)
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
diff --git components/printing/renderer/print_render_frame_helper.cc components/printing/renderer/print_render_frame_helper.cc
|
|
|
|
index 18469953e9f0..bb94f44e58b0 100644
|
|
|
|
--- components/printing/renderer/print_render_frame_helper.cc
|
|
|
|
+++ components/printing/renderer/print_render_frame_helper.cc
|
2017-05-31 17:33:30 +02:00
|
|
|
@@ -320,7 +320,6 @@ bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame,
|
2017-04-20 21:28:17 +02:00
|
|
|
return plugin && plugin->SupportsPaginatedPrint();
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Returns true if the current destination printer is PRINT_TO_PDF.
|
|
|
|
bool IsPrintToPdfRequested(const base::DictionaryValue& job_settings) {
|
|
|
|
bool print_to_pdf = false;
|
2017-05-31 17:33:30 +02:00
|
|
|
@@ -342,7 +341,6 @@ bool PrintingFrameHasPageSizeStyle(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
return frame_has_custom_page_size_style;
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
#if BUILDFLAG(ENABLE_PRINTING)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Disable scaling when either:
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -399,7 +397,6 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
bool FitToPageEnabled(const base::DictionaryValue& job_settings) {
|
|
|
|
bool fit_to_paper_size = false;
|
|
|
|
if (!job_settings.GetBoolean(kSettingFitToPageEnabled, &fit_to_paper_size)) {
|
2017-05-31 17:33:30 +02:00
|
|
|
@@ -441,7 +438,6 @@ blink::WebPrintScalingOption GetPrintScalingOption(
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
2017-04-20 21:28:17 +02:00
|
|
|
return blink::kWebPrintScalingOptionFitToPrintableArea;
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
// Helper function to scale and round an integer value with a double valued
|
|
|
|
// scaling.
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -977,6 +973,7 @@ PrintRenderFrameHelper::PrintRenderFrameHelper(
|
2015-07-24 02:06:56 +02:00
|
|
|
print_for_preview_(false),
|
2016-01-06 20:20:54 +01:00
|
|
|
delegate_(std::move(delegate)),
|
2015-07-24 02:06:56 +02:00
|
|
|
print_node_in_progress_(false),
|
|
|
|
+ force_print_preview_(false),
|
|
|
|
is_loading_(false),
|
|
|
|
is_scripted_preview_delayed_(false),
|
|
|
|
ipc_nesting_level_(0),
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1038,10 +1035,8 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
2016-02-02 22:32:44 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (g_is_preview_enabled) {
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
print_preview_context_.InitWithFrame(web_frame);
|
2016-02-02 22:32:44 +01:00
|
|
|
RequestPrintPreview(PRINT_PREVIEW_SCRIPTED);
|
|
|
|
-#endif
|
|
|
|
} else {
|
2016-11-23 21:54:29 +01:00
|
|
|
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
|
|
|
Print(web_frame, blink::WebNode(), true /* is_scripted? */);
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1067,14 +1062,10 @@ bool PrintRenderFrameHelper::OnMessageReceived(const IPC::Message& message) {
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog)
|
2016-11-23 21:54:29 +01:00
|
|
|
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
|
|
|
|
-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview)
|
|
|
|
-#endif
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone)
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_SetPrintingEnabled, OnSetPrintingEnabled)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
2016-11-23 21:54:29 +01:00
|
|
|
IPC_END_MESSAGE_MAP()
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1122,7 +1113,6 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() {
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::OnPrintForPrintPreview(
|
2016-02-02 22:32:44 +01:00
|
|
|
const base::DictionaryValue& job_settings) {
|
|
|
|
CHECK_LE(ipc_nesting_level_, 1);
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1182,7 +1172,6 @@ void PrintRenderFrameHelper::OnPrintForPrintPreview(
|
2016-02-02 22:32:44 +01:00
|
|
|
DidFinishPrinting(FAIL_PRINT);
|
|
|
|
}
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_BASIC_PRINTING) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::GetPageSizeAndContentAreaFromPageLayout(
|
2016-02-02 22:32:44 +01:00
|
|
|
const PageSizeMargins& page_layout_in_points,
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1207,7 +1196,6 @@ void PrintRenderFrameHelper::UpdateFrameMarginsCssInfo(
|
2016-02-02 22:32:44 +01:00
|
|
|
ignore_css_margins_ = (margins_type != DEFAULT_MARGINS);
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::OnPrintPreview(
|
|
|
|
const base::DictionaryValue& settings) {
|
2016-02-02 22:32:44 +01:00
|
|
|
if (ipc_nesting_level_ > 1)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1399,7 +1387,7 @@ bool PrintRenderFrameHelper::CreatePreviewDocument() {
|
2016-02-02 22:32:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if !defined(OS_MACOSX) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
+#if !defined(OS_MACOSX)
|
2017-09-06 23:40:58 +02:00
|
|
|
bool PrintRenderFrameHelper::RenderPreviewPage(
|
2016-02-02 22:32:44 +01:00
|
|
|
int page_number,
|
|
|
|
const PrintMsg_Print_Params& print_params) {
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1429,7 +1417,7 @@ bool PrintRenderFrameHelper::RenderPreviewPage(
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
return PreviewPageRendered(page_number, draft_metafile.get());
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // !defined(OS_MACOSX) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
+#endif // !defined(OS_MACOSX)
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
bool PrintRenderFrameHelper::FinalizePrintReadyDocument() {
|
2016-02-02 22:32:44 +01:00
|
|
|
DCHECK(!is_print_ready_metafile_sent_);
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1458,7 +1446,6 @@ bool PrintRenderFrameHelper::FinalizePrintReadyDocument() {
|
2016-02-02 22:32:44 +01:00
|
|
|
Send(new PrintHostMsg_MetafileReadyForPrinting(routing_id(), preview_params));
|
|
|
|
return true;
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::OnPrintingDone(bool success) {
|
2016-02-02 22:32:44 +01:00
|
|
|
if (ipc_nesting_level_ > 1)
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1473,7 +1460,6 @@ void PrintRenderFrameHelper::OnSetPrintingEnabled(bool enabled) {
|
2016-11-23 21:54:29 +01:00
|
|
|
is_printing_enabled_ = enabled;
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
|
2016-02-02 22:32:44 +01:00
|
|
|
if (ipc_nesting_level_ > 1)
|
|
|
|
return;
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1484,7 +1470,9 @@ void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
|
2015-07-24 02:06:56 +02:00
|
|
|
// that instead.
|
|
|
|
auto plugin = delegate_->GetPdfElement(frame);
|
2017-04-20 21:28:17 +02:00
|
|
|
if (!plugin.IsNull()) {
|
2015-07-24 02:06:56 +02:00
|
|
|
+ force_print_preview_ = true;
|
|
|
|
PrintNode(plugin);
|
|
|
|
+ force_print_preview_ = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print_preview_context_.InitWithFrame(frame);
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1492,7 +1480,6 @@ void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
|
2016-02-02 22:32:44 +01:00
|
|
|
? PRINT_PREVIEW_USER_INITIATED_SELECTION
|
|
|
|
: PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME);
|
|
|
|
}
|
|
|
|
-#endif
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
bool PrintRenderFrameHelper::IsPrintingEnabled() const {
|
2016-11-23 21:54:29 +01:00
|
|
|
return is_printing_enabled_;
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1514,11 +1501,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
2017-01-23 18:36:54 +01:00
|
|
|
|
|
|
|
print_node_in_progress_ = true;
|
2015-07-24 02:06:56 +02:00
|
|
|
|
2016-02-02 22:32:44 +01:00
|
|
|
- if (g_is_preview_enabled) {
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
+ if (g_is_preview_enabled || force_print_preview_) {
|
|
|
|
print_preview_context_.InitWithNode(node);
|
|
|
|
RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE);
|
|
|
|
-#endif
|
2015-07-24 02:06:56 +02:00
|
|
|
} else {
|
2016-11-23 21:54:29 +01:00
|
|
|
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
2017-01-23 18:36:54 +01:00
|
|
|
// Make a copy of the node, in case RenderView::OnContextMenuClosed() resets
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1608,7 +1593,6 @@ void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) {
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
case FAIL_PREVIEW:
|
2017-07-27 01:19:27 +02:00
|
|
|
if (!is_print_ready_metafile_sent_) {
|
|
|
|
if (notify_browser_of_print_failure_) {
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1625,7 +1609,6 @@ void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) {
|
2017-07-27 01:19:27 +02:00
|
|
|
cookie));
|
|
|
|
print_preview_context_.Failed(false);
|
2016-02-02 22:32:44 +01:00
|
|
|
break;
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
prep_frame_view_.reset();
|
|
|
|
print_pages_params_.reset();
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1757,7 +1740,6 @@ bool PrintRenderFrameHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
bool PrintRenderFrameHelper::SetOptionsFromPdfDocument(
|
2016-02-02 22:32:44 +01:00
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params* options) {
|
|
|
|
blink::WebLocalFrame* source_frame = print_preview_context_.source_frame();
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -1864,7 +1846,6 @@ bool PrintRenderFrameHelper::UpdatePrintSettings(
|
2017-01-23 18:36:54 +01:00
|
|
|
print_preview_context_.set_error(PREVIEW_ERROR_INVALID_PRINTER_SETTINGS);
|
|
|
|
return false;
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::GetPrintSettingsFromUser(
|
|
|
|
@@ -2023,7 +2004,6 @@ bool PrintRenderFrameHelper::CopyMetafileDataToSharedMem(
|
2016-03-16 03:55:59 +01:00
|
|
|
return true;
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::ShowScriptedPrintPreview() {
|
2016-02-02 22:32:44 +01:00
|
|
|
if (is_scripted_preview_delayed_) {
|
|
|
|
is_scripted_preview_delayed_ = false;
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -2154,7 +2134,6 @@ bool PrintRenderFrameHelper::PreviewPageRendered(int page_number,
|
2016-02-02 22:32:44 +01:00
|
|
|
Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params));
|
|
|
|
return true;
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
PrintRenderFrameHelper::PrintPreviewContext::PrintPreviewContext()
|
2016-02-02 22:32:44 +01:00
|
|
|
: total_page_count_(0),
|
2017-09-06 23:40:58 +02:00
|
|
|
diff --git components/printing/renderer/print_render_frame_helper.h components/printing/renderer/print_render_frame_helper.h
|
|
|
|
index 6a52cd8bb78e..d5ca1ceb264d 100644
|
|
|
|
--- components/printing/renderer/print_render_frame_helper.h
|
|
|
|
+++ components/printing/renderer/print_render_frame_helper.h
|
|
|
|
@@ -156,10 +156,8 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
OK,
|
|
|
|
FAIL_PRINT_INIT,
|
|
|
|
FAIL_PRINT,
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
FAIL_PREVIEW,
|
2017-07-27 01:19:27 +02:00
|
|
|
INVALID_SETTINGS,
|
2016-02-02 22:32:44 +01:00
|
|
|
-#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PrintPreviewErrorBuckets {
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -196,10 +194,8 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
void OnPrintForSystemDialog();
|
|
|
|
void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
|
2016-11-23 21:54:29 +01:00
|
|
|
#endif // BUILDFLAG(ENABLE_BASIC_PRINTING)
|
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
|
|
|
void OnInitiatePrintPreview(bool has_selection);
|
2016-02-02 22:32:44 +01:00
|
|
|
void OnPrintPreview(const base::DictionaryValue& settings);
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
void OnPrintingDone(bool success);
|
|
|
|
|
|
|
|
// Get |page_size| and |content_area| information from
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -212,7 +208,6 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
// Update |ignore_css_margins_| based on settings.
|
|
|
|
void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings);
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Prepare frame for creating preview document.
|
|
|
|
void PrepareFrameForPreviewDocument();
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -229,7 +224,6 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// Finalize the print ready preview document.
|
|
|
|
bool FinalizePrintReadyDocument();
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
// Enable/Disable printing.
|
|
|
|
void OnSetPrintingEnabled(bool enabled);
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -259,7 +253,6 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
const blink::WebNode& node,
|
|
|
|
int* number_of_pages);
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Set options for print preset from source PDF document.
|
|
|
|
bool SetOptionsFromPdfDocument(
|
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params* options);
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -270,7 +263,6 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
bool UpdatePrintSettings(blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebNode& node,
|
|
|
|
const base::DictionaryValue& passed_job_settings);
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
2017-01-23 18:36:54 +01:00
|
|
|
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Get final print settings from the user.
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -374,7 +366,6 @@ class PrintRenderFrameHelper
|
2017-01-23 18:36:54 +01:00
|
|
|
bool IsScriptInitiatedPrintAllowed(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
bool user_initiated);
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
// Shows scripted print preview when options from plugin are available.
|
|
|
|
void ShowScriptedPrintPreview();
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -392,7 +383,6 @@ class PrintRenderFrameHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
// |metafile| is the rendered page. Otherwise |metafile| is NULL.
|
|
|
|
// Returns true if print preview should continue, false on failure.
|
|
|
|
bool PreviewPageRendered(int page_number, PdfMetafileSkia* metafile);
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings);
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -553,6 +543,7 @@ class PrintRenderFrameHelper
|
2015-07-24 02:06:56 +02:00
|
|
|
ScriptingThrottler scripting_throttler_;
|
|
|
|
|
|
|
|
bool print_node_in_progress_;
|
|
|
|
+ bool force_print_preview_;
|
|
|
|
PrintPreviewContext print_preview_context_;
|
|
|
|
bool is_loading_;
|
|
|
|
bool is_scripted_preview_delayed_;
|
2017-09-06 23:40:58 +02:00
|
|
|
diff --git components/printing/renderer/print_render_frame_helper_mac.mm components/printing/renderer/print_render_frame_helper_mac.mm
|
|
|
|
index 42149955ee2c..ca6cb42ffce1 100644
|
|
|
|
--- components/printing/renderer/print_render_frame_helper_mac.mm
|
|
|
|
+++ components/printing/renderer/print_render_frame_helper_mac.mm
|
|
|
|
@@ -76,7 +76,6 @@ void PrintRenderFrameHelper::PrintPagesInternal(
|
2017-04-20 21:28:17 +02:00
|
|
|
}
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
2015-03-24 16:40:08 +01:00
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2017-09-06 23:40:58 +02:00
|
|
|
bool PrintRenderFrameHelper::RenderPreviewPage(
|
2016-02-02 22:32:44 +01:00
|
|
|
int page_number,
|
|
|
|
const PrintMsg_Print_Params& print_params) {
|
2017-09-06 23:40:58 +02:00
|
|
|
@@ -115,7 +114,6 @@ bool PrintRenderFrameHelper::RenderPreviewPage(
|
2015-03-24 16:40:08 +01:00
|
|
|
}
|
2016-02-02 22:32:44 +01:00
|
|
|
return PreviewPageRendered(page_number, draft_metafile.get());
|
|
|
|
}
|
2016-11-23 21:54:29 +01:00
|
|
|
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
2015-03-24 16:40:08 +01:00
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
void PrintRenderFrameHelper::RenderPage(const PrintMsg_Print_Params& params,
|
|
|
|
int page_number,
|