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

Side by Side Diff: chrome/renderer/print_web_view_helper_linux.cc

Issue 164225: Switch to WebFrame from the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/print_web_view_helper.cc ('k') | chrome/renderer/print_web_view_helper_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/print_web_view_helper.h" 5 #include "chrome/renderer/print_web_view_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "skia/ext/vector_canvas.h" 9 #include "skia/ext/vector_canvas.h"
10 #include "webkit/glue/webframe.h" 10 #include "webkit/api/public/WebFrame.h"
11 11
12 using WebKit::WebFrame;
12 13
13 void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) { 14 void PrintWebViewHelper::Print(WebFrame* frame, bool script_initiated) {
14 // If still not finished with earlier print request simply ignore. 15 // If still not finished with earlier print request simply ignore.
15 if (IsPrinting()) 16 if (IsPrinting())
16 return; 17 return;
17 18
18 // TODO(myhuang): Get printing parameters via IPC. 19 // TODO(myhuang): Get printing parameters via IPC.
19 // For testing purpose, we hard-coded printing parameters here. 20 // For testing purpose, we hard-coded printing parameters here.
20 21
21 // The paper size is US Letter (8.5 in. by 11 in.). 22 // The paper size is US Letter (8.5 in. by 11 in.).
(...skipping 10 matching lines...) Expand all
32 default_settings.dpi = kDPI; 33 default_settings.dpi = kDPI;
33 default_settings.min_shrink = 1.25; 34 default_settings.min_shrink = 1.25;
34 default_settings.max_shrink = 2.0; 35 default_settings.max_shrink = 2.0;
35 default_settings.desired_dpi = kDPI; 36 default_settings.desired_dpi = kDPI;
36 default_settings.document_cookie = NULL; 37 default_settings.document_cookie = NULL;
37 default_settings.selection_only = false; 38 default_settings.selection_only = false;
38 39
39 // Calculate the estimated page count. 40 // Calculate the estimated page count.
40 PrepareFrameAndViewForPrint prep_frame_view(default_settings, 41 PrepareFrameAndViewForPrint prep_frame_view(default_settings,
41 frame, 42 frame,
42 frame->GetView()); 43 frame->view());
43 int expected_pages_count = prep_frame_view.GetExpectedPageCount(); 44 int expected_pages_count = prep_frame_view.GetExpectedPageCount();
44 DCHECK(expected_pages_count); 45 DCHECK(expected_pages_count);
45 46
46 ViewMsg_PrintPage_Params page_params; 47 ViewMsg_PrintPage_Params page_params;
47 page_params.params = default_settings; 48 page_params.params = default_settings;
48 49
49 // TODO(myhuang): Get final printing settings via IPC. 50 // TODO(myhuang): Get final printing settings via IPC.
50 // For testing purpose, we hard-coded printing settings here. 51 // For testing purpose, we hard-coded printing settings here.
51 52
52 // Print the first page only. 53 // Print the first page only.
(...skipping 14 matching lines...) Expand all
67 int size_y = static_cast<int>(canvas_size.height() * 68 int size_y = static_cast<int>(canvas_size.height() *
68 params.params.max_shrink); 69 params.params.max_shrink);
69 // Calculate the dpi adjustment. 70 // Calculate the dpi adjustment.
70 float shrink = static_cast<float>(canvas_size.width()) / 71 float shrink = static_cast<float>(canvas_size.width()) /
71 params.params.printable_size.width(); 72 params.params.printable_size.width();
72 73
73 // TODO(myhuang): We now use VectorCanvas to generate a PS/PDF file for 74 // TODO(myhuang): We now use VectorCanvas to generate a PS/PDF file for
74 // each page in printing. We might also need to create a metafile class 75 // each page in printing. We might also need to create a metafile class
75 // on Linux. 76 // on Linux.
76 skia::VectorCanvas canvas(size_x, size_y); 77 skia::VectorCanvas canvas(size_x, size_y);
77 float webkit_shrink = frame->PrintPage(params.page_number, &canvas); 78 float webkit_shrink = frame->printPage(params.page_number, &canvas);
78 if (shrink <= 0) { 79 if (shrink <= 0) {
79 NOTREACHED() << "Printing page " << params.page_number << " failed."; 80 NOTREACHED() << "Printing page " << params.page_number << " failed.";
80 } else { 81 } else {
81 // Update the dpi adjustment with the "page shrink" calculated in webkit. 82 // Update the dpi adjustment with the "page shrink" calculated in webkit.
82 shrink /= webkit_shrink; 83 shrink /= webkit_shrink;
83 } 84 }
84 } 85 }
85 86
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper.cc ('k') | chrome/renderer/print_web_view_helper_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698