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

Side by Side Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 17568014: Remove redundant calls to obtain WebView in PrintWebViewHelper::GetPrintFrame() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 851
852 // Render Pages for printing. 852 // Render Pages for printing.
853 if (!RenderPagesForPrint(pdf_frame, pdf_element)) { 853 if (!RenderPagesForPrint(pdf_frame, pdf_element)) {
854 LOG(ERROR) << "RenderPagesForPrint failed"; 854 LOG(ERROR) << "RenderPagesForPrint failed";
855 DidFinishPrinting(FAIL_PRINT); 855 DidFinishPrinting(FAIL_PRINT);
856 } 856 }
857 } 857 }
858 858
859 bool PrintWebViewHelper::GetPrintFrame(WebKit::WebFrame** frame) { 859 bool PrintWebViewHelper::GetPrintFrame(WebKit::WebFrame** frame) {
860 DCHECK(frame); 860 DCHECK(frame);
861 DCHECK(render_view()->GetWebView()); 861 WebKit::WebView* webView = render_view()->GetWebView();
862 if (!render_view()->GetWebView()) 862 DCHECK(webView);
863 if (!webView)
vivekg_samsung 2013/06/24 09:29:14 Having both "DCHECK(webView)" and "if (!webView) r
863 return false; 864 return false;
864 865
865 // If the user has selected text in the currently focused frame we print 866 // If the user has selected text in the currently focused frame we print
866 // only that frame (this makes print selection work for multiple frames). 867 // only that frame (this makes print selection work for multiple frames).
867 *frame = render_view()->GetWebView()->focusedFrame()->hasSelection() ? 868 WebKit::WebFrame* focusedFrame = webView->focusedFrame();
868 render_view()->GetWebView()->focusedFrame() : 869 *frame = focusedFrame->hasSelection() ? focusedFrame : webView->mainFrame();
869 render_view()->GetWebView()->mainFrame();
870 return true; 870 return true;
871 } 871 }
872 872
873 void PrintWebViewHelper::OnPrintPages() { 873 void PrintWebViewHelper::OnPrintPages() {
874 WebKit::WebFrame* frame; 874 WebKit::WebFrame* frame;
875 if (GetPrintFrame(&frame)) 875 if (GetPrintFrame(&frame))
876 Print(frame, WebKit::WebNode()); 876 Print(frame, WebKit::WebNode());
877 } 877 }
878 878
879 void PrintWebViewHelper::OnPrintForSystemDialog() { 879 void PrintWebViewHelper::OnPrintForSystemDialog() {
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 } 1985 }
1986 1986
1987 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 1987 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
1988 prep_frame_view_.reset(); 1988 prep_frame_view_.reset();
1989 metafile_.reset(); 1989 metafile_.reset();
1990 pages_to_render_.clear(); 1990 pages_to_render_.clear();
1991 error_ = PREVIEW_ERROR_NONE; 1991 error_ = PREVIEW_ERROR_NONE;
1992 } 1992 }
1993 1993
1994 } // namespace printing 1994 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698