mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add print preview support (see issue #123)
Pass the `--enable-print-preview` command-line flag to enable. Currently only supported on Windows and Linux.
This commit is contained in:
committed by
Marshall Greenblatt
parent
cf87c88b05
commit
1669c0afbd
@@ -1,573 +0,0 @@
|
||||
diff --git chrome/app/builtin_service_manifests.cc chrome/app/builtin_service_manifests.cc
|
||||
index 6c9c779d785e..6032d42122d3 100644
|
||||
--- chrome/app/builtin_service_manifests.cc
|
||||
+++ chrome/app/builtin_service_manifests.cc
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "chrome/common/constants.mojom.h"
|
||||
#include "chrome/services/file_util/public/cpp/manifest.h"
|
||||
#include "chrome/services/noop/public/cpp/manifest.h"
|
||||
+#include "chrome/services/printing/public/cpp/manifest.h"
|
||||
#include "components/services/patch/public/cpp/manifest.h"
|
||||
#include "components/services/quarantine/public/cpp/manifest.h"
|
||||
#include "components/services/unzip/public/cpp/manifest.h"
|
||||
@@ -60,10 +61,6 @@
|
||||
#include "components/services/pdf_compositor/public/cpp/manifest.h" // nogncheck
|
||||
#endif
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
-#include "chrome/services/printing/public/cpp/manifest.h"
|
||||
-#endif
|
||||
-
|
||||
#if BUILDFLAG(ENABLE_ISOLATED_XR_SERVICE)
|
||||
#include "chrome/services/isolated_xr_device/manifest.h"
|
||||
#endif
|
||||
diff --git chrome/app/printing_strings.grdp chrome/app/printing_strings.grdp
|
||||
index c7533c13e863..7578f9b6ae71 100644
|
||||
--- chrome/app/printing_strings.grdp
|
||||
+++ chrome/app/printing_strings.grdp
|
||||
@@ -1,11 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Printing specific strings (included from generated_resources.grd). -->
|
||||
<grit-part>
|
||||
- <if expr="enable_print_preview or is_win">
|
||||
<message name="IDS_UTILITY_PROCESS_PRINTING_SERVICE_NAME" desc="The name of the utility process used for printing conversions.">
|
||||
Printing Service
|
||||
</message>
|
||||
- </if>
|
||||
|
||||
<message name="IDS_PRINT_INVALID_PRINTER_SETTINGS" desc="Message to display when selected printer is not reachable or its settings are invalid.">
|
||||
The selected printer is not available or not installed correctly. Check your printer or try selecting another printer.
|
||||
diff --git chrome/browser/ui/cocoa/applescript/tab_applescript.mm chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
||||
index d4c9283b3cef..4a91987bfe7f 100644
|
||||
--- chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
||||
+++ chrome/browser/ui/cocoa/applescript/tab_applescript.mm
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "base/logging.h"
|
||||
#import "base/mac/scoped_nsobject.h"
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
-#include "chrome/browser/printing/print_view_manager.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/sessions/session_tab_helper.h"
|
||||
#include "chrome/browser/ui/cocoa/applescript/apple_event_util.h"
|
||||
@@ -27,6 +27,10 @@
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
+#include "chrome/browser/printing/print_view_manager.h"
|
||||
+#endif
|
||||
+
|
||||
using content::NavigationController;
|
||||
using content::NavigationEntry;
|
||||
using content::OpenURLParams;
|
||||
@@ -234,11 +238,15 @@ void ResumeAppleEventAndSendReply(NSAppleEventManagerSuspensionID suspension_id,
|
||||
|
||||
- (void)handlesPrintScriptCommand:(NSScriptCommand*)command {
|
||||
AppleScript::LogAppleScriptUMA(AppleScript::AppleScriptCommand::TAB_PRINT);
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
bool initiated = printing::PrintViewManager::FromWebContents(webContents_)
|
||||
->PrintNow(webContents_->GetMainFrame());
|
||||
if (!initiated) {
|
||||
AppleScript::SetError(AppleScript::errInitiatePrinting);
|
||||
}
|
||||
+#else
|
||||
+ NOTIMPLEMENTED();
|
||||
+#endif
|
||||
}
|
||||
|
||||
- (void)handlesSaveScriptCommand:(NSScriptCommand*)command {
|
||||
diff --git chrome/browser/ui/webui/settings/printing_handler.cc chrome/browser/ui/webui/settings/printing_handler.cc
|
||||
index 8647b2daf9ea..b070ab3e4b86 100644
|
||||
--- 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
|
||||
diff --git chrome/common/chrome_utility_printing_messages.h chrome/common/chrome_utility_printing_messages.h
|
||||
index 6bd558079c97..6832bf9f297b 100644
|
||||
--- 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
|
||||
index 006966fd1c58..db9cd49af2a4 100644
|
||||
--- chrome/utility/printing_handler.h
|
||||
+++ chrome/utility/printing_handler.h
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "build/build_config.h"
|
||||
#include "printing/buildflags/buildflags.h"
|
||||
|
||||
-#if !defined(OS_WIN) || !BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
+#if !defined(OS_WIN)
|
||||
#error "Windows printing and print preview must be enabled"
|
||||
#endif
|
||||
|
||||
diff --git components/printing/common/print_messages.cc components/printing/common/print_messages.cc
|
||||
index 528773d80a2f..3355de3884cd 100644
|
||||
--- components/printing/common/print_messages.cc
|
||||
+++ components/printing/common/print_messages.cc
|
||||
@@ -131,7 +131,6 @@ PrintMsg_PrintFrame_Params::PrintMsg_PrintFrame_Params() {}
|
||||
|
||||
PrintMsg_PrintFrame_Params::~PrintMsg_PrintFrame_Params() {}
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
PrintHostMsg_RequestPrintPreview_Params::
|
||||
PrintHostMsg_RequestPrintPreview_Params()
|
||||
: is_modifiable(false),
|
||||
@@ -161,4 +160,3 @@ PrintHostMsg_SetOptionsFromDocument_Params::
|
||||
PrintHostMsg_SetOptionsFromDocument_Params::
|
||||
~PrintHostMsg_SetOptionsFromDocument_Params() {
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
diff --git components/printing/common/print_messages.h components/printing/common/print_messages.h
|
||||
index 1802034a6e15..ae0d479ecafa 100644
|
||||
--- components/printing/common/print_messages.h
|
||||
+++ components/printing/common/print_messages.h
|
||||
@@ -85,7 +85,6 @@ struct PrintMsg_PrintFrame_Params {
|
||||
int document_cookie;
|
||||
};
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
struct PrintHostMsg_RequestPrintPreview_Params {
|
||||
PrintHostMsg_RequestPrintPreview_Params();
|
||||
~PrintHostMsg_RequestPrintPreview_Params();
|
||||
@@ -112,7 +111,6 @@ struct PrintHostMsg_SetOptionsFromDocument_Params {
|
||||
printing::DuplexMode duplex;
|
||||
printing::PageRanges page_ranges;
|
||||
};
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
#endif // INTERNAL_COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
|
||||
|
||||
@@ -211,7 +209,6 @@ IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
|
||||
IPC_STRUCT_TRAITS_MEMBER(to)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
|
||||
IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
|
||||
IPC_STRUCT_TRAITS_MEMBER(webnode_only)
|
||||
@@ -237,7 +234,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_SetOptionsFromDocument_Params)
|
||||
// Specifies page range to be printed.
|
||||
IPC_STRUCT_TRAITS_MEMBER(page_ranges)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
|
||||
IPC_STRUCT_TRAITS_MEMBER(content_width)
|
||||
@@ -278,7 +274,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintContent_Params)
|
||||
IPC_STRUCT_MEMBER(printing::ContentToProxyIdMap, subframe_content_info)
|
||||
IPC_STRUCT_END()
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Parameters to describe the to-be-rendered preview document.
|
||||
IPC_STRUCT_BEGIN(PrintHostMsg_DidStartPreview_Params)
|
||||
// Total page count for the rendered preview. (Not the number of pages the
|
||||
@@ -321,7 +316,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
|
||||
// Store the expected pages count.
|
||||
IPC_STRUCT_MEMBER(int, expected_pages_count)
|
||||
IPC_STRUCT_END()
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
// Parameters to describe a rendered page.
|
||||
IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintDocument_Params)
|
||||
@@ -356,20 +350,18 @@ IPC_STRUCT_END()
|
||||
|
||||
// Messages sent from the browser to the renderer.
|
||||
|
||||
-#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
|
||||
|
||||
// Tells the RenderFrame to initiate printing or print preview for a particular
|
||||
// node, depending on which mode the RenderFrame is in.
|
||||
IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINTING)
|
||||
// Tells the RenderFrame to switch the CSS to print media type, renders every
|
||||
// requested pages and switch back the CSS to display media type.
|
||||
IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
|
||||
|
||||
+#if BUILDFLAG(ENABLE_PRINTING)
|
||||
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
|
||||
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
|
||||
#endif
|
||||
@@ -384,7 +376,6 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
|
||||
// Tells the RenderFrame whether printing is enabled or not.
|
||||
IPC_MESSAGE_ROUTED1(PrintMsg_SetPrintingEnabled, bool /* enabled */)
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Tells the RenderFrame 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.
|
||||
@@ -393,7 +384,6 @@ IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
|
||||
|
||||
// Tells the RenderFrame that print preview dialog was closed.
|
||||
IPC_MESSAGE_ROUTED0(PrintMsg_ClosePrintPreviewDialog)
|
||||
-#endif
|
||||
|
||||
// Messages sent from the renderer to the browser.
|
||||
|
||||
@@ -443,7 +433,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
|
||||
PrintMsg_PrintPages_Params
|
||||
/* settings chosen by the user*/)
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Asks the browser to do print preview.
|
||||
IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
|
||||
PrintHostMsg_RequestPrintPreview_Params /* params */)
|
||||
@@ -480,7 +469,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_CheckForCancel,
|
||||
IPC_MESSAGE_ROUTED2(PrintHostMsg_MetafileReadyForPrinting,
|
||||
PrintHostMsg_DidPreviewDocument_Params /* params */,
|
||||
PrintHostMsg_PreviewIds /* ids */)
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
// This is sent when there are invalid printer settings.
|
||||
IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
|
||||
@@ -489,7 +477,6 @@ IPC_MESSAGE_ROUTED0(PrintHostMsg_ShowInvalidPrinterSettingsError)
|
||||
IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
|
||||
int /* document cookie */)
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Tell the browser print preview failed.
|
||||
IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewFailed,
|
||||
int /* document cookie */,
|
||||
@@ -520,6 +507,5 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
|
||||
IPC_MESSAGE_ROUTED2(PrintHostMsg_SetOptionsFromDocument,
|
||||
PrintHostMsg_SetOptionsFromDocument_Params /* params */,
|
||||
PrintHostMsg_PreviewIds /* ids */)
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
#endif // COMPONENTS_PRINTING_COMMON_PRINT_MESSAGES_H_
|
||||
diff --git components/printing/renderer/print_render_frame_helper.cc components/printing/renderer/print_render_frame_helper.cc
|
||||
index 74f26daa76a2..61a02b46e5a6 100644
|
||||
--- components/printing/renderer/print_render_frame_helper.cc
|
||||
+++ components/printing/renderer/print_render_frame_helper.cc
|
||||
@@ -351,7 +351,6 @@ bool IsPrintingNodeOrPdfFrame(const blink::WebLocalFrame* frame,
|
||||
return plugin && plugin->SupportsPaginatedPrint();
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(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;
|
||||
@@ -373,7 +372,6 @@ bool PrintingFrameHasPageSizeStyle(blink::WebLocalFrame* frame,
|
||||
}
|
||||
return frame_has_custom_page_size_style;
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
// Disable scaling when either:
|
||||
@@ -428,7 +426,6 @@ MarginType GetMarginsForPdf(blink::WebLocalFrame* frame,
|
||||
: PRINTABLE_AREA_MARGINS;
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
gfx::Size GetPdfPageSize(const gfx::Size& page_size, int dpi) {
|
||||
return gfx::Size(ConvertUnit(page_size.width(), dpi, kPointsPerInch),
|
||||
ConvertUnit(page_size.height(), dpi, kPointsPerInch));
|
||||
@@ -475,7 +472,6 @@ blink::WebPrintScalingOption GetPrintScalingOption(
|
||||
}
|
||||
return blink::kWebPrintScalingOptionFitToPrintableArea;
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
// Helper function to scale and round an integer value with a double valued
|
||||
// scaling.
|
||||
@@ -1106,10 +1102,8 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
||||
return;
|
||||
|
||||
if (g_is_preview_enabled) {
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
print_preview_context_.InitWithFrame(web_frame);
|
||||
RequestPrintPreview(PRINT_PREVIEW_SCRIPTED);
|
||||
-#endif
|
||||
} else {
|
||||
auto weak_this = weak_ptr_factory_.GetWeakPtr();
|
||||
web_frame->DispatchBeforePrintEvent();
|
||||
@@ -1137,13 +1131,11 @@ bool PrintRenderFrameHelper::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_BEGIN_MESSAGE_MAP(PrintRenderFrameHelper, message)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog)
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_ClosePrintPreviewDialog,
|
||||
OnClosePrintPreviewDialog)
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintFrameContent, OnPrintFrameContent)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_SetPrintingEnabled, OnSetPrintingEnabled)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
@@ -1223,7 +1215,6 @@ void PrintRenderFrameHelper::UpdateFrameMarginsCssInfo(
|
||||
ignore_css_margins_ = (margins_type != DEFAULT_MARGINS);
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
void PrintRenderFrameHelper::OnPrintPreview(
|
||||
const base::DictionaryValue& settings) {
|
||||
if (ipc_nesting_level_ > 1)
|
||||
@@ -1487,7 +1478,6 @@ int PrintRenderFrameHelper::GetFitToPageScaleFactor(
|
||||
printable_height / static_cast<double>(uniform_page_size.height);
|
||||
return static_cast<int>(100.0f * std::min(scale_width, scale_height));
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
void PrintRenderFrameHelper::OnPrintingDone(bool success) {
|
||||
if (ipc_nesting_level_ > 1)
|
||||
@@ -1502,7 +1492,6 @@ void PrintRenderFrameHelper::OnSetPrintingEnabled(bool enabled) {
|
||||
is_printing_enabled_ = enabled;
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
|
||||
if (ipc_nesting_level_ > 1)
|
||||
return;
|
||||
@@ -1513,7 +1502,9 @@ void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
|
||||
// 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);
|
||||
@@ -1525,7 +1516,6 @@ void PrintRenderFrameHelper::OnInitiatePrintPreview(bool has_selection) {
|
||||
void PrintRenderFrameHelper::OnClosePrintPreviewDialog() {
|
||||
print_preview_context_.source_frame()->DispatchAfterPrintEvent();
|
||||
}
|
||||
-#endif
|
||||
|
||||
void PrintRenderFrameHelper::OnPrintFrameContent(
|
||||
const PrintMsg_PrintFrame_Params& params) {
|
||||
@@ -1609,11 +1599,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
|
||||
print_node_in_progress_ = true;
|
||||
|
||||
- if (g_is_preview_enabled) {
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
+ if (g_is_preview_enabled || force_print_preview_) {
|
||||
print_preview_context_.InitWithNode(node);
|
||||
RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE);
|
||||
-#endif
|
||||
} else {
|
||||
// Make a copy of the node, in case RenderView::OnContextMenuClosed() resets
|
||||
// its |context_menu_node_|.
|
||||
@@ -1689,13 +1677,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) {
|
||||
int cookie =
|
||||
print_pages_params_ ? print_pages_params_->params.document_cookie : 0;
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
PrintHostMsg_PreviewIds ids;
|
||||
if (print_pages_params_) {
|
||||
ids.ui_id = print_pages_params_->params.preview_ui_id;
|
||||
ids.request_id = print_pages_params_->params.preview_request_id;
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
switch (result) {
|
||||
case OK:
|
||||
break;
|
||||
@@ -1710,7 +1696,6 @@ void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) {
|
||||
}
|
||||
break;
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
case FAIL_PREVIEW:
|
||||
if (!is_print_ready_metafile_sent_) {
|
||||
if (notify_browser_of_print_failure_) {
|
||||
@@ -1728,7 +1713,6 @@ void PrintRenderFrameHelper::DidFinishPrinting(PrintingResult result) {
|
||||
cookie, ids));
|
||||
print_preview_context_.Failed(false);
|
||||
break;
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
}
|
||||
prep_frame_view_.reset();
|
||||
print_pages_params_.reset();
|
||||
@@ -1901,7 +1885,6 @@ bool PrintRenderFrameHelper::CalculateNumberOfPages(blink::WebLocalFrame* frame,
|
||||
return true;
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
bool PrintRenderFrameHelper::SetOptionsFromPdfDocument(
|
||||
PrintHostMsg_SetOptionsFromDocument_Params* options) {
|
||||
blink::WebLocalFrame* source_frame = print_preview_context_.source_frame();
|
||||
@@ -1986,7 +1969,6 @@ bool PrintRenderFrameHelper::UpdatePrintSettings(
|
||||
print_preview_context_.set_error(PREVIEW_ERROR_INVALID_PRINTER_SETTINGS);
|
||||
return false;
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
void PrintRenderFrameHelper::GetPrintSettingsFromUser(
|
||||
blink::WebLocalFrame* frame,
|
||||
@@ -2138,7 +2120,6 @@ bool PrintRenderFrameHelper::CopyMetafileDataToReadOnlySharedMem(
|
||||
return true;
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
void PrintRenderFrameHelper::ShowScriptedPrintPreview() {
|
||||
if (is_scripted_preview_delayed_) {
|
||||
is_scripted_preview_delayed_ = false;
|
||||
@@ -2264,7 +2245,6 @@ bool PrintRenderFrameHelper::PreviewPageRendered(
|
||||
Send(new PrintHostMsg_DidPreviewPage(routing_id(), preview_page_params, ids));
|
||||
return true;
|
||||
}
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
PrintRenderFrameHelper::PrintPreviewContext::PrintPreviewContext() = default;
|
||||
|
||||
diff --git components/printing/renderer/print_render_frame_helper.h components/printing/renderer/print_render_frame_helper.h
|
||||
index 1e2777561ba6..21c3777010b6 100644
|
||||
--- components/printing/renderer/print_render_frame_helper.h
|
||||
+++ components/printing/renderer/print_render_frame_helper.h
|
||||
@@ -150,10 +150,8 @@ class PrintRenderFrameHelper
|
||||
OK,
|
||||
FAIL_PRINT_INIT,
|
||||
FAIL_PRINT,
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
FAIL_PREVIEW,
|
||||
INVALID_SETTINGS,
|
||||
-#endif
|
||||
};
|
||||
|
||||
// These values are persisted to logs. Entries should not be renumbered and
|
||||
@@ -195,11 +193,9 @@ class PrintRenderFrameHelper
|
||||
// Message handlers ---------------------------------------------------------
|
||||
void OnPrintPages();
|
||||
void OnPrintForSystemDialog();
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
void OnInitiatePrintPreview(bool has_selection);
|
||||
void OnPrintPreview(const base::DictionaryValue& settings);
|
||||
void OnClosePrintPreviewDialog();
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
void OnPrintFrameContent(const PrintMsg_PrintFrame_Params& params);
|
||||
void OnPrintingDone(bool success);
|
||||
|
||||
@@ -213,7 +209,6 @@ class PrintRenderFrameHelper
|
||||
// Update |ignore_css_margins_| based on settings.
|
||||
void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings);
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Prepare frame for creating preview document.
|
||||
void PrepareFrameForPreviewDocument();
|
||||
|
||||
@@ -232,7 +227,6 @@ class PrintRenderFrameHelper
|
||||
|
||||
// Helper method to calculate the scale factor for fit-to-page.
|
||||
int GetFitToPageScaleFactor(const gfx::Rect& printable_area_in_points);
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
// Enable/Disable printing.
|
||||
void OnSetPrintingEnabled(bool enabled);
|
||||
@@ -259,7 +253,6 @@ class PrintRenderFrameHelper
|
||||
const blink::WebNode& node,
|
||||
int* number_of_pages);
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Set options for print preset from source PDF document.
|
||||
bool SetOptionsFromPdfDocument(
|
||||
PrintHostMsg_SetOptionsFromDocument_Params* options);
|
||||
@@ -270,7 +263,6 @@ class PrintRenderFrameHelper
|
||||
bool UpdatePrintSettings(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
const base::DictionaryValue& passed_job_settings);
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
// Get final print settings from the user.
|
||||
// WARNING: |this| may be gone after this method returns.
|
||||
@@ -352,7 +344,6 @@ class PrintRenderFrameHelper
|
||||
bool IsScriptInitiatedPrintAllowed(blink::WebLocalFrame* frame,
|
||||
bool user_initiated);
|
||||
|
||||
-#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Shows scripted print preview when options from plugin are available.
|
||||
void ShowScriptedPrintPreview();
|
||||
|
||||
@@ -371,7 +362,6 @@ class PrintRenderFrameHelper
|
||||
// Returns true if print preview should continue, false on failure.
|
||||
bool PreviewPageRendered(int page_number,
|
||||
std::unique_ptr<MetafileSkia> metafile);
|
||||
-#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
|
||||
void SetPrintPagesParams(const PrintMsg_PrintPages_Params& settings);
|
||||
|
||||
@@ -526,6 +516,7 @@ class PrintRenderFrameHelper
|
||||
ScriptingThrottler scripting_throttler_;
|
||||
|
||||
bool print_node_in_progress_ = false;
|
||||
+ bool force_print_preview_ = false;
|
||||
PrintPreviewContext print_preview_context_;
|
||||
bool is_loading_ = false;
|
||||
bool is_scripted_preview_delayed_ = false;
|
||||
diff --git components/printing_component_strings.grdp components/printing_component_strings.grdp
|
||||
index f3cbf563dee3..d899aab89dfd 100644
|
||||
--- components/printing_component_strings.grdp
|
||||
+++ components/printing_component_strings.grdp
|
||||
@@ -1,12 +1,10 @@
|
||||
<?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>
|
||||
|
||||
<message name="IDS_PDF_COMPOSITOR_SERVICE_DISPLAY_NAME" desc="The display name (in the system task manager, etc) of the service process used for PDF compositing.">
|
||||
PDF Compositor Service
|
||||
diff --git components/pwg_encoder/BUILD.gn components/pwg_encoder/BUILD.gn
|
||||
index 96ae254116a9..3697d6034300 100644
|
||||
--- components/pwg_encoder/BUILD.gn
|
||||
+++ components/pwg_encoder/BUILD.gn
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
import("//printing/buildflags/buildflags.gni")
|
||||
|
||||
-assert(enable_print_preview)
|
||||
-
|
||||
static_library("pwg_encoder") {
|
||||
sources = [
|
||||
"bitmap_image.cc",
|
336
patch/patches/print_preview_123.patch
Normal file
336
patch/patches/print_preview_123.patch
Normal file
@@ -0,0 +1,336 @@
|
||||
diff --git chrome/browser/download/download_prefs.cc chrome/browser/download/download_prefs.cc
|
||||
index 323534a720c1..72b232f0ed85 100644
|
||||
--- chrome/browser/download/download_prefs.cc
|
||||
+++ chrome/browser/download/download_prefs.cc
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "base/strings/sys_string_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/download/chrome_download_manager_delegate.h"
|
||||
#include "chrome/browser/download/download_core_service_factory.h"
|
||||
#include "chrome/browser/download/download_core_service_impl.h"
|
||||
@@ -52,6 +53,10 @@
|
||||
#include "chrome/browser/ui/pdf/adobe_reader_info_win.h"
|
||||
#endif
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+#include "cef/libcef/browser/browser_context.h"
|
||||
+#endif
|
||||
+
|
||||
using content::BrowserContext;
|
||||
using content::BrowserThread;
|
||||
using content::DownloadManager;
|
||||
@@ -303,7 +308,11 @@ DownloadPrefs* DownloadPrefs::FromDownloadManager(
|
||||
// static
|
||||
DownloadPrefs* DownloadPrefs::FromBrowserContext(
|
||||
content::BrowserContext* context) {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
return FromDownloadManager(BrowserContext::GetDownloadManager(context));
|
||||
+#else
|
||||
+ return CefBrowserContext::GetForContext(context)->GetDownloadPrefs();
|
||||
+#endif
|
||||
}
|
||||
|
||||
bool DownloadPrefs::IsFromTrustedSource(const download::DownloadItem& item) {
|
||||
diff --git chrome/browser/printing/print_preview_dialog_controller.cc chrome/browser/printing/print_preview_dialog_controller.cc
|
||||
index c26ddaa9aa12..ad181fdc7478 100644
|
||||
--- chrome/browser/printing/print_preview_dialog_controller.cc
|
||||
+++ chrome/browser/printing/print_preview_dialog_controller.cc
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "base/path_service.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "build/build_config.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
|
||||
@@ -420,8 +421,11 @@ WebContents* PrintPreviewDialogController::CreatePrintPreviewDialog(
|
||||
content::HostZoomMap::Get(preview_dialog->GetSiteInstance())
|
||||
->SetZoomLevelForHostAndScheme(print_url.scheme(), print_url.host(), 0);
|
||||
PrintViewManager::CreateForWebContents(preview_dialog);
|
||||
+
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
|
||||
preview_dialog);
|
||||
+#endif
|
||||
|
||||
// Add an entry to the map.
|
||||
preview_dialog_map_[preview_dialog] = initiator;
|
||||
diff --git chrome/browser/resources/print_preview/ui/destination_dialog.html chrome/browser/resources/print_preview/ui/destination_dialog.html
|
||||
index 624b32bd370e..69b6134bcc41 100644
|
||||
--- chrome/browser/resources/print_preview/ui/destination_dialog.html
|
||||
+++ chrome/browser/resources/print_preview/ui/destination_dialog.html
|
||||
@@ -180,9 +180,7 @@
|
||||
</print-preview-provisional-destination-resolver>
|
||||
</div>
|
||||
<div slot="button-container">
|
||||
- <paper-button on-click="onOpenSettingsPrintPage_">
|
||||
- $i18n{manage}
|
||||
- </paper-button>
|
||||
+ <div></div>
|
||||
<paper-button class="cancel-button" on-click="onCancelButtonClick_">
|
||||
$i18n{cancel}
|
||||
</paper-button>
|
||||
diff --git chrome/browser/resources/print_preview/ui/destination_select.html chrome/browser/resources/print_preview/ui/destination_select.html
|
||||
index d8369b509661..a0791e34b570 100644
|
||||
--- chrome/browser/resources/print_preview/ui/destination_select.html
|
||||
+++ chrome/browser/resources/print_preview/ui/destination_select.html
|
||||
@@ -47,10 +47,6 @@
|
||||
<option value="[[getPdfDestinationKey_()]]" hidden$="[[appKioskMode]]">
|
||||
$i18n{printToPDF}
|
||||
</option>
|
||||
- <option value="[[getGoogleDriveDestinationKey_(activeUser)]]"
|
||||
- hidden$="[[!activeUser]]">
|
||||
- $i18n{printToGoogleDrive}
|
||||
- </option>
|
||||
<if expr="chromeos">
|
||||
<option value="noDestinations"
|
||||
hidden$="[[!noDestinations]]" selected$="[[noDestinations]]">
|
||||
diff --git chrome/browser/ui/webui/constrained_web_dialog_ui.cc chrome/browser/ui/webui/constrained_web_dialog_ui.cc
|
||||
index 12f77178ea92..470b13bd7879 100644
|
||||
--- chrome/browser/ui/webui/constrained_web_dialog_ui.cc
|
||||
+++ chrome/browser/ui/webui/constrained_web_dialog_ui.cc
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "chrome/browser/extensions/tab_helper.h"
|
||||
#endif
|
||||
|
||||
+#include "cef/libcef/features/features.h"
|
||||
+
|
||||
using content::RenderFrameHost;
|
||||
using content::RenderViewHost;
|
||||
using content::WebContents;
|
||||
@@ -57,8 +59,10 @@ class ConstrainedWebDialogDelegateUserData
|
||||
ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui)
|
||||
: WebUIController(web_ui) {
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents());
|
||||
#endif
|
||||
+#endif
|
||||
}
|
||||
|
||||
ConstrainedWebDialogUI::~ConstrainedWebDialogUI() {
|
||||
diff --git chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
|
||||
index e0d6a9034332..d99eb0bfe967 100644
|
||||
--- chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
|
||||
+++ chrome/browser/ui/webui/print_preview/pdf_printer_handler.cc
|
||||
@@ -144,8 +144,10 @@ PdfPrinterHandler::PdfPrinterHandler(Profile* profile,
|
||||
weak_ptr_factory_(this) {}
|
||||
|
||||
PdfPrinterHandler::~PdfPrinterHandler() {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
if (select_file_dialog_.get())
|
||||
select_file_dialog_->ListenerDestroyed();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void PdfPrinterHandler::Reset() {
|
||||
@@ -180,12 +182,14 @@ void PdfPrinterHandler::StartPrint(
|
||||
return;
|
||||
}
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
if (select_file_dialog_ &&
|
||||
select_file_dialog_->IsRunning(
|
||||
platform_util::GetTopLevel(preview_web_contents_->GetNativeView()))) {
|
||||
// Dialog is already showing.
|
||||
return;
|
||||
}
|
||||
+#endif
|
||||
|
||||
DCHECK(!print_callback_);
|
||||
print_callback_ = std::move(callback);
|
||||
@@ -324,7 +328,11 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
|
||||
// If the directory is empty there is no reason to create it or use the
|
||||
// default location.
|
||||
if (path.empty()) {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
OnDirectorySelected(default_filename, path);
|
||||
+#else
|
||||
+ ShowCefSaveAsDialog(initiator, default_filename, path);
|
||||
+#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -334,8 +342,14 @@ void PdfPrinterHandler::SelectFile(const base::FilePath& default_filename,
|
||||
base::PostTaskWithTraitsAndReplyWithResult(
|
||||
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
|
||||
base::BindOnce(&SelectSaveDirectory, path, default_path),
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
base::BindOnce(&PdfPrinterHandler::OnDirectorySelected,
|
||||
weak_ptr_factory_.GetWeakPtr(), default_filename));
|
||||
+#else
|
||||
+ base::BindOnce(&PdfPrinterHandler::ShowCefSaveAsDialog,
|
||||
+ weak_ptr_factory_.GetWeakPtr(), initiator,
|
||||
+ default_filename));
|
||||
+#endif
|
||||
}
|
||||
|
||||
void PdfPrinterHandler::PostPrintToPdfTask() {
|
||||
@@ -351,6 +365,7 @@ void PdfPrinterHandler::OnGotUniqueFileName(const base::FilePath& path) {
|
||||
FileSelected(path, 0, nullptr);
|
||||
}
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
void PdfPrinterHandler::OnDirectorySelected(const base::FilePath& filename,
|
||||
const base::FilePath& directory) {
|
||||
base::FilePath path = directory.Append(filename);
|
||||
@@ -375,5 +390,36 @@ void PdfPrinterHandler::OnDirectorySelected(const base::FilePath& filename,
|
||||
&file_type_info, 0, base::FilePath::StringType(),
|
||||
platform_util::GetTopLevel(preview_web_contents_->GetNativeView()), NULL);
|
||||
}
|
||||
+#else
|
||||
+void PdfPrinterHandler::ShowCefSaveAsDialog(content::WebContents* initiator,
|
||||
+ const base::FilePath& filename,
|
||||
+ const base::FilePath& directory) {
|
||||
+ CefRefPtr<CefBrowserHostImpl> cef_browser =
|
||||
+ CefBrowserHostImpl::GetBrowserForContents(initiator);
|
||||
+ if (!cef_browser)
|
||||
+ return;
|
||||
+
|
||||
+ base::FilePath path = directory.Append(filename);
|
||||
+
|
||||
+ CefFileDialogRunner::FileChooserParams params;
|
||||
+ params.mode = blink::mojom::FileChooserParams::Mode::kSave;
|
||||
+ params.default_file_name = path;
|
||||
+ params.accept_types.push_back(CefString(path.Extension()));
|
||||
+
|
||||
+ cef_browser->RunFileChooser(
|
||||
+ params, base::Bind(&PdfPrinterHandler::SaveAsDialogDismissed,
|
||||
+ weak_ptr_factory_.GetWeakPtr()));
|
||||
+}
|
||||
+
|
||||
+void PdfPrinterHandler::SaveAsDialogDismissed(
|
||||
+ int selected_accept_filter,
|
||||
+ const std::vector<base::FilePath>& file_paths) {
|
||||
+ if (file_paths.size() == 1) {
|
||||
+ FileSelected(file_paths[0], 0, nullptr);
|
||||
+ } else {
|
||||
+ FileSelectionCanceled(nullptr);
|
||||
+ }
|
||||
+}
|
||||
+#endif
|
||||
|
||||
} // namespace printing
|
||||
diff --git chrome/browser/ui/webui/print_preview/pdf_printer_handler.h chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
|
||||
index eae9098f2136..b4cffbcceb02 100644
|
||||
--- chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
|
||||
+++ chrome/browser/ui/webui/print_preview/pdf_printer_handler.h
|
||||
@@ -11,13 +11,19 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/strings/string16.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/ui/webui/print_preview/printer_handler.h"
|
||||
+
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
#include "ui/shell_dialogs/select_file_dialog.h"
|
||||
+#else
|
||||
+#include "cef/libcef/browser/browser_host_impl.h"
|
||||
+#endif
|
||||
|
||||
namespace base {
|
||||
class FilePath;
|
||||
class RefCountedMemory;
|
||||
-}
|
||||
+} // namespace base
|
||||
|
||||
namespace content {
|
||||
class WebContents;
|
||||
@@ -78,17 +84,28 @@ class PdfPrinterHandler : public PrinterHandler,
|
||||
// The print preview web contents. Protected so unit tests can access it.
|
||||
content::WebContents* const preview_web_contents_;
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
// The underlying dialog object. Protected so unit tests can access it.
|
||||
scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
|
||||
+#endif
|
||||
|
||||
private:
|
||||
void PostPrintToPdfTask();
|
||||
void OnGotUniqueFileName(const base::FilePath& path);
|
||||
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
// Prompts the user to save the file. The dialog will default to saving
|
||||
// the file with name |filename| in |directory|.
|
||||
void OnDirectorySelected(const base::FilePath& filename,
|
||||
const base::FilePath& directory);
|
||||
+#else
|
||||
+ void ShowCefSaveAsDialog(content::WebContents* initiator,
|
||||
+ const base::FilePath& filename,
|
||||
+ const base::FilePath& directory);
|
||||
+
|
||||
+ void SaveAsDialogDismissed(int selected_accept_filter,
|
||||
+ const std::vector<base::FilePath>& file_paths);
|
||||
+#endif
|
||||
|
||||
Profile* const profile_;
|
||||
StickySettings* const sticky_settings_;
|
||||
diff --git chrome/browser/ui/webui/print_preview/print_preview_handler.cc chrome/browser/ui/webui/print_preview/print_preview_handler.cc
|
||||
index 47528eaccd78..2ecd9e3d5c03 100644
|
||||
--- chrome/browser/ui/webui/print_preview/print_preview_handler.cc
|
||||
+++ chrome/browser/ui/webui/print_preview/print_preview_handler.cc
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/values.h"
|
||||
#include "build/build_config.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/app_mode/app_mode_utils.h"
|
||||
#include "chrome/browser/bad_message.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
@@ -1243,6 +1244,9 @@ PrinterHandler* PrintPreviewHandler::GetPrinterHandler(
|
||||
}
|
||||
return privet_printer_handler_.get();
|
||||
}
|
||||
+#else // !BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
|
||||
+ if (printer_type == PrinterType::kPrivetPrinter)
|
||||
+ return nullptr;
|
||||
#endif
|
||||
if (printer_type == PrinterType::kPdfPrinter) {
|
||||
if (!pdf_printer_handler_) {
|
||||
@@ -1325,6 +1329,7 @@ void PrintPreviewHandler::OnPrintResult(const std::string& callback_id,
|
||||
}
|
||||
|
||||
void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
|
||||
+#if !BUILDFLAG(ENABLE_CEF)
|
||||
DCHECK(!identity_manager_);
|
||||
cloud_print_enabled_ =
|
||||
GetPrefs()->GetBoolean(prefs::kCloudPrintSubmitEnabled);
|
||||
@@ -1340,6 +1345,7 @@ void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
|
||||
|
||||
identity_manager_ = IdentityManagerFactory::GetForProfile(profile);
|
||||
identity_manager_->AddObserver(this);
|
||||
+#endif
|
||||
}
|
||||
|
||||
void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
|
||||
diff --git chrome/browser/ui/webui/print_preview/print_preview_ui.cc chrome/browser/ui/webui/print_preview/print_preview_ui.cc
|
||||
index f90198efcf2a..d866bf90c13a 100644
|
||||
--- chrome/browser/ui/webui/print_preview/print_preview_ui.cc
|
||||
+++ chrome/browser/ui/webui/print_preview/print_preview_ui.cc
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/values.h"
|
||||
#include "build/build_config.h"
|
||||
+#include "cef/libcef/features/features.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/printing/background_printing_manager.h"
|
||||
#include "chrome/browser/printing/print_preview_data_service.h"
|
||||
@@ -73,12 +74,16 @@ namespace printing {
|
||||
|
||||
namespace {
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+const char kBasicPrintShortcut[] = "";
|
||||
+#else
|
||||
#if defined(OS_MACOSX)
|
||||
// U+0028 U+21E7 U+2318 U+0050 U+0029 in UTF8
|
||||
const char kBasicPrintShortcut[] = "\x28\xE2\x8c\xA5\xE2\x8C\x98\x50\x29";
|
||||
#elif !defined(OS_CHROMEOS)
|
||||
const char kBasicPrintShortcut[] = "(Ctrl+Shift+P)";
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
PrintPreviewUI::TestDelegate* g_test_delegate = nullptr;
|
||||
|
Reference in New Issue
Block a user