2017-12-07 22:44:24 +01:00
diff --git chrome/browser/ui/BUILD.gn chrome/browser/ui/BUILD.gn
2018-05-14 13:24:05 +02:00
index 388cb0b5db0e..d9580cda6f8b 100644
2017-12-07 22:44:24 +01:00
--- chrome/browser/ui/BUILD.gn
+++ chrome/browser/ui/BUILD.gn
2018-05-14 13:24:05 +02:00
@@ -884,6 +884,7 @@ split_static_library("ui") {
2017-12-07 22:44:24 +01:00
"//base:i18n",
2018-03-20 21:15:08 +01:00
"//base/allocator:buildflags",
2017-12-07 22:44:24 +01:00
"//cc/paint",
+ "//cef/libcef/features",
"//chrome:extra_resources",
"//chrome:resources",
"//chrome:strings",
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
2018-04-19 17:44:42 +02:00
index 33216fef9a1b..c84572425a8d 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
2017-12-07 22:44:24 +01:00
@@ -9,7 +9,7 @@
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"
2017-12-07 22:44:24 +01:00
+#include "cef/libcef/features/features.h"
#include "chrome/browser/profiles/profile.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"
2017-12-07 22:44:24 +01:00
@@ -27,6 +27,10 @@
2016-11-23 21:54:29 +01:00
#include "content/public/browser/web_contents_delegate.h"
#include "url/gurl.h"
2017-12-07 22:44:24 +01:00
+#if !BUILDFLAG(ENABLE_CEF)
2016-11-23 21:54:29 +01:00
+#include "chrome/browser/printing/print_view_manager.h"
+#endif
+
using content::NavigationController;
using content::NavigationEntry;
using content::OpenURLParams;
2018-04-19 17:44:42 +02: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);
2017-12-07 22:44:24 +01:00
+#if !BUILDFLAG(ENABLE_CEF)
2016-11-23 21:54:29 +01:00
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-12-07 22:44:24 +01:00
diff --git chrome/browser/ui/webui/settings/printing_handler.cc chrome/browser/ui/webui/settings/printing_handler.cc
2018-04-19 17:44:42 +02:00
index 8647b2daf9ea..b070ab3e4b86 100644
2017-12-07 22:44:24 +01:00
--- chrome/browser/ui/webui/settings/printing_handler.cc
+++ chrome/browser/ui/webui/settings/printing_handler.cc
@@ -6,9 +6,13 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "chrome/browser/printing/printer_manager_dialog.h"
+#include "cef/libcef/features/features.h"
#include "content/public/browser/web_ui.h"
+#if !BUILDFLAG(ENABLE_CEF)
+#include "chrome/browser/printing/printer_manager_dialog.h"
+#endif
+
namespace settings {
PrintingHandler::PrintingHandler() {}
@@ -27,7 +31,11 @@ void PrintingHandler::OnJavascriptAllowed() {}
void PrintingHandler::OnJavascriptDisallowed() {}
void PrintingHandler::HandleOpenSystemPrintDialog(const base::ListValue* args) {
+#if !BUILDFLAG(ENABLE_CEF)
printing::PrinterManagerDialog::ShowPrinterManagerDialog();
+#else
+ NOTIMPLEMENTED();
+#endif
}
} // namespace settings
2018-03-20 21:15:08 +01:00
diff --git chrome/common/chrome_utility_printing_messages.h chrome/common/chrome_utility_printing_messages.h
2018-04-19 17:44:42 +02:00
index f903429e25e4..cde2124fb18e 100644
2018-03-20 21:15:08 +01:00
--- chrome/common/chrome_utility_printing_messages.h
+++ chrome/common/chrome_utility_printing_messages.h
@@ -16,7 +16,7 @@
#define IPC_MESSAGE_START ChromeUtilityPrintingMsgStart
-#if defined(OS_WIN) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
+#if defined(OS_WIN)
// Preview and Cloud Print messages.
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
@@ -94,6 +94,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
IPC_MESSAGE_CONTROL1(
ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed,
std::string /* printer name */)
-#endif // defined(OS_WIN) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
+#endif // defined(OS_WIN)
#endif // CHROME_COMMON_CHROME_UTILITY_PRINTING_MESSAGES_H_
diff --git chrome/utility/printing_handler.h chrome/utility/printing_handler.h
2018-04-19 17:44:42 +02:00
index 006966fd1c58..db9cd49af2a4 100644
2018-03-20 21:15:08 +01:00
--- chrome/utility/printing_handler.h
+++ chrome/utility/printing_handler.h
@@ -11,7 +11,7 @@
#include "build/build_config.h"
2018-04-19 17:44:42 +02:00
#include "printing/buildflags/buildflags.h"
2018-03-20 21:15:08 +01:00
-#if !defined(OS_WIN) || !BUILDFLAG(ENABLE_PRINT_PREVIEW)
+#if !defined(OS_WIN)
#error "Windows printing and print preview must be enabled"
#endif
2018-02-15 01:12:09 +01:00
2016-07-14 03:35:07 +02:00
diff --git components/printing/common/print_messages.cc components/printing/common/print_messages.cc
2018-04-19 17:44:42 +02:00
index b308dc410ffb..6c92009df454 100644
2016-07-14 03:35:07 +02:00
--- components/printing/common/print_messages.cc
+++ components/printing/common/print_messages.cc
2018-03-20 21:15:08 +01:00
@@ -148,7 +148,6 @@ PrintMsg_PrintFrame_Params::PrintMsg_PrintFrame_Params() {}
PrintMsg_PrintFrame_Params::~PrintMsg_PrintFrame_Params() {}
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
PrintHostMsg_RequestPrintPreview_Params::
PrintHostMsg_RequestPrintPreview_Params()
: is_modifiable(false),
2018-03-20 21:15:08 +01:00
@@ -170,4 +169,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
2018-05-14 13:24:05 +02:00
index b9e8aa76fe5a..12e8b30b339d 100644
2016-07-14 03:35:07 +02:00
--- components/printing/common/print_messages.h
+++ components/printing/common/print_messages.h
2018-03-20 21:15:08 +01:00
@@ -85,7 +85,6 @@ struct PrintMsg_PrintFrame_Params {
int document_cookie;
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
struct PrintHostMsg_RequestPrintPreview_Params {
PrintHostMsg_RequestPrintPreview_Params();
~PrintHostMsg_RequestPrintPreview_Params();
2018-03-20 21:15:08 +01:00
@@ -104,7 +103,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
2017-12-07 22:44:24 +01:00
#endif // INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
2016-02-02 22:32:44 +01:00
2018-03-20 21:15:08 +01:00
@@ -198,7 +196,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)
2018-03-20 21:15:08 +01:00
@@ -219,7 +216,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)
2018-03-20 21:15:08 +01:00
@@ -264,7 +260,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintContent_Params)
IPC_STRUCT_MEMBER(printing::ContentToProxyIdMap, subframe_content_info)
IPC_STRUCT_END()
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
// Parameters to describe a rendered document.
IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
2018-03-20 21:15:08 +01:00
// Document's content including metafile data and subframe info.
@@ -309,7 +304,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
// The id of the preview request.
IPC_STRUCT_MEMBER(int, preview_request_id)
2016-02-02 22:32:44 +01:00
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.
2018-02-15 01:12:09 +01:00
IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintDocument_Params)
2018-03-20 21:15:08 +01:00
@@ -345,10 +339,8 @@ 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.
2018-03-20 21:15:08 +01:00
@@ -373,13 +365,13 @@ 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 */)
2017-10-20 19:45:20 +02:00
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
// Tells the RenderFrame that print preview dialog was closed.
IPC_MESSAGE_ROUTED0(PrintMsg_ClosePrintPreviewDialog)
#endif
2018-03-20 21:15:08 +01:00
@@ -445,7 +437,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 */)
2018-03-20 21:15:08 +01:00
@@ -479,7 +470,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)
2018-03-20 21:15:08 +01:00
@@ -488,7 +478,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 */)
2018-03-20 21:15:08 +01:00
@@ -515,6 +504,5 @@ 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-12-07 22:44:24 +01:00
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
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
2018-05-14 13:24:05 +02:00
index 0d4dcbd43b48..91c430ccead8 100644
2017-09-06 23:40:58 +02:00
--- components/printing/renderer/print_render_frame_helper.cc
+++ components/printing/renderer/print_render_frame_helper.cc
2018-03-20 21:15:08 +01:00
@@ -326,7 +326,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;
2018-03-20 21:15:08 +01:00
@@ -348,7 +347,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:
2018-05-14 13:24:05 +02:00
@@ -403,7 +401,6 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame,
: PRINTABLE_AREA_MARGINS;
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
bool FitToPageEnabled(const base::DictionaryValue& job_settings) {
bool fit_to_paper_size = false;
if (!job_settings.GetBoolean(kSettingFitToPageEnabled, &fit_to_paper_size)) {
2018-05-14 13:24:05 +02:00
@@ -445,7 +442,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.
2018-05-14 13:24:05 +02:00
@@ -949,6 +945,7 @@ PrintRenderFrameHelper::PrintRenderFrameHelper(
2018-02-15 01:12:09 +01:00
notify_browser_of_print_failure_(true),
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),
2018-05-14 13:24:05 +02:00
@@ -1010,10 +1007,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 {
2017-10-20 19:45:20 +02:00
auto weak_this = weak_ptr_factory_.GetWeakPtr();
2018-05-14 13:24:05 +02:00
web_frame->DispatchBeforePrintEvent();
@@ -1041,10 +1036,10 @@ bool PrintRenderFrameHelper::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(PrintRenderFrameHelper, 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
-#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)
2017-10-20 19:45:20 +02:00
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
IPC_MESSAGE_HANDLER(PrintMsg_ClosePrintPreviewDialog,
OnClosePrintPreviewDialog)
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
2018-05-14 13:24:05 +02:00
@@ -1126,7 +1121,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)
2018-05-14 13:24:05 +02:00
@@ -1311,7 +1305,6 @@ bool PrintRenderFrameHelper::CreatePreviewDocument() {
2016-02-02 22:32:44 +01:00
return true;
}
2018-03-20 21:15:08 +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) {
2018-05-14 13:24:05 +02:00
@@ -1339,7 +1332,6 @@ bool PrintRenderFrameHelper::RenderPreviewPage(
2018-03-20 21:15:08 +01:00
print_params.printed_doc_type);
return PreviewPageRendered(page_number, std::move(metafile));
2016-02-02 22:32:44 +01:00
}
2018-03-20 21:15:08 +01:00
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
2016-02-02 22:32:44 +01:00
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_);
2018-05-14 13:24:05 +02:00
@@ -1367,7 +1359,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)
2018-05-14 13:24:05 +02:00
@@ -1382,7 +1373,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;
2018-05-14 13:24:05 +02:00
@@ -1393,7 +1383,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);
2018-05-14 13:24:05 +02:00
@@ -1402,10 +1394,11 @@ void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
2016-02-02 22:32:44 +01:00
: PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME);
}
2017-10-20 19:45:20 +02:00
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void PrintRenderFrameHelper::OnClosePrintPreviewDialog() {
print_preview_context_.source_frame()->DispatchAfterPrintEvent();
}
2016-02-02 22:32:44 +01:00
-#endif
2017-10-20 19:45:20 +02:00
+#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
2016-02-02 22:32:44 +01:00
2018-03-20 21:15:08 +01:00
void PrintRenderFrameHelper::OnPrintFrameContent(
const PrintMsg_PrintFrame_Params& params) {
2018-05-14 13:24:05 +02:00
@@ -1489,11 +1482,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 {
2017-01-23 18:36:54 +01:00
// Make a copy of the node, in case RenderView::OnContextMenuClosed() resets
2018-05-14 13:24:05 +02:00
// its |context_menu_node_|.
@@ -1583,7 +1574,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_) {
2018-05-14 13:24:05 +02:00
@@ -1600,7 +1590,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();
2018-05-14 13:24:05 +02:00
@@ -1768,7 +1757,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();
2018-05-14 13:24:05 +02:00
@@ -1862,7 +1850,6 @@ bool PrintRenderFrameHelper::UpdatePrintSettings(
2018-02-15 01:12:09 +01:00
print_preview_context_.set_error(PREVIEW_ERROR_INVALID_PRINTER_SETTINGS);
2017-01-23 18:36:54 +01:00
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
2017-09-06 23:40:58 +02:00
void PrintRenderFrameHelper::GetPrintSettingsFromUser(
2018-05-14 13:24:05 +02:00
blink::WebLocalFrame* frame,
@@ -2018,7 +2005,6 @@ bool PrintRenderFrameHelper::CopyMetafileDataToReadOnlySharedMem(
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;
2018-05-14 13:24:05 +02:00
@@ -2141,7 +2127,6 @@ bool PrintRenderFrameHelper::PreviewPageRendered(
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
2018-05-14 13:24:05 +02:00
index cccd932eb993..ed7893a67e7a 100644
2017-09-06 23:40:58 +02:00
--- components/printing/renderer/print_render_frame_helper.h
+++ components/printing/renderer/print_render_frame_helper.h
2018-03-20 21:15:08 +01:00
@@ -145,10 +145,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
};
2018-03-20 21:15:08 +01:00
// These values are persisted to logs. Entries should not be renumbered and
2018-05-14 13:24:05 +02:00
@@ -184,9 +182,9 @@ class PrintRenderFrameHelper
// Message handlers ---------------------------------------------------------
2018-02-15 01:12:09 +01:00
void OnPrintPages();
2016-02-02 22:32:44 +01:00
void OnPrintForSystemDialog();
2016-11-23 21:54:29 +01:00
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnInitiatePrintPreview(bool has_selection);
2016-02-02 22:32:44 +01:00
void OnPrintPreview(const base::DictionaryValue& settings);
2017-10-20 19:45:20 +02:00
+#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
void OnClosePrintPreviewDialog();
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
2018-03-20 21:15:08 +01:00
void OnPrintFrameContent(const PrintMsg_PrintFrame_Params& params);
2018-05-14 13:24:05 +02:00
@@ -202,7 +200,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();
2018-05-14 13:24:05 +02:00
@@ -219,7 +216,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);
2018-05-14 13:24:05 +02:00
@@ -247,7 +243,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);
2018-05-14 13:24:05 +02:00
@@ -258,7 +253,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
// Get final print settings from the user.
2018-05-14 13:24:05 +02:00
// WARNING: |this| may be gone after this method returns.
@@ -340,7 +334,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();
2018-05-14 13:24:05 +02:00
@@ -359,7 +352,6 @@ class PrintRenderFrameHelper
2016-02-02 22:32:44 +01:00
// Returns true if print preview should continue, false on failure.
2018-03-20 21:15:08 +01:00
bool PreviewPageRendered(int page_number,
std::unique_ptr<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);
2018-05-14 13:24:05 +02:00
@@ -513,6 +505,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_;
2018-04-19 17:44:42 +02:00
diff --git components/printing_strings.grdp components/printing_strings.grdp
index a669226337f2..5e3c3caa2aa2 100644
--- components/printing_strings.grdp
+++ components/printing_strings.grdp
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
- <if expr="enable_print_preview">
<if expr="is_win">
<message name="IDS_PRINT_PREVIEW_FRIENDLY_WIN_NETWORK_PRINTER_NAME" desc="Friendly name for a printer with a given name on a given server. This uses the same format as the Windows print dialog.">
<ph name="PRINTER_NAME">$1<ex>HP LaserJet</ex></ph> on <ph name="SERVER_NAME">$2<ex>printserver</ex></ph>
</message>
</if>
- </if>
</grit-part>
2018-03-20 21:15:08 +01:00
diff --git components/pwg_encoder/BUILD.gn components/pwg_encoder/BUILD.gn
2018-04-19 17:44:42 +02:00
index 96ae254116a9..3697d6034300 100644
2018-03-20 21:15:08 +01:00
--- components/pwg_encoder/BUILD.gn
+++ components/pwg_encoder/BUILD.gn
@@ -4,8 +4,6 @@
2018-04-19 17:44:42 +02:00
import("//printing/buildflags/buildflags.gni")
2018-03-20 21:15:08 +01:00
-assert(enable_print_preview)
-
static_library("pwg_encoder") {
sources = [
"bitmap_image.cc",