Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10898)

Unified Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 740983002: Implement window.print() on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adressed mounir's comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/printing/print_web_view_helper.cc
diff --git a/chrome/renderer/printing/print_web_view_helper.cc b/chrome/renderer/printing/print_web_view_helper.cc
index 201e4c25cfc9c3bcd65485912053db37fa698538..8e0ba5a66c45ff113d881e1d06fedb49a6795819 100644
--- a/chrome/renderer/printing/print_web_view_helper.cc
+++ b/chrome/renderer/printing/print_web_view_helper.cc
@@ -67,6 +67,13 @@ enum PrintPreviewHelperEvents {
const double kMinDpi = 1.0;
+#if defined(OS_ANDROID)
+// Used to trigger the android system dialog from window.print()
+const bool g_is_system_specific_flow_enabled = true;
Vitaly Buka (NO REVIEWS) 2014/12/09 23:46:48 If I read the code correctly you just send value o
dgn 2014/12/10 18:12:52 The parameter I added to the |Print()| function ha
+#else
+const bool g_is_system_specific_flow_enabled = false;
+#endif
+
#if !defined(ENABLE_PRINT_PREVIEW)
bool g_is_preview_enabled_ = false;
#else
@@ -818,9 +825,6 @@ void PrintWebViewHelper::DisablePreview() {
bool PrintWebViewHelper::IsScriptInitiatedPrintAllowed(
blink::WebFrame* frame, bool user_initiated) {
-#if defined(OS_ANDROID)
- return false;
-#endif // defined(OS_ANDROID)
// If preview is enabled, then the print dialog is tab modal, and the user
// can always close the tab on a mis-behaving page (the system print dialog
// is app modal). If the print was initiated through user action, don't
@@ -858,7 +862,7 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
return;
if (!g_is_preview_enabled_) {
- Print(frame, blink::WebNode());
+ Print(frame, blink::WebNode(), g_is_system_specific_flow_enabled);
} else {
print_preview_context_.InitWithFrame(frame);
RequestPrintPreview(PRINT_PREVIEW_SCRIPTED);
@@ -968,6 +972,7 @@ bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
#if defined(ENABLE_BASIC_PRINTING)
void PrintWebViewHelper::OnPrintPages() {
+ DLOG(INFO) << "DGN - OnPrintPages - Call from PrintManager";
blink::WebLocalFrame* frame;
if (!GetPrintFrame(&frame))
return;
@@ -1275,10 +1280,15 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) {
}
void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
- const blink::WebNode& node) {
+ const blink::WebNode& node,
+ const bool use_system_specific_flow) {
// If still not finished with earlier print request simply ignore.
- if (prep_frame_view_)
+ DLOG(INFO) << "DGN Print";
+
+ if (prep_frame_view_) {
+ DLOG(INFO) << "DGN Print request ignored";
return;
+ }
FrameReference frame_ref(frame);
@@ -1288,6 +1298,8 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
return; // Failed to init print page settings.
}
+ DLOG(INFO) << "DGN CalculateNumberOfPages OK";
+
// Some full screen plugins can say they don't want to print.
if (!expected_page_count) {
DidFinishPrinting(FAIL_PRINT);
@@ -1296,11 +1308,14 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
// Ask the browser to show UI to retrieve the final print settings.
if (!GetPrintSettingsFromUser(frame_ref.GetFrame(), node,
- expected_page_count)) {
+ expected_page_count,
+ use_system_specific_flow)) {
DidFinishPrinting(OK); // Release resources and fail silently.
return;
}
+ DLOG(INFO) << "DGN GetPrintSettingsFromUser OK";
+
// Render Pages for printing.
if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) {
LOG(ERROR) << "RenderPagesForPrint failed";
@@ -1573,7 +1588,8 @@ bool PrintWebViewHelper::UpdatePrintSettings(
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebFrame* frame,
const blink::WebNode& node,
- int expected_pages_count) {
+ int expected_pages_count,
+ const bool system_specific) {
PrintHostMsg_ScriptedPrint_Params params;
PrintMsg_PrintPages_Params print_settings;
@@ -1584,6 +1600,7 @@ bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebFrame* frame,
if (PrintingNodeOrPdfFrame(frame, node))
margin_type = GetMarginsForPdf(frame, node);
params.margin_type = margin_type;
+ params.use_system_specific_flow = system_specific;
Send(new PrintHostMsg_DidShowPrintDialog(routing_id()));

Powered by Google App Engine
This is Rietveld 408576698