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

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

Issue 546373002: Revert of More System Dialog printing code disabled on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@522493002
Patch Set: Mon Sep 8 00:14:11 PDT 2014 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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 827
828 if (!IsScriptInitiatedPrintAllowed(frame, user_initiated)) 828 if (!IsScriptInitiatedPrintAllowed(frame, user_initiated))
829 return; 829 return;
830 print_preview_context_.InitWithFrame(frame); 830 print_preview_context_.InitWithFrame(frame);
831 RequestPrintPreview(PRINT_PREVIEW_SCRIPTED); 831 RequestPrintPreview(PRINT_PREVIEW_SCRIPTED);
832 } 832 }
833 833
834 bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { 834 bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
835 bool handled = true; 835 bool handled = true;
836 IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message) 836 IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
837 #if !defined(OS_WIN)
838 IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) 837 IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
839 IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog) 838 IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog)
840 #endif // !OS_WIN
841 IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) 839 IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)
842 IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) 840 IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
843 IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) 841 IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview)
844 IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) 842 IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone)
845 IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked, 843 IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked,
846 SetScriptedPrintBlocked) 844 SetScriptedPrintBlocked)
847 IPC_MESSAGE_UNHANDLED(handled = false) 845 IPC_MESSAGE_UNHANDLED(handled = false)
848 IPC_END_MESSAGE_MAP() 846 IPC_END_MESSAGE_MAP()
849 return handled; 847 return handled;
850 } 848 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 // If the user has selected text in the currently focused frame we print 925 // If the user has selected text in the currently focused frame we print
928 // only that frame (this makes print selection work for multiple frames). 926 // only that frame (this makes print selection work for multiple frames).
929 blink::WebLocalFrame* focusedFrame = 927 blink::WebLocalFrame* focusedFrame =
930 webView->focusedFrame()->toWebLocalFrame(); 928 webView->focusedFrame()->toWebLocalFrame();
931 *frame = focusedFrame->hasSelection() 929 *frame = focusedFrame->hasSelection()
932 ? focusedFrame 930 ? focusedFrame
933 : webView->mainFrame()->toWebLocalFrame(); 931 : webView->mainFrame()->toWebLocalFrame();
934 return true; 932 return true;
935 } 933 }
936 934
937 #if !defined(OS_WIN)
938 void PrintWebViewHelper::OnPrintPages() { 935 void PrintWebViewHelper::OnPrintPages() {
939 blink::WebLocalFrame* frame; 936 blink::WebLocalFrame* frame;
940 if (GetPrintFrame(&frame)) 937 if (GetPrintFrame(&frame))
941 Print(frame, blink::WebNode()); 938 Print(frame, blink::WebNode());
942 } 939 }
943 940
944 void PrintWebViewHelper::OnPrintForSystemDialog() { 941 void PrintWebViewHelper::OnPrintForSystemDialog() {
945 blink::WebLocalFrame* frame = print_preview_context_.source_frame(); 942 blink::WebLocalFrame* frame = print_preview_context_.source_frame();
946 if (!frame) { 943 if (!frame) {
947 NOTREACHED(); 944 NOTREACHED();
948 return; 945 return;
949 } 946 }
947
950 Print(frame, print_preview_context_.source_node()); 948 Print(frame, print_preview_context_.source_node());
951 } 949 }
952 #endif // !OS_WIN
953 950
954 void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout( 951 void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout(
955 const PageSizeMargins& page_layout_in_points, 952 const PageSizeMargins& page_layout_in_points,
956 gfx::Size* page_size, 953 gfx::Size* page_size,
957 gfx::Rect* content_area) { 954 gfx::Rect* content_area) {
958 *page_size = gfx::Size( 955 *page_size = gfx::Size(
959 page_layout_in_points.content_width + 956 page_layout_in_points.content_width +
960 page_layout_in_points.margin_right + 957 page_layout_in_points.margin_right +
961 page_layout_in_points.margin_left, 958 page_layout_in_points.margin_left,
962 page_layout_in_points.content_height + 959 page_layout_in_points.content_height +
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 print_node_in_progress_ = true; 1216 print_node_in_progress_ = true;
1220 1217
1221 // Make a copy of the node, in case RenderView::OnContextMenuClosed resets 1218 // Make a copy of the node, in case RenderView::OnContextMenuClosed resets
1222 // its |context_menu_node_|. 1219 // its |context_menu_node_|.
1223 print_preview_context_.InitWithNode(node); 1220 print_preview_context_.InitWithNode(node);
1224 RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE); 1221 RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE);
1225 1222
1226 print_node_in_progress_ = false; 1223 print_node_in_progress_ = false;
1227 } 1224 }
1228 1225
1229 #if !defined(OS_WIN)
1230 void PrintWebViewHelper::Print(blink::WebLocalFrame* frame, 1226 void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
1231 const blink::WebNode& node) { 1227 const blink::WebNode& node) {
1232 // If still not finished with earlier print request simply ignore. 1228 // If still not finished with earlier print request simply ignore.
1233 if (prep_frame_view_) 1229 if (prep_frame_view_)
1234 return; 1230 return;
1235 1231
1236 FrameReference frame_ref(frame); 1232 FrameReference frame_ref(frame);
1237 1233
1238 int expected_page_count = 0; 1234 int expected_page_count = 0;
1239 if (!CalculateNumberOfPages(frame, node, &expected_page_count)) { 1235 if (!CalculateNumberOfPages(frame, node, &expected_page_count)) {
(...skipping 13 matching lines...) Expand all
1253 DidFinishPrinting(OK); // Release resources and fail silently. 1249 DidFinishPrinting(OK); // Release resources and fail silently.
1254 return; 1250 return;
1255 } 1251 }
1256 1252
1257 // Render Pages for printing. 1253 // Render Pages for printing.
1258 if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) { 1254 if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) {
1259 LOG(ERROR) << "RenderPagesForPrint failed"; 1255 LOG(ERROR) << "RenderPagesForPrint failed";
1260 DidFinishPrinting(FAIL_PRINT); 1256 DidFinishPrinting(FAIL_PRINT);
1261 } 1257 }
1262 } 1258 }
1263 #endif // !OS_WIN
1264 1259
1265 void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { 1260 void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
1266 switch (result) { 1261 switch (result) {
1267 case OK: 1262 case OK:
1268 break; 1263 break;
1269 1264
1270 case FAIL_PRINT_INIT: 1265 case FAIL_PRINT_INIT:
1271 DCHECK(!notify_browser_of_print_failure_); 1266 DCHECK(!notify_browser_of_print_failure_);
1272 break; 1267 break;
1273 1268
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 } 1959 }
1965 1960
1966 void PrintWebViewHelper::SetPrintPagesParams( 1961 void PrintWebViewHelper::SetPrintPagesParams(
1967 const PrintMsg_PrintPages_Params& settings) { 1962 const PrintMsg_PrintPages_Params& settings) {
1968 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); 1963 print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings));
1969 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(), 1964 Send(new PrintHostMsg_DidGetDocumentCookie(routing_id(),
1970 settings.params.document_cookie)); 1965 settings.params.document_cookie));
1971 } 1966 }
1972 1967
1973 } // namespace printing 1968 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | chrome/renderer/printing/print_web_view_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698