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
|
2016-10-17 20:14:44 +02:00
|
|
|
index 4552193..dbf30ae 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
|
|
|
|
@@ -9,7 +9,9 @@
|
|
|
|
#include "base/logging.h"
|
|
|
|
#import "base/mac/scoped_nsobject.h"
|
|
|
|
#include "base/strings/sys_string_conversions.h"
|
|
|
|
+#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
#include "chrome/browser/printing/print_view_manager.h"
|
|
|
|
+#endif
|
|
|
|
#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-10-17 20:14:44 +02:00
|
|
|
@@ -224,11 +226,15 @@ void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id,
|
2016-07-14 03:35:07 +02:00
|
|
|
|
|
|
|
- (void)handlesPrintScriptCommand:(NSScriptCommand*)command {
|
|
|
|
AppleScript::LogAppleScriptUMA(AppleScript::AppleScriptCommand::TAB_PRINT);
|
|
|
|
+#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
bool initiated =
|
|
|
|
printing::PrintViewManager::FromWebContents(webContents_)->PrintNow();
|
|
|
|
if (!initiated) {
|
|
|
|
AppleScript::SetError(AppleScript::errInitiatePrinting);
|
|
|
|
}
|
|
|
|
+#else
|
|
|
|
+ NOTIMPLEMENTED();
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)handlesSaveScriptCommand:(NSScriptCommand*)command {
|
|
|
|
diff --git components/printing/common/print_messages.cc components/printing/common/print_messages.cc
|
2016-05-25 01:35:43 +02:00
|
|
|
index 6798e35..215777f 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/common/print_messages.cc
|
|
|
|
+++ components/printing/common/print_messages.cc
|
2016-05-25 01:35:43 +02:00
|
|
|
@@ -103,7 +103,6 @@ void PrintMsg_PrintPages_Params::Reset() {
|
2016-02-02 22:32:44 +01:00
|
|
|
pages = std::vector<int>();
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params::
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params()
|
|
|
|
: is_modifiable(false),
|
2016-05-25 01:35:43 +02:00
|
|
|
@@ -125,4 +124,3 @@ PrintHostMsg_SetOptionsFromDocument_Params::
|
2016-02-02 22:32:44 +01:00
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params::
|
|
|
|
~PrintHostMsg_SetOptionsFromDocument_Params() {
|
|
|
|
}
|
|
|
|
-#endif // defined(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
|
2016-08-31 13:25:56 +02:00
|
|
|
index a019144..af8839d 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/common/print_messages.h
|
|
|
|
+++ components/printing/common/print_messages.h
|
2016-04-27 22:38:52 +02:00
|
|
|
@@ -71,7 +71,6 @@ struct PrintMsg_PrintPages_Params {
|
2016-02-02 22:32:44 +01:00
|
|
|
std::vector<int> pages;
|
|
|
|
};
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
struct PrintHostMsg_RequestPrintPreview_Params {
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params();
|
|
|
|
~PrintHostMsg_RequestPrintPreview_Params();
|
2016-04-27 22:38:52 +02:00
|
|
|
@@ -90,7 +89,6 @@ struct PrintHostMsg_SetOptionsFromDocument_Params {
|
2016-02-02 22:32:44 +01:00
|
|
|
printing::DuplexMode duplex;
|
|
|
|
printing::PageRanges page_ranges;
|
|
|
|
};
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
|
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
@@ -177,7 +175,6 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_STRUCT_TRAITS_MEMBER(to)
|
|
|
|
IPC_STRUCT_TRAITS_END()
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(webnode_only)
|
2016-04-27 22:38:52 +02:00
|
|
|
@@ -198,7 +195,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()
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
|
|
|
|
IPC_STRUCT_TRAITS_MEMBER(content_width)
|
2016-04-27 22:38:52 +02:00
|
|
|
@@ -218,7 +214,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()
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Parameters to describe a rendered document.
|
|
|
|
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
|
|
|
|
// A shared memory handle to metafile data.
|
2016-04-27 22:38:52 +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()
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// Parameters to describe a rendered page.
|
|
|
|
IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -311,22 +305,20 @@ IPC_STRUCT_END()
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// Messages sent from the browser to the renderer.
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Tells the render view to initiate print preview for the entire document.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */)
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// Tells the render frame to initiate printing or print preview for a particular
|
|
|
|
// node, depending on which mode the render frame is in.
|
|
|
|
IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
|
|
|
|
|
|
|
|
-#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#if defined(ENABLE_BASIC_PRINTING)
|
|
|
|
// 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 */)
|
|
|
|
-#endif // defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#endif // defined(ENABLE_BASIC_PRINTING)
|
|
|
|
|
|
|
|
#if defined(ENABLE_BASIC_PRINTING)
|
|
|
|
// Tells the render view to switch the CSS to print media type, renders every
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -345,13 +337,11 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
|
2016-02-02 22:32:44 +01:00
|
|
|
IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
|
|
|
|
bool /* blocked */)
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Tells the render view to switch the CSS to print media type, renders every
|
|
|
|
// 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 */)
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// Messages sent from the renderer to the browser.
|
|
|
|
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -411,7 +401,6 @@ IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten,
|
2016-02-02 22:32:44 +01:00
|
|
|
int /* fd in browser */) // Used only by Chrome OS.
|
|
|
|
#endif // defined(OS_ANDROID)
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Asks the browser to do print preview.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
|
|
|
|
PrintHostMsg_RequestPrintPreview_Params /* params */)
|
2016-08-31 13:25:56 +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 */)
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// This is sent when there are invalid printer settings.
|
|
|
|
IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
|
2016-08-31 13:25:56 +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 */)
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Tell the browser print preview failed.
|
|
|
|
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
|
|
|
|
int /* document cookie */)
|
2016-08-31 13:25:56 +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 */)
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
2016-07-14 03:35:07 +02:00
|
|
|
diff --git components/printing/renderer/print_web_view_helper.cc components/printing/renderer/print_web_view_helper.cc
|
2016-10-21 21:52:29 +02:00
|
|
|
index 7e9df81..33489d0 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/renderer/print_web_view_helper.cc
|
|
|
|
+++ components/printing/renderer/print_web_view_helper.cc
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -86,6 +86,9 @@ const float kPrintingMinimumShrinkFactor = 1.333f;
|
2015-10-09 17:23:12 +02:00
|
|
|
|
|
|
|
#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
bool g_is_preview_enabled = true;
|
|
|
|
+#else
|
|
|
|
+bool g_is_preview_enabled = false;
|
|
|
|
+#endif // defined(ENABLE_PRINT_PREVIEW)
|
2015-03-24 16:40:08 +01:00
|
|
|
|
|
|
|
const char kPageLoadScriptFormat[] =
|
|
|
|
"document.open(); document.write(%s); document.close();";
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -100,9 +103,6 @@ void ExecuteScript(blink::WebFrame* frame,
|
2015-03-24 16:40:08 +01:00
|
|
|
std::string script = base::StringPrintf(script_format, json.c_str());
|
|
|
|
frame->executeScript(blink::WebString(base::UTF8ToUTF16(script)));
|
|
|
|
}
|
2015-10-09 17:23:12 +02:00
|
|
|
-#else
|
|
|
|
-bool g_is_preview_enabled = false;
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
2015-03-24 16:40:08 +01:00
|
|
|
|
|
|
|
int GetDPI(const PrintMsg_Print_Params* print_params) {
|
|
|
|
#if defined(OS_MACOSX)
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -302,7 +302,6 @@ bool PrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
return plugin && plugin->supportsPaginatedPrint();
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Returns true if the current destination printer is PRINT_TO_PDF.
|
|
|
|
bool IsPrintToPdfRequested(const base::DictionaryValue& job_settings) {
|
|
|
|
bool print_to_pdf = false;
|
2016-08-31 13:25:56 +02:00
|
|
|
@@ -324,7 +323,6 @@ bool PrintingFrameHasPageSizeStyle(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
return frame_has_custom_page_size_style;
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// Disable scaling when either:
|
|
|
|
// - The PDF specifies disabling scaling.
|
2016-10-17 20:14:44 +02:00
|
|
|
@@ -378,7 +376,6 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
bool FitToPageEnabled(const base::DictionaryValue& job_settings) {
|
|
|
|
bool fit_to_paper_size = false;
|
|
|
|
if (!job_settings.GetBoolean(kSettingFitToPageEnabled, &fit_to_paper_size)) {
|
2016-10-17 20:14:44 +02:00
|
|
|
@@ -421,7 +418,6 @@ blink::WebPrintScalingOption GetPrintScalingOption(
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
return blink::WebPrintScalingOptionFitToPrintableArea;
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
PrintMsg_Print_Params CalculatePrintParamsForCss(
|
2016-07-21 23:21:32 +02:00
|
|
|
blink::WebLocalFrame* frame,
|
2016-10-17 20:14:44 +02:00
|
|
|
@@ -505,7 +501,6 @@ blink::WebView* FrameReference::view() {
|
2015-03-24 16:40:08 +01:00
|
|
|
return view_;
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// static - Not anonymous so that platform implementations can use it.
|
|
|
|
void PrintWebViewHelper::PrintHeaderAndFooter(
|
|
|
|
blink::WebCanvas* canvas,
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -563,7 +558,6 @@ void PrintWebViewHelper::PrintHeaderAndFooter(
|
|
|
|
|
2015-03-24 16:40:08 +01:00
|
|
|
web_view->close();
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// static - Not anonymous so that platform implementations can use it.
|
|
|
|
float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame,
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -840,6 +834,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view,
|
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),
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -898,10 +893,8 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (g_is_preview_enabled) {
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
print_preview_context_.InitWithFrame(frame);
|
|
|
|
RequestPrintPreview(PRINT_PREVIEW_SCRIPTED);
|
|
|
|
-#endif
|
|
|
|
} else {
|
|
|
|
#if defined(ENABLE_BASIC_PRINTING)
|
|
|
|
Print(frame, blink::WebNode(), true);
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -925,14 +918,10 @@ bool PrintWebViewHelper::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)
|
|
|
|
#endif // defined(ENABLE_BASIC_PRINTING)
|
|
|
|
-#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview)
|
|
|
|
-#endif
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone)
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked,
|
|
|
|
SetScriptedPrintBlocked)
|
|
|
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -987,7 +976,6 @@ void PrintWebViewHelper::OnPrintForSystemDialog() {
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
#endif // defined(ENABLE_BASIC_PRINTING)
|
|
|
|
|
|
|
|
-#if defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
void PrintWebViewHelper::OnPrintForPrintPreview(
|
|
|
|
const base::DictionaryValue& job_settings) {
|
|
|
|
CHECK_LE(ipc_nesting_level_, 1);
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1052,7 +1040,6 @@ void PrintWebViewHelper::OnPrintForPrintPreview(
|
2016-02-02 22:32:44 +01:00
|
|
|
DidFinishPrinting(FAIL_PRINT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_BASIC_PRINTING) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout(
|
|
|
|
const PageSizeMargins& page_layout_in_points,
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1077,7 +1064,6 @@ void PrintWebViewHelper::UpdateFrameMarginsCssInfo(
|
2016-02-02 22:32:44 +01:00
|
|
|
ignore_css_margins_ = (margins_type != DEFAULT_MARGINS);
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) {
|
|
|
|
if (ipc_nesting_level_ > 1)
|
|
|
|
return;
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1238,7 +1224,7 @@ bool PrintWebViewHelper::CreatePreviewDocument() {
|
2016-02-02 22:32:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if !defined(OS_MACOSX) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#if !defined(OS_MACOSX)
|
|
|
|
bool PrintWebViewHelper::RenderPreviewPage(
|
|
|
|
int page_number,
|
|
|
|
const PrintMsg_Print_Params& print_params) {
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1268,7 +1254,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
return PreviewPageRendered(page_number, draft_metafile.get());
|
|
|
|
}
|
|
|
|
-#endif // !defined(OS_MACOSX) && defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
+#endif // !defined(OS_MACOSX)
|
|
|
|
|
|
|
|
bool PrintWebViewHelper::FinalizePrintReadyDocument() {
|
|
|
|
DCHECK(!is_print_ready_metafile_sent_);
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1298,7 +1284,6 @@ bool PrintWebViewHelper::FinalizePrintReadyDocument() {
|
2016-02-02 22:32:44 +01:00
|
|
|
Send(new PrintHostMsg_MetafileReadyForPrinting(routing_id(), preview_params));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
void PrintWebViewHelper::OnPrintingDone(bool success) {
|
|
|
|
if (ipc_nesting_level_ > 1)
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1313,7 +1298,6 @@ void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) {
|
2016-02-02 22:32:44 +01:00
|
|
|
is_scripted_printing_blocked_ = blocked;
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) {
|
|
|
|
if (ipc_nesting_level_ > 1)
|
|
|
|
return;
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1324,7 +1308,9 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) {
|
2015-07-24 02:06:56 +02:00
|
|
|
// that instead.
|
|
|
|
auto plugin = delegate_->GetPdfElement(frame);
|
|
|
|
if (!plugin.isNull()) {
|
|
|
|
+ force_print_preview_ = true;
|
|
|
|
PrintNode(plugin);
|
|
|
|
+ force_print_preview_ = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
print_preview_context_.InitWithFrame(frame);
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1332,7 +1318,6 @@ void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) {
|
2016-02-02 22:32:44 +01:00
|
|
|
? PRINT_PREVIEW_USER_INITIATED_SELECTION
|
|
|
|
: PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME);
|
|
|
|
}
|
|
|
|
-#endif
|
|
|
|
|
|
|
|
bool PrintWebViewHelper::IsPrintingEnabled() {
|
|
|
|
bool result = false;
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1358,11 +1343,9 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) {
|
2015-07-24 02:06:56 +02:00
|
|
|
|
|
|
|
// Make a copy of the node, in case RenderView::OnContextMenuClosed resets
|
|
|
|
// its |context_menu_node_|.
|
2016-02-02 22:32:44 +01:00
|
|
|
- if (g_is_preview_enabled) {
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
+ 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-02-02 22:32:44 +01:00
|
|
|
#if defined(ENABLE_BASIC_PRINTING)
|
|
|
|
blink::WebNode duplicate_node(node);
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1428,7 +1411,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
case FAIL_PREVIEW:
|
|
|
|
int cookie =
|
|
|
|
print_pages_params_ ? print_pages_params_->params.document_cookie : 0;
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1440,7 +1422,6 @@ void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
print_preview_context_.Failed(notify_browser_of_print_failure_);
|
|
|
|
break;
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
}
|
|
|
|
prep_frame_view_.reset();
|
|
|
|
print_pages_params_.reset();
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1572,7 +1553,6 @@ bool PrintWebViewHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame,
|
2016-02-02 22:32:44 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
bool PrintWebViewHelper::SetOptionsFromPdfDocument(
|
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params* options) {
|
|
|
|
blink::WebLocalFrame* source_frame = print_preview_context_.source_frame();
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1681,7 +1661,6 @@ bool PrintWebViewHelper::UpdatePrintSettings(
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
#if defined(ENABLE_BASIC_PRINTING)
|
|
|
|
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1790,7 +1769,6 @@ void PrintWebViewHelper::PrintPageInternal(
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
if (params.params.display_header_footer) {
|
2016-04-27 22:38:52 +02:00
|
|
|
// TODO(thestig): Figure out why Linux needs this. It is almost certainly
|
|
|
|
// |printingMinimumShrinkFactor| from Blink.
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1805,7 +1783,6 @@ void PrintWebViewHelper::PrintPageInternal(
|
2016-03-16 03:55:59 +01:00
|
|
|
scale_factor / fudge_factor, page_layout_in_points,
|
|
|
|
params.params);
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
float webkit_scale_factor =
|
|
|
|
RenderPageContent(frame, params.page_number, canvas_area, content_area,
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1841,7 +1818,6 @@ bool PrintWebViewHelper::CopyMetafileDataToSharedMem(
|
2016-03-16 03:55:59 +01:00
|
|
|
return true;
|
2016-02-02 22:32:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
void PrintWebViewHelper::ShowScriptedPrintPreview() {
|
|
|
|
if (is_scripted_preview_delayed_) {
|
|
|
|
is_scripted_preview_delayed_ = false;
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -1969,7 +1945,6 @@ bool PrintWebViewHelper::PreviewPageRendered(int page_number,
|
2016-02-02 22:32:44 +01:00
|
|
|
Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
PrintWebViewHelper::PrintPreviewContext::PrintPreviewContext()
|
|
|
|
: total_page_count_(0),
|
2016-07-14 03:35:07 +02:00
|
|
|
diff --git components/printing/renderer/print_web_view_helper.h components/printing/renderer/print_web_view_helper.h
|
2016-07-21 23:21:32 +02:00
|
|
|
index dd8d24d..7c73d38 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/renderer/print_web_view_helper.h
|
|
|
|
+++ components/printing/renderer/print_web_view_helper.h
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -138,9 +138,7 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
OK,
|
|
|
|
FAIL_PRINT_INIT,
|
|
|
|
FAIL_PRINT,
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
FAIL_PREVIEW,
|
|
|
|
-#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PrintPreviewErrorBuckets {
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -175,10 +173,8 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
void OnPrintForSystemDialog();
|
|
|
|
void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
|
|
|
|
#endif // defined(ENABLE_BASIC_PRINTING)
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
void OnInitiatePrintPreview(bool selection_only);
|
|
|
|
void OnPrintPreview(const base::DictionaryValue& settings);
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
void OnPrintingDone(bool success);
|
|
|
|
|
|
|
|
// Get |page_size| and |content_area| information from
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -191,7 +187,6 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
// Update |ignore_css_margins_| based on settings.
|
|
|
|
void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings);
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Prepare frame for creating preview document.
|
|
|
|
void PrepareFrameForPreviewDocument();
|
|
|
|
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -208,7 +203,6 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
|
|
|
|
// Finalize the print ready preview document.
|
|
|
|
bool FinalizePrintReadyDocument();
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// Enable/Disable window.print calls. If |blocked| is true window.print
|
|
|
|
// calls will silently fail. Call with |blocked| set to false to reenable.
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -237,7 +231,6 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
const blink::WebNode& node,
|
|
|
|
int* number_of_pages);
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Set options for print preset from source PDF document.
|
|
|
|
bool SetOptionsFromPdfDocument(
|
|
|
|
PrintHostMsg_SetOptionsFromDocument_Params* options);
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -248,7 +241,6 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
bool UpdatePrintSettings(blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebNode& node,
|
|
|
|
const base::DictionaryValue& passed_job_settings);
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// Get final print settings from the user.
|
|
|
|
// Return false if the user cancels or on error.
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -323,7 +315,6 @@ class PrintWebViewHelper
|
2016-01-06 20:20:54 +01:00
|
|
|
const PrintMsg_PrintPages_Params& params,
|
|
|
|
int page_count);
|
2015-03-24 16:40:08 +01:00
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Given the |device| and |canvas| to draw on, prints the appropriate headers
|
|
|
|
// and footers using strings from |header_footer_info| on to the canvas.
|
|
|
|
static void PrintHeaderAndFooter(blink::WebCanvas* canvas,
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -333,7 +324,6 @@ class PrintWebViewHelper
|
2015-03-24 16:40:08 +01:00
|
|
|
float webkit_scale_factor,
|
|
|
|
const PageSizeMargins& page_layout_in_points,
|
|
|
|
const PrintMsg_Print_Params& params);
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
bool GetPrintFrame(blink::WebLocalFrame** frame);
|
|
|
|
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -345,7 +335,6 @@ class PrintWebViewHelper
|
2016-02-02 22:32:44 +01:00
|
|
|
bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame,
|
|
|
|
bool user_initiated);
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
// Shows scripted print preview when options from plugin are available.
|
|
|
|
void ShowScriptedPrintPreview();
|
|
|
|
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -361,7 +350,6 @@ class PrintWebViewHelper
|
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);
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings);
|
|
|
|
|
2016-07-21 23:21:32 +02:00
|
|
|
@@ -514,6 +502,7 @@ class PrintWebViewHelper
|
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_;
|
2016-07-14 03:35:07 +02:00
|
|
|
diff --git components/printing/renderer/print_web_view_helper_mac.mm components/printing/renderer/print_web_view_helper_mac.mm
|
2016-07-21 23:21:32 +02:00
|
|
|
index 0b13474..4bf7c6b 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/printing/renderer/print_web_view_helper_mac.mm
|
|
|
|
+++ components/printing/renderer/print_web_view_helper_mac.mm
|
2016-03-16 03:55:59 +01:00
|
|
|
@@ -68,7 +68,6 @@ void PrintWebViewHelper::PrintPageInternal(
|
2016-02-02 22:32:44 +01:00
|
|
|
Send(new PrintHostMsg_DidPrintPage(routing_id(), page_params));
|
|
|
|
}
|
2015-03-24 16:40:08 +01:00
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
2016-02-02 22:32:44 +01:00
|
|
|
bool PrintWebViewHelper::RenderPreviewPage(
|
|
|
|
int page_number,
|
|
|
|
const PrintMsg_Print_Params& print_params) {
|
2016-06-21 00:59:23 +02:00
|
|
|
@@ -105,7 +104,6 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
2015-03-24 16:40:08 +01:00
|
|
|
}
|
2016-02-02 22:32:44 +01:00
|
|
|
return PreviewPageRendered(page_number, draft_metafile.get());
|
|
|
|
}
|
2015-03-24 16:40:08 +01:00
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
2016-02-02 22:32:44 +01:00
|
|
|
void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
|
|
|
|
int page_number,
|
2016-06-21 00:59:23 +02:00
|
|
|
@@ -140,14 +138,12 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
|
2015-12-09 17:10:16 +01:00
|
|
|
|
2015-03-24 16:40:08 +01:00
|
|
|
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
|
|
|
skia::SetIsPreviewMetafile(*canvas, is_preview);
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
if (params.display_header_footer) {
|
|
|
|
PrintHeaderAndFooter(static_cast<blink::WebCanvas*>(canvas),
|
|
|
|
page_number + 1,
|
|
|
|
print_preview_context_.total_page_count(), *frame,
|
|
|
|
scale_factor, page_layout_in_points, params);
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
RenderPageContent(frame, page_number, canvas_area, content_area,
|
|
|
|
scale_factor, static_cast<blink::WebCanvas*>(canvas));
|
|
|
|
}
|
2016-07-14 03:35:07 +02:00
|
|
|
diff --git components/resources/printing_resources.grdp components/resources/printing_resources.grdp
|
2015-03-24 16:40:08 +01:00
|
|
|
index 7213746..32b8b1e 100644
|
2016-07-14 03:35:07 +02:00
|
|
|
--- components/resources/printing_resources.grdp
|
|
|
|
+++ components/resources/printing_resources.grdp
|
2015-03-24 16:40:08 +01:00
|
|
|
@@ -1,6 +1,4 @@
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<grit-part>
|
|
|
|
- <if expr="enable_print_preview">
|
|
|
|
<include name="IDR_PRINT_PREVIEW_PAGE" file="../printing/resources/print_preview_page.html" flattenhtml="true" allowexternalscript="false" type="BINDATA" />
|
|
|
|
- </if>
|
|
|
|
</grit-part>
|