Commit c7a827e9 authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Merge common code in RenderView::OnPrintPages and RenderView::OnPrintPreview.

BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6296018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72054 0039d316-1c4b-4281-b951-d872f2087c98
parent 4614f197
......@@ -1146,15 +1146,7 @@ void RenderView::OnCaptureSnapshot() {
}
void RenderView::OnPrintPages() {
DCHECK(webview());
if (webview()) {
// If the user has selected text in the currently focused frame we print
// only that frame (this makes print selection work for multiple frames).
if (webview()->focusedFrame()->hasSelection())
Print(webview()->focusedFrame(), false, false);
else
Print(webview()->mainFrame(), false, false);
}
OnPrint(false);
}
void RenderView::OnPrintingDone(int document_cookie, bool success) {
......@@ -1167,15 +1159,7 @@ void RenderView::OnPrintingDone(int document_cookie, bool success) {
}
void RenderView::OnPrintPreview() {
DCHECK(webview());
if (webview()) {
// If the user has selected text in the currently focused frame we print
// only that frame (this makes print selection work for multiple frames).
if (webview()->focusedFrame()->hasSelection())
Print(webview()->focusedFrame(), false, true);
else
Print(webview()->focusedFrame(), false, true);
}
OnPrint(true);
}
void RenderView::OnPrintNodeUnderContextMenu() {
......@@ -5333,6 +5317,18 @@ void RenderView::postAccessibilityNotification(
}
}
void RenderView::OnPrint(bool is_preview) {
DCHECK(webview());
if (webview()) {
// If the user has selected text in the currently focused frame we print
// only that frame (this makes print selection work for multiple frames).
if (webview()->focusedFrame()->hasSelection())
Print(webview()->focusedFrame(), false, is_preview);
else
Print(webview()->mainFrame(), false, is_preview);
}
}
void RenderView::Print(WebFrame* frame,
bool script_initiated,
bool is_preview) {
......
......@@ -1087,6 +1087,9 @@ class RenderView : public RenderWidget,
const WebKit::WebURLError& error,
bool replace);
// Common method for OnPrintPages() and OnPrintPreview().
void OnPrint(bool is_preview);
// Prints |frame|.
void Print(WebKit::WebFrame* frame, bool script_initiated, bool is_preview);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment