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

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

Issue 581163002: Removed unused argument and GetPrintCanvasSize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_rot
Patch Set: Thu 09/18/2014 11:42:21.91 Created 6 years, 3 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
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 554 }
555 555
556 const blink::WebNode& node() const { 556 const blink::WebNode& node() const {
557 return node_to_print_; 557 return node_to_print_;
558 } 558 }
559 559
560 int GetExpectedPageCount() const { 560 int GetExpectedPageCount() const {
561 return expected_pages_count_; 561 return expected_pages_count_;
562 } 562 }
563 563
564 gfx::Size GetPrintCanvasSize() const;
565
566 void FinishPrinting(); 564 void FinishPrinting();
567 565
568 bool IsLoadingSelection() { 566 bool IsLoadingSelection() {
569 // It's not selection if not |owns_web_view_|. 567 // It's not selection if not |owns_web_view_|.
570 return owns_web_view_ && frame() && frame()->isLoading(); 568 return owns_web_view_ && frame() && frame()->isLoading();
571 } 569 }
572 570
573 // TODO(ojan): Remove this override and have this class use a non-null 571 // TODO(ojan): Remove this override and have this class use a non-null
574 // layerTreeView. 572 // layerTreeView.
575 // blink::WebViewClient override: 573 // blink::WebViewClient override:
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) { 733 void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame) {
736 if (frame->parent()) 734 if (frame->parent())
737 frame->parent()->removeChild(frame); 735 frame->parent()->removeChild(frame);
738 frame->close(); 736 frame->close();
739 } 737 }
740 738
741 void PrepareFrameAndViewForPrint::CallOnReady() { 739 void PrepareFrameAndViewForPrint::CallOnReady() {
742 return on_ready_.Run(); // Can delete |this|. 740 return on_ready_.Run(); // Can delete |this|.
743 } 741 }
744 742
745 gfx::Size PrepareFrameAndViewForPrint::GetPrintCanvasSize() const {
746 DCHECK(is_printing_started_);
747 return gfx::Size(web_print_params_.printContentArea.width,
748 web_print_params_.printContentArea.height);
749 }
750
751 void PrepareFrameAndViewForPrint::RestoreSize() { 743 void PrepareFrameAndViewForPrint::RestoreSize() {
752 if (frame()) { 744 if (frame()) {
753 blink::WebView* web_view = frame_.GetFrame()->view(); 745 blink::WebView* web_view = frame_.GetFrame()->view();
754 web_view->resize(prev_view_size_); 746 web_view->resize(prev_view_size_);
755 if (blink::WebFrame* web_frame = web_view->mainFrame()) 747 if (blink::WebFrame* web_frame = web_view->mainFrame())
756 web_frame->setScrollOffset(prev_scroll_offset_); 748 web_frame->setScrollOffset(prev_scroll_offset_);
757 } 749 }
758 } 750 }
759 751
760 void PrepareFrameAndViewForPrint::FinishPrinting() { 752 void PrepareFrameAndViewForPrint::FinishPrinting() {
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 int printed_count = params.pages.empty() ? page_count : params.pages.size(); 1342 int printed_count = params.pages.empty() ? page_count : params.pages.size();
1351 #if !defined(OS_CHROMEOS) 1343 #if !defined(OS_CHROMEOS)
1352 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", printed_count); 1344 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", printed_count);
1353 #else 1345 #else
1354 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrintWebDialog", 1346 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrintWebDialog",
1355 printed_count); 1347 printed_count);
1356 #endif // !defined(OS_CHROMEOS) 1348 #endif // !defined(OS_CHROMEOS)
1357 } 1349 }
1358 1350
1359 1351
1360 if (!PrintPagesNative(prep_frame_view_->frame(), page_count, 1352 if (!PrintPagesNative(prep_frame_view_->frame(), page_count)) {
1361 prep_frame_view_->GetPrintCanvasSize())) {
1362 LOG(ERROR) << "Printing failed."; 1353 LOG(ERROR) << "Printing failed.";
1363 return DidFinishPrinting(FAIL_PRINT); 1354 return DidFinishPrinting(FAIL_PRINT);
1364 } 1355 }
1365 } 1356 }
1366 1357
1367 void PrintWebViewHelper::FinishFramePrinting() { 1358 void PrintWebViewHelper::FinishFramePrinting() {
1368 prep_frame_view_.reset(); 1359 prep_frame_view_.reset();
1369 } 1360 }
1370 1361
1371 #if defined(OS_MACOSX) 1362 #if defined(OS_MACOSX)
1372 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame, 1363 bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
1373 int page_count, 1364 int page_count) {
1374 const gfx::Size& canvas_size) {
1375 const PrintMsg_PrintPages_Params& params = *print_pages_params_; 1365 const PrintMsg_PrintPages_Params& params = *print_pages_params_;
1376 const PrintMsg_Print_Params& print_params = params.params; 1366 const PrintMsg_Print_Params& print_params = params.params;
1377 1367
1378 PrintMsg_PrintPage_Params page_params; 1368 PrintMsg_PrintPage_Params page_params;
1379 page_params.params = print_params; 1369 page_params.params = print_params;
1380 if (params.pages.empty()) { 1370 if (params.pages.empty()) {
1381 for (int i = 0; i < page_count; ++i) { 1371 for (int i = 0; i < page_count; ++i) {
1382 page_params.page_number = i; 1372 page_params.page_number = i;
1383 PrintPageInternal(page_params, canvas_size, frame); 1373 PrintPageInternal(page_params, frame);
1384 } 1374 }
1385 } else { 1375 } else {
1386 for (size_t i = 0; i < params.pages.size(); ++i) { 1376 for (size_t i = 0; i < params.pages.size(); ++i) {
1387 if (params.pages[i] >= page_count) 1377 if (params.pages[i] >= page_count)
1388 break; 1378 break;
1389 page_params.page_number = params.pages[i]; 1379 page_params.page_number = params.pages[i];
1390 PrintPageInternal(page_params, canvas_size, frame); 1380 PrintPageInternal(page_params, frame);
1391 } 1381 }
1392 } 1382 }
1393 return true; 1383 return true;
1394 } 1384 }
1395 1385
1396 #endif // OS_MACOSX 1386 #endif // OS_MACOSX
1397 1387
1398 // static - Not anonymous so that platform implementations can use it. 1388 // static - Not anonymous so that platform implementations can use it.
1399 void PrintWebViewHelper::ComputePageLayoutInPointsForCss( 1389 void PrintWebViewHelper::ComputePageLayoutInPointsForCss(
1400 blink::WebFrame* frame, 1390 blink::WebFrame* frame,
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 1957
1968 PdfMetafileSkia* PrintWebViewHelper::PrintPreviewContext::metafile() { 1958 PdfMetafileSkia* PrintWebViewHelper::PrintPreviewContext::metafile() {
1969 DCHECK(IsRendering()); 1959 DCHECK(IsRendering());
1970 return metafile_.get(); 1960 return metafile_.get();
1971 } 1961 }
1972 1962
1973 int PrintWebViewHelper::PrintPreviewContext::last_error() const { 1963 int PrintWebViewHelper::PrintPreviewContext::last_error() const {
1974 return error_; 1964 return error_;
1975 } 1965 }
1976 1966
1977 gfx::Size PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const {
1978 DCHECK(IsRendering());
1979 return prep_frame_view_->GetPrintCanvasSize();
1980 }
1981
1982 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 1967 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
1983 prep_frame_view_.reset(); 1968 prep_frame_view_.reset();
1984 metafile_.reset(); 1969 metafile_.reset();
1985 pages_to_render_.clear(); 1970 pages_to_render_.clear();
1986 error_ = PREVIEW_ERROR_NONE; 1971 error_ = PREVIEW_ERROR_NONE;
1987 } 1972 }
1988 1973
1989 void PrintWebViewHelper::SetPrintPagesParams( 1974 void PrintWebViewHelper::SetPrintPagesParams(
1990 const PrintMsg_PrintPages_Params& settings) { 1975 const PrintMsg_PrintPages_Params& settings) {
1991 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); 1976 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 blink::WebConsoleMessage::LevelWarning, message)); 2017 blink::WebConsoleMessage::LevelWarning, message));
2033 return false; 2018 return false;
2034 } 2019 }
2035 2020
2036 void PrintWebViewHelper::ScriptingThrottler::Reset() { 2021 void PrintWebViewHelper::ScriptingThrottler::Reset() {
2037 // Reset counter on successful print. 2022 // Reset counter on successful print.
2038 count_ = 0; 2023 count_ = 0;
2039 } 2024 }
2040 2025
2041 } // namespace printing 2026 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | chrome/renderer/printing/print_web_view_helper_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698