OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(OS_MACOSX) && !defined(USE_SKIA) | |
8 #include <CoreGraphics/CGContext.h> | |
9 #endif | |
10 | |
11 #include <string> | 7 #include <string> |
12 | 8 |
13 #include "base/command_line.h" | 9 #include "base/command_line.h" |
14 #include "base/logging.h" | 10 #include "base/logging.h" |
15 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
16 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
17 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
18 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/print_messages.h" | 15 #include "chrome/common/print_messages.h" |
20 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
(...skipping 21 matching lines...) Expand all Loading... |
42 #if defined(OS_POSIX) | 38 #if defined(OS_POSIX) |
43 #include "base/process_util.h" | 39 #include "base/process_util.h" |
44 #include "content/common/view_messages.h" | 40 #include "content/common/view_messages.h" |
45 #endif | 41 #endif |
46 | 42 |
47 #if defined(USE_SKIA) | 43 #if defined(USE_SKIA) |
48 #include "skia/ext/vector_canvas.h" | 44 #include "skia/ext/vector_canvas.h" |
49 #include "skia/ext/vector_platform_device_skia.h" | 45 #include "skia/ext/vector_platform_device_skia.h" |
50 #include "third_party/skia/include/core/SkTypeface.h" | 46 #include "third_party/skia/include/core/SkTypeface.h" |
51 #elif defined(OS_MACOSX) | 47 #elif defined(OS_MACOSX) |
| 48 #include <CoreGraphics/CGContext.h> |
| 49 |
52 #include "base/mac/scoped_cftyperef.h" | 50 #include "base/mac/scoped_cftyperef.h" |
53 #include "base/sys_string_conversions.h" | 51 #include "base/sys_string_conversions.h" |
54 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" | 52 #include "ui/gfx/scoped_cg_context_save_gstate_mac.h" |
55 #endif | 53 #endif |
56 | 54 |
57 #if defined(OS_MACOSX) | 55 #if defined(OS_MACOSX) |
58 using base::mac::ScopedCFTypeRef; | 56 using base::mac::ScopedCFTypeRef; |
59 #endif | 57 #endif |
60 using printing::ConvertPixelsToPoint; | 58 using printing::ConvertPixelsToPoint; |
61 using printing::ConvertPixelsToPointDouble; | 59 using printing::ConvertPixelsToPointDouble; |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 &(preview_params.metafile_data_handle))) { | 725 &(preview_params.metafile_data_handle))) { |
728 LOG(ERROR) << "CopyMetafileDataToSharedMem failed"; | 726 LOG(ERROR) << "CopyMetafileDataToSharedMem failed"; |
729 return false; | 727 return false; |
730 } | 728 } |
731 Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); | 729 Send(new PrintHostMsg_PagesReadyForPreview(routing_id(), preview_params)); |
732 return true; | 730 return true; |
733 } | 731 } |
734 | 732 |
735 void PrintWebViewHelper::OnPrintingDone(bool success) { | 733 void PrintWebViewHelper::OnPrintingDone(bool success) { |
736 notify_browser_of_print_failure_ = false; | 734 notify_browser_of_print_failure_ = false; |
737 if (success == FAIL_PRINT) | 735 if (!success) |
738 LOG(ERROR) << "Failure in OnPrintingDone"; | 736 LOG(ERROR) << "Failure in OnPrintingDone"; |
739 DidFinishPrinting(success ? OK : FAIL_PRINT); | 737 DidFinishPrinting(success ? OK : FAIL_PRINT); |
740 } | 738 } |
741 | 739 |
742 void PrintWebViewHelper::OnPrintNodeUnderContextMenu() { | 740 void PrintWebViewHelper::OnPrintNodeUnderContextMenu() { |
743 const WebNode& context_menu_node = render_view()->context_menu_node(); | 741 const WebNode& context_menu_node = render_view()->context_menu_node(); |
744 if (context_menu_node.isNull()) { | 742 if (context_menu_node.isNull()) { |
745 NOTREACHED(); | 743 NOTREACHED(); |
746 return; | 744 return; |
747 } | 745 } |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 const gfx::Size& | 1454 const gfx::Size& |
1457 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { | 1455 PrintWebViewHelper::PrintPreviewContext::GetPrintCanvasSize() const { |
1458 return prep_frame_view_->GetPrintCanvasSize(); | 1456 return prep_frame_view_->GetPrintCanvasSize(); |
1459 } | 1457 } |
1460 | 1458 |
1461 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1459 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
1462 prep_frame_view_.reset(); | 1460 prep_frame_view_.reset(); |
1463 metafile_.reset(); | 1461 metafile_.reset(); |
1464 pages_to_render_.clear(); | 1462 pages_to_render_.clear(); |
1465 } | 1463 } |
OLD | NEW |