summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorsanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 05:29:07 +0000
committersanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-12 05:29:07 +0000
commit38bba4f8e2f93dd789c3483a3f0c153ca5809793 (patch)
tree18ec7bd6d8cf84dd7492b1f986f210621a79db00 /chrome/renderer
parent31548a10135c11ff689074896237d2b7a404959c (diff)
downloadchromium_src-38bba4f8e2f93dd789c3483a3f0c153ca5809793.zip
chromium_src-38bba4f8e2f93dd789c3483a3f0c153ca5809793.tar.gz
chromium_src-38bba4f8e2f93dd789c3483a3f0c153ca5809793.tar.bz2
Changes made to the printing logic to allow plugins to participate in the browser's print workflow. These changes mainly involve allowing the plugin to specify
whether it wants the browser to use overlays and also changes to the EMF code on Windows to decompress JPEGs/PNGs in the metafile. The related webkit change is https://bugs.webkit.org/show_bug.cgi?id=35550 BUG=None TEST=Test printing with new Pepper plugins that support custom printing. Review URL: http://codereview.chromium.org/745001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41400 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/print_web_view_helper.cc7
-rw-r--r--chrome/renderer/print_web_view_helper.h5
-rw-r--r--chrome/renderer/print_web_view_helper_win.cc9
3 files changed, 16 insertions, 5 deletions
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc
index 32e4064..52aede1 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -29,7 +29,8 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
const ViewMsg_Print_Params& print_params,
WebFrame* frame,
WebView* web_view)
- : frame_(frame), web_view_(web_view), expected_pages_count_(0) {
+ : frame_(frame), web_view_(web_view), expected_pages_count_(0),
+ use_browser_overlays_(true) {
print_canvas_size_.set_width(
printing::ConvertUnit(print_params.printable_size.width(),
static_cast<int>(print_params.dpi),
@@ -53,7 +54,9 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
web_view->resize(print_layout_size);
- expected_pages_count_ = frame->printBegin(print_canvas_size_);
+ expected_pages_count_ = frame->printBegin(
+ print_canvas_size_, static_cast<int>(print_params.dpi),
+ &use_browser_overlays_);
}
PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() {
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h
index 1a4f5aa..45d174b 100644
--- a/chrome/renderer/print_web_view_helper.h
+++ b/chrome/renderer/print_web_view_helper.h
@@ -47,6 +47,10 @@ class PrepareFrameAndViewForPrint {
return expected_pages_count_;
}
+ bool ShouldUseBrowserOverlays() const {
+ return use_browser_overlays_;
+ }
+
const gfx::Size& GetPrintCanvasSize() const {
return print_canvas_size_;
}
@@ -57,6 +61,7 @@ class PrepareFrameAndViewForPrint {
gfx::Size print_canvas_size_;
gfx::Size prev_view_size_;
int expected_pages_count_;
+ bool use_browser_overlays_;
DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint);
};
diff --git a/chrome/renderer/print_web_view_helper_win.cc b/chrome/renderer/print_web_view_helper_win.cc
index b75aa10..09fcb20 100644
--- a/chrome/renderer/print_web_view_helper_win.cc
+++ b/chrome/renderer/print_web_view_helper_win.cc
@@ -71,6 +71,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) {
// Continue only if the settings are valid.
if (default_settings.dpi && default_settings.document_cookie) {
int expected_pages_count = 0;
+ bool use_browser_overlays = true;
// Prepare once to calculate the estimated page count. This must be in
// a scope for itself (see comments on PrepareFrameAndViewForPrint).
@@ -80,6 +81,7 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) {
frame->view());
expected_pages_count = prep_frame_view.GetExpectedPageCount();
DCHECK(expected_pages_count);
+ use_browser_overlays = prep_frame_view.ShouldUseBrowserOverlays();
}
// Ask the browser to show UI to retrieve the final print settings.
@@ -98,9 +100,10 @@ void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) {
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 = frame->hasSelection();
params.has_selection = false;
params.expected_pages_count = expected_pages_count;
+ params.use_overlays = use_browser_overlays;
msg = new ViewHostMsg_ScriptedPrint(routing_id(), params,
&print_settings);
@@ -178,8 +181,8 @@ void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params,
}
void PrintWebViewHelper::PrintPage(const ViewMsg_PrintPage_Params& params,
- const gfx::Size& canvas_size,
- WebFrame* frame) {
+ const gfx::Size& canvas_size,
+ WebFrame* frame) {
// Generate a memory-based metafile. It will use the current screen's DPI.
printing::NativeMetafile metafile;