2015-03-24 16:40:08 +01:00
|
|
|
diff --git printing/renderer/print_web_view_helper.cc printing/renderer/print_web_view_helper.cc
|
2016-01-06 20:20:54 +01:00
|
|
|
index c09ad6a..2a92296 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper.cc
|
|
|
|
+++ printing/renderer/print_web_view_helper.cc
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -79,6 +79,9 @@ const double kMinDpi = 1.0;
|
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-01-06 20:20:54 +01:00
|
|
|
@@ -93,9 +96,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-01-06 20:20:54 +01:00
|
|
|
@@ -486,7 +486,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-01-06 20:20:54 +01:00
|
|
|
@@ -542,7 +541,6 @@ void PrintWebViewHelper::PrintHeaderAndFooter(
|
2015-03-24 16:40:08 +01:00
|
|
|
web_view->close();
|
|
|
|
frame->close();
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
// static - Not anonymous so that platform implementations can use it.
|
|
|
|
float PrintWebViewHelper::RenderPageContent(blink::WebFrame* frame,
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -815,6 +813,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-01-06 20:20:54 +01:00
|
|
|
@@ -1254,7 +1253,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-01-06 20:20:54 +01:00
|
|
|
@@ -1287,7 +1288,7 @@ 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_|.
|
2015-10-09 17:23:12 +02:00
|
|
|
- if (!g_is_preview_enabled) {
|
|
|
|
+ if (!g_is_preview_enabled && !force_print_preview_) {
|
2015-07-24 02:06:56 +02:00
|
|
|
blink::WebNode duplicate_node(node);
|
|
|
|
Print(duplicate_node.document().frame(), duplicate_node, false);
|
|
|
|
} else {
|
2015-03-24 16:40:08 +01:00
|
|
|
diff --git printing/renderer/print_web_view_helper.h printing/renderer/print_web_view_helper.h
|
2016-01-06 20:20:54 +01:00
|
|
|
index 0de51e5..da084d0 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper.h
|
|
|
|
+++ printing/renderer/print_web_view_helper.h
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -317,7 +317,6 @@ class PrintWebViewHelper
|
|
|
|
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-01-06 20:20:54 +01:00
|
|
|
@@ -327,7 +326,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-01-06 20:20:54 +01:00
|
|
|
@@ -506,6 +504,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_;
|
2015-03-24 16:40:08 +01:00
|
|
|
diff --git printing/renderer/print_web_view_helper_linux.cc printing/renderer/print_web_view_helper_linux.cc
|
2016-01-06 20:20:54 +01:00
|
|
|
index acc72ed..545178d 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper_linux.cc
|
|
|
|
+++ printing/renderer/print_web_view_helper_linux.cc
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -141,7 +141,6 @@ void PrintWebViewHelper::PrintPageInternal(
|
2015-12-09 17:10:16 +01:00
|
|
|
|
2015-03-24 16:40:08 +01:00
|
|
|
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
if (params.params.display_header_footer) {
|
|
|
|
// |page_number| is 0-based, so 1 is added.
|
|
|
|
// TODO(vitalybuka) : why does it work only with 1.25?
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -150,7 +149,6 @@ void PrintWebViewHelper::PrintPageInternal(
|
2015-03-24 16:40:08 +01:00
|
|
|
scale_factor / 1.25, page_layout_in_points,
|
|
|
|
params.params);
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
RenderPageContent(frame, params.page_number, canvas_area, content_area,
|
|
|
|
scale_factor, canvas);
|
|
|
|
diff --git printing/renderer/print_web_view_helper_mac.mm printing/renderer/print_web_view_helper_mac.mm
|
2016-01-06 20:20:54 +01:00
|
|
|
index e682fa3..3a3aa8e 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper_mac.mm
|
|
|
|
+++ printing/renderer/print_web_view_helper_mac.mm
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -143,14 +143,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));
|
|
|
|
}
|
|
|
|
diff --git printing/renderer/print_web_view_helper_pdf_win.cc printing/renderer/print_web_view_helper_pdf_win.cc
|
2016-01-06 20:20:54 +01:00
|
|
|
index 11401bf..2ed0668 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper_pdf_win.cc
|
|
|
|
+++ printing/renderer/print_web_view_helper_pdf_win.cc
|
2016-01-06 20:20:54 +01:00
|
|
|
@@ -151,14 +151,12 @@ void PrintWebViewHelper::PrintPageInternal(
|
2015-12-09 17:10:16 +01:00
|
|
|
|
2015-03-24 16:40:08 +01:00
|
|
|
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
|
|
|
|
|
|
|
-#if defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
if (params.params.display_header_footer) {
|
|
|
|
// |page_number| is 0-based, so 1 is added.
|
|
|
|
PrintHeaderAndFooter(canvas, params.page_number + 1,
|
|
|
|
print_preview_context_.total_page_count(), *frame,
|
|
|
|
scale_factor, page_layout_in_points, params.params);
|
|
|
|
}
|
|
|
|
-#endif // defined(ENABLE_PRINT_PREVIEW)
|
|
|
|
|
|
|
|
float webkit_scale_factor =
|
|
|
|
RenderPageContent(frame, params.page_number, canvas_area, content_area,
|
|
|
|
diff --git resources/printing_resources.grdp resources/printing_resources.grdp
|
|
|
|
index 7213746..32b8b1e 100644
|
|
|
|
--- resources/printing_resources.grdp
|
|
|
|
+++ resources/printing_resources.grdp
|
|
|
|
@@ -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>
|