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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 6479004: Print Preview: Hook up the print button to initiate a normal print operation.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: add a comment Created 9 years, 10 months 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
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/print_web_view_helper.cc
===================================================================
--- chrome/renderer/print_web_view_helper.cc (revision 75293)
+++ chrome/renderer/print_web_view_helper.cc (working copy)
@@ -32,6 +32,8 @@
using printing::ConvertUnit;
using printing::ConvertUnitDouble;
using WebKit::WebConsoleMessage;
+using WebKit::WebDocument;
+using WebKit::WebElement;
using WebKit::WebFrame;
using WebKit::WebNode;
using WebKit::WebRect;
@@ -121,6 +123,8 @@
bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
+ IPC_MESSAGE_HANDLER(ViewMsg_PrintForPrintPreview,
+ OnPrintForPrintPreview)
IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages)
IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone)
IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview)
@@ -131,6 +135,25 @@
return handled;
}
+void PrintWebViewHelper::OnPrintForPrintPreview() {
+ if (!render_view()->webview())
+ return;
+ WebFrame* main_frame = render_view()->webview()->mainFrame();
+ if (!main_frame)
+ return;
+
+ WebDocument document = main_frame->document();
+ // <object> with id="pdf-viewer" is created in
+ // chrome/browser/resources/print_preview.js
+ WebElement element = document.getElementById("pdf-viewer");
+ if (element.isNull()) {
+ NOTREACHED();
+ return;
+ }
+
+ PrintNode(&element, false, false);
+}
+
void PrintWebViewHelper::OnPrint(bool is_preview) {
DCHECK(render_view()->webview());
if (!render_view()->webview())
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698