| 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/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" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/print_messages.h" | 20 #include "chrome/common/print_messages.h" |
| 21 #include "chrome/common/render_messages.h" | 21 #include "chrome/common/render_messages.h" |
| 22 #include "chrome/renderer/prerender/prerender_helper.h" | 22 #include "chrome/renderer/prerender/prerender_helper.h" |
| 23 #include "content/public/renderer/render_frame.h" |
| 23 #include "content/public/renderer/render_thread.h" | 24 #include "content/public/renderer/render_thread.h" |
| 24 #include "content/public/renderer/render_view.h" | 25 #include "content/public/renderer/render_view.h" |
| 25 #include "content/public/renderer/web_preferences.h" | 26 #include "content/public/renderer/web_preferences.h" |
| 26 #include "grit/browser_resources.h" | 27 #include "grit/browser_resources.h" |
| 27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 28 #include "net/base/escape.h" | 29 #include "net/base/escape.h" |
| 29 #include "printing/metafile.h" | 30 #include "printing/metafile.h" |
| 30 #include "printing/metafile_impl.h" | 31 #include "printing/metafile_impl.h" |
| 31 #include "printing/units.h" | 32 #include "printing/units.h" |
| 32 #include "skia/ext/vector_platform_device_skia.h" | 33 #include "skia/ext/vector_platform_device_skia.h" |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 is_loading_ = false; | 751 is_loading_ = false; |
| 751 ShowScriptedPrintPreview(); | 752 ShowScriptedPrintPreview(); |
| 752 } | 753 } |
| 753 | 754 |
| 754 // Prints |frame| which called window.print(). | 755 // Prints |frame| which called window.print(). |
| 755 void PrintWebViewHelper::PrintPage(blink::WebFrame* frame, | 756 void PrintWebViewHelper::PrintPage(blink::WebFrame* frame, |
| 756 bool user_initiated) { | 757 bool user_initiated) { |
| 757 DCHECK(frame); | 758 DCHECK(frame); |
| 758 | 759 |
| 759 // Allow Prerendering to cancel this print request if necessary. | 760 // Allow Prerendering to cancel this print request if necessary. |
| 760 if (prerender::PrerenderHelper::IsPrerendering(render_view())) { | 761 if (prerender::PrerenderHelper::IsPrerendering( |
| 762 render_view()->GetMainRenderFrame())) { |
| 761 Send(new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id())); | 763 Send(new ChromeViewHostMsg_CancelPrerenderForPrinting(routing_id())); |
| 762 return; | 764 return; |
| 763 } | 765 } |
| 764 | 766 |
| 765 if (!IsScriptInitiatedPrintAllowed(frame, user_initiated)) | 767 if (!IsScriptInitiatedPrintAllowed(frame, user_initiated)) |
| 766 return; | 768 return; |
| 767 IncrementScriptedPrintCount(); | 769 IncrementScriptedPrintCount(); |
| 768 | 770 |
| 769 if (is_preview_enabled_) { | 771 if (is_preview_enabled_) { |
| 770 print_preview_context_.InitWithFrame(frame); | 772 print_preview_context_.InitWithFrame(frame); |
| (...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1963 } | 1965 } |
| 1964 | 1966 |
| 1965 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1967 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
| 1966 prep_frame_view_.reset(); | 1968 prep_frame_view_.reset(); |
| 1967 metafile_.reset(); | 1969 metafile_.reset(); |
| 1968 pages_to_render_.clear(); | 1970 pages_to_render_.clear(); |
| 1969 error_ = PREVIEW_ERROR_NONE; | 1971 error_ = PREVIEW_ERROR_NONE; |
| 1970 } | 1972 } |
| 1971 | 1973 |
| 1972 } // namespace printing | 1974 } // namespace printing |
| OLD | NEW |