Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/print_web_view_helper.h" | 5 #include "chrome/renderer/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 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 825 IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) | 825 IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) |
| 826 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, | 826 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, |
| 827 OnPrintNodeUnderContextMenu) | 827 OnPrintNodeUnderContextMenu) |
| 828 IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) | 828 IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) |
| 829 IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) | 829 IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) |
| 830 IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) | 830 IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) |
| 831 IPC_MESSAGE_HANDLER(PrintMsg_ResetScriptedPrintCount, | 831 IPC_MESSAGE_HANDLER(PrintMsg_ResetScriptedPrintCount, |
| 832 ResetScriptedPrintCount) | 832 ResetScriptedPrintCount) |
| 833 IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked, | 833 IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked, |
| 834 SetScriptedPrintBlocked) | 834 SetScriptedPrintBlocked) |
| 835 IPC_MESSAGE_HANDLER(PrintMsg_PrintForFile, OnPrintForFile) | |
| 835 IPC_MESSAGE_UNHANDLED(handled = false) | 836 IPC_MESSAGE_UNHANDLED(handled = false) |
| 836 IPC_END_MESSAGE_MAP() | 837 IPC_END_MESSAGE_MAP() |
| 837 return handled; | 838 return handled; |
| 838 } | 839 } |
| 839 | 840 |
| 840 void PrintWebViewHelper::OnPrintForPrintPreview( | 841 void PrintWebViewHelper::OnPrintForPrintPreview( |
| 841 const DictionaryValue& job_settings) { | 842 const DictionaryValue& job_settings) { |
| 842 DCHECK(is_preview_enabled_); | 843 DCHECK(is_preview_enabled_); |
| 843 // If still not finished with earlier print request simply ignore. | 844 // If still not finished with earlier print request simply ignore. |
| 844 if (print_web_view_) | 845 if (print_web_view_) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 900 void PrintWebViewHelper::OnPrintForSystemDialog() { | 901 void PrintWebViewHelper::OnPrintForSystemDialog() { |
| 901 WebFrame* frame = print_preview_context_.frame(); | 902 WebFrame* frame = print_preview_context_.frame(); |
| 902 if (!frame) { | 903 if (!frame) { |
| 903 NOTREACHED(); | 904 NOTREACHED(); |
| 904 return; | 905 return; |
| 905 } | 906 } |
| 906 | 907 |
| 907 Print(frame, print_preview_context_.node()); | 908 Print(frame, print_preview_context_.node()); |
| 908 } | 909 } |
| 909 | 910 |
| 911 void PrintWebViewHelper::OnPrintForFile() { | |
| 912 OnPrintPages(); | |
|
MAD
2012/06/15 02:54:29
To be removed...
MAD
2012/06/28 15:48:14
Done.
| |
| 913 } | |
| 914 | |
| 910 void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout( | 915 void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout( |
| 911 const printing::PageSizeMargins& page_layout_in_points, | 916 const printing::PageSizeMargins& page_layout_in_points, |
| 912 gfx::Size* page_size, | 917 gfx::Size* page_size, |
| 913 gfx::Rect* content_area) { | 918 gfx::Rect* content_area) { |
| 914 *page_size = gfx::Size( | 919 *page_size = gfx::Size( |
| 915 page_layout_in_points.content_width + | 920 page_layout_in_points.content_width + |
| 916 page_layout_in_points.margin_right + | 921 page_layout_in_points.margin_right + |
| 917 page_layout_in_points.margin_left, | 922 page_layout_in_points.margin_left, |
| 918 page_layout_in_points.content_height + | 923 page_layout_in_points.content_height + |
| 919 page_layout_in_points.margin_top + | 924 page_layout_in_points.margin_top + |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1210 // show UI and wait for the user. | 1215 // show UI and wait for the user. |
| 1211 prepare.reset(); | 1216 prepare.reset(); |
| 1212 | 1217 |
| 1213 // Some full screen plugins can say they don't want to print. | 1218 // Some full screen plugins can say they don't want to print. |
| 1214 if (!expected_page_count) { | 1219 if (!expected_page_count) { |
| 1215 DidFinishPrinting(FAIL_PRINT); | 1220 DidFinishPrinting(FAIL_PRINT); |
| 1216 return; | 1221 return; |
| 1217 } | 1222 } |
| 1218 | 1223 |
| 1219 // Ask the browser to show UI to retrieve the final print settings. | 1224 // Ask the browser to show UI to retrieve the final print settings. |
| 1220 if (!GetPrintSettingsFromUser(frame, node, expected_page_count, | 1225 // if (!GetPrintSettingsFromUser(frame, node, expected_page_count, |
|
MAD
2012/06/15 02:54:29
Need to fix this....
MAD
2012/06/28 15:48:14
Done.
| |
| 1221 use_browser_overlays)) { | 1226 // use_browser_overlays)) { |
| 1222 DidFinishPrinting(OK); // Release resources and fail silently. | 1227 // DidFinishPrinting(OK); // Release resources and fail silently. |
| 1223 return; | 1228 // return; |
| 1224 } | 1229 // } |
| 1225 | 1230 |
| 1226 // Render Pages for printing. | 1231 // Render Pages for printing. |
| 1227 if (!RenderPagesForPrint(frame, node)) { | 1232 if (!RenderPagesForPrint(frame, node)) { |
| 1228 LOG(ERROR) << "RenderPagesForPrint failed"; | 1233 LOG(ERROR) << "RenderPagesForPrint failed"; |
| 1229 DidFinishPrinting(FAIL_PRINT); | 1234 DidFinishPrinting(FAIL_PRINT); |
| 1230 } | 1235 } |
| 1231 ResetScriptedPrintCount(); | 1236 ResetScriptedPrintCount(); |
| 1232 } | 1237 } |
| 1233 | 1238 |
| 1234 void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { | 1239 void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1941 DCHECK(IsRendering()); | 1946 DCHECK(IsRendering()); |
| 1942 return prep_frame_view_->GetPrintCanvasSize(); | 1947 return prep_frame_view_->GetPrintCanvasSize(); |
| 1943 } | 1948 } |
| 1944 | 1949 |
| 1945 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1950 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
| 1946 prep_frame_view_.reset(); | 1951 prep_frame_view_.reset(); |
| 1947 metafile_.reset(); | 1952 metafile_.reset(); |
| 1948 pages_to_render_.clear(); | 1953 pages_to_render_.clear(); |
| 1949 error_ = PREVIEW_ERROR_NONE; | 1954 error_ = PREVIEW_ERROR_NONE; |
| 1950 } | 1955 } |
| OLD | NEW |