From 16cd533f95ab1d2046f64bb6a18df634f62bda80 Mon Sep 17 00:00:00 2001 From: "viettrungluu@chromium.org" Date: Thu, 13 May 2010 17:27:45 +0000 Subject: Fix Print Selection. (And re-enable it on Windows; other platforms need more work.) BUG=22937,27621 TEST=Go to a suitable web page; select something; Ctrl-P to print; select "Selection" under "Page Range"; print; etc. Review URL: http://codereview.chromium.org/1992017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47157 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/print_web_view_helper.cc | 7 ++----- chrome/renderer/print_web_view_helper.h | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index d0ad4db..40fe523 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -153,10 +153,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { // of this message has to deal with this. params.host_window_id = render_view_->host_window(); params.cookie = default_settings.document_cookie; - // TODO(maruel): Reenable once http://crbug.com/22937 is fixed. - // Print selection is broken because DidStopLoading is never called. - // params.has_selection = frame->hasSelection(); - params.has_selection = false; + params.has_selection = frame->hasSelection(); params.expected_pages_count = expected_pages_count; params.use_overlays = use_browser_overlays; @@ -240,7 +237,7 @@ bool PrintWebViewHelper::CopyAndPrint(const ViewMsg_PrintPages_Params& params, print_web_view_ = WebView::create(this); prefs.Apply(print_web_view_); - print_web_view_->initializeMainFrame(NULL); + print_web_view_->initializeMainFrame(this); print_pages_params_.reset(new ViewMsg_PrintPages_Params(params)); print_pages_params_->pages.clear(); // Print all pages of selection. diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h index f80c507..0c971b5 100644 --- a/chrome/renderer/print_web_view_helper.h +++ b/chrome/renderer/print_web_view_helper.h @@ -10,6 +10,7 @@ #include "base/scoped_ptr.h" #include "base/time.h" #include "gfx/size.h" +#include "third_party/WebKit/WebKit/chromium/public/WebFrameClient.h" #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" namespace gfx { @@ -70,7 +71,8 @@ class PrepareFrameAndViewForPrint { // PrintWebViewHelper handles most of the printing grunt work for RenderView. // We plan on making print asynchronous and that will require copying the DOM // of the document and creating a new WebView with the contents. -class PrintWebViewHelper : public WebKit::WebViewClient { +class PrintWebViewHelper : public WebKit::WebViewClient, + public WebKit::WebFrameClient { public: explicit PrintWebViewHelper(RenderView* render_view); virtual ~PrintWebViewHelper(); -- cgit v1.1