2015-03-24 16:40:08 +01:00
|
|
|
diff --git printing/renderer/print_web_view_helper.cc printing/renderer/print_web_view_helper.cc
|
2015-11-10 21:18:16 +01:00
|
|
|
index f2dc502..c0049d0 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper.cc
|
|
|
|
+++ printing/renderer/print_web_view_helper.cc
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -74,6 +74,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();";
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -88,9 +91,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)
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -481,7 +481,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,
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -537,7 +536,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,
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -810,6 +808,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view,
|
2015-07-24 02:06:56 +02:00
|
|
|
print_for_preview_(false),
|
|
|
|
delegate_(delegate.Pass()),
|
|
|
|
print_node_in_progress_(false),
|
|
|
|
+ force_print_preview_(false),
|
|
|
|
is_loading_(false),
|
|
|
|
is_scripted_preview_delayed_(false),
|
|
|
|
ipc_nesting_level_(0),
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -1249,7 +1248,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);
|
2015-11-10 21:18:16 +01:00
|
|
|
@@ -1282,7 +1283,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
|
2015-10-09 17:23:12 +02:00
|
|
|
index d9ea441..dce6b9e 100644
|
2015-03-24 16:40:08 +01:00
|
|
|
--- printing/renderer/print_web_view_helper.h
|
|
|
|
+++ printing/renderer/print_web_view_helper.h
|
2015-06-06 00:06:48 +02:00
|
|
|
@@ -309,7 +309,6 @@ class PrintWebViewHelper
|
2015-03-24 16:40:08 +01:00
|
|
|
double* scale_factor,
|
|
|
|
PageSizeMargins* page_layout_in_points);
|
|
|
|
|
|
|
|
-#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,
|
2015-06-06 00:06:48 +02:00
|
|
|
@@ -319,7 +318,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);
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -498,6 +496,7 @@ class PrintWebViewHelper
|
|
|
|
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
|
2015-12-09 17:10:16 +01:00
|
|
|
index 3e4033d..7a8b61f 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
|
2015-12-09 17:10:16 +01:00
|
|
|
@@ -152,7 +152,6 @@ void PrintWebViewHelper::PrintPageInternal(
|
|
|
|
|
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?
|
2015-12-09 17:10:16 +01:00
|
|
|
@@ -161,7 +160,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
|
2015-12-09 17:10:16 +01:00
|
|
|
index 293f567..601fee6 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
|
2015-12-09 17:10:16 +01:00
|
|
|
@@ -125,14 +125,12 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
|
|
|
|
|
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
|
2015-12-09 17:10:16 +01:00
|
|
|
index 13ad735..fffce71 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
|
2015-12-09 17:10:16 +01:00
|
|
|
@@ -160,14 +160,12 @@ void PrintWebViewHelper::PrintPageInternal(
|
|
|
|
|
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>
|