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 "components/printing/renderer/print_web_view_helper.h" | 5 #include "components/printing/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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
760 } | 760 } |
761 } | 761 } |
762 frame_.Reset(NULL); | 762 frame_.Reset(NULL); |
763 on_ready_.Reset(); | 763 on_ready_.Reset(); |
764 } | 764 } |
765 | 765 |
766 PrintWebViewHelper::PrintWebViewHelper( | 766 PrintWebViewHelper::PrintWebViewHelper( |
767 content::RenderView* render_view, | 767 content::RenderView* render_view, |
768 bool out_of_process_pdf_enabled, | 768 bool out_of_process_pdf_enabled, |
769 bool print_preview_disabled, | 769 bool print_preview_disabled, |
770 bool should_ask_print_settings, | |
770 scoped_ptr<Delegate> delegate) | 771 scoped_ptr<Delegate> delegate) |
771 : content::RenderViewObserver(render_view), | 772 : content::RenderViewObserver(render_view), |
772 content::RenderViewObserverTracker<PrintWebViewHelper>(render_view), | 773 content::RenderViewObserverTracker<PrintWebViewHelper>(render_view), |
773 reset_prep_frame_view_(false), | 774 reset_prep_frame_view_(false), |
774 is_print_ready_metafile_sent_(false), | 775 is_print_ready_metafile_sent_(false), |
775 ignore_css_margins_(false), | 776 ignore_css_margins_(false), |
776 is_scripted_printing_blocked_(false), | 777 is_scripted_printing_blocked_(false), |
777 notify_browser_of_print_failure_(true), | 778 notify_browser_of_print_failure_(true), |
778 print_for_preview_(false), | 779 print_for_preview_(false), |
779 out_of_process_pdf_enabled_(out_of_process_pdf_enabled), | 780 out_of_process_pdf_enabled_(out_of_process_pdf_enabled), |
781 should_ask_print_settings_(should_ask_print_settings), | |
780 delegate_(delegate.Pass()), | 782 delegate_(delegate.Pass()), |
781 print_node_in_progress_(false), | 783 print_node_in_progress_(false), |
782 is_loading_(false), | 784 is_loading_(false), |
783 is_scripted_preview_delayed_(false), | 785 is_scripted_preview_delayed_(false), |
784 weak_ptr_factory_(this) { | 786 weak_ptr_factory_(this) { |
785 if (print_preview_disabled) | 787 if (print_preview_disabled) |
786 DisablePreview(); | 788 DisablePreview(); |
787 } | 789 } |
788 | 790 |
789 PrintWebViewHelper::~PrintWebViewHelper() {} | 791 PrintWebViewHelper::~PrintWebViewHelper() {} |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1258 return; // Failed to init print page settings. | 1260 return; // Failed to init print page settings. |
1259 } | 1261 } |
1260 | 1262 |
1261 // Some full screen plugins can say they don't want to print. | 1263 // Some full screen plugins can say they don't want to print. |
1262 if (!expected_page_count) { | 1264 if (!expected_page_count) { |
1263 DidFinishPrinting(FAIL_PRINT); | 1265 DidFinishPrinting(FAIL_PRINT); |
1264 return; | 1266 return; |
1265 } | 1267 } |
1266 | 1268 |
1267 // Ask the browser to show UI to retrieve the final print settings. | 1269 // Ask the browser to show UI to retrieve the final print settings. |
1268 if (!GetPrintSettingsFromUser(frame_ref.GetFrame(), node, | 1270 if (should_ask_print_settings_ && |
1271 !GetPrintSettingsFromUser(frame_ref.GetFrame(), node, | |
dgn
2015/01/15 19:28:48
This block is disabled with a #if 0 in webview. I
sgurun-gerrit only
2015/01/15 19:39:32
I think this logic is chrome only. Webview cannot
| |
1269 expected_page_count, | 1272 expected_page_count, |
1270 is_scripted)) { | 1273 is_scripted)) { |
1271 DidFinishPrinting(OK); // Release resources and fail silently. | 1274 DidFinishPrinting(OK); // Release resources and fail silently. |
1272 return; | 1275 return; |
1273 } | 1276 } |
1274 | 1277 |
1275 // Render Pages for printing. | 1278 // Render Pages for printing. |
1276 if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) { | 1279 if (!RenderPagesForPrint(frame_ref.GetFrame(), node)) { |
1277 LOG(ERROR) << "RenderPagesForPrint failed"; | 1280 LOG(ERROR) << "RenderPagesForPrint failed"; |
1278 DidFinishPrinting(FAIL_PRINT); | 1281 DidFinishPrinting(FAIL_PRINT); |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2028 blink::WebConsoleMessage::LevelWarning, message)); | 2031 blink::WebConsoleMessage::LevelWarning, message)); |
2029 return false; | 2032 return false; |
2030 } | 2033 } |
2031 | 2034 |
2032 void PrintWebViewHelper::ScriptingThrottler::Reset() { | 2035 void PrintWebViewHelper::ScriptingThrottler::Reset() { |
2033 // Reset counter on successful print. | 2036 // Reset counter on successful print. |
2034 count_ = 0; | 2037 count_ = 0; |
2035 } | 2038 } |
2036 | 2039 |
2037 } // namespace printing | 2040 } // namespace printing |
OLD | NEW |