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" |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 Print(frame, blink::WebNode()); | 829 Print(frame, blink::WebNode()); |
830 } | 830 } |
831 } | 831 } |
832 | 832 |
833 bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { | 833 bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { |
834 bool handled = true; | 834 bool handled = true; |
835 IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message) | 835 IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message) |
836 IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) | 836 IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) |
837 IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog) | 837 IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog) |
838 IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) | 838 IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) |
839 IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, | |
840 OnPrintNodeUnderContextMenu) | |
841 IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) | 839 IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) |
842 IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) | 840 IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) |
843 IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) | 841 IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) |
844 IPC_MESSAGE_HANDLER(PrintMsg_ResetScriptedPrintCount, | 842 IPC_MESSAGE_HANDLER(PrintMsg_ResetScriptedPrintCount, |
845 ResetScriptedPrintCount) | 843 ResetScriptedPrintCount) |
846 IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked, | 844 IPC_MESSAGE_HANDLER(PrintMsg_SetScriptedPrintingBlocked, |
847 SetScriptedPrintBlocked) | 845 SetScriptedPrintBlocked) |
848 IPC_MESSAGE_UNHANDLED(handled = false) | 846 IPC_MESSAGE_UNHANDLED(handled = false) |
849 IPC_END_MESSAGE_MAP() | 847 IPC_END_MESSAGE_MAP() |
850 return handled; | 848 return handled; |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 notify_browser_of_print_failure_ = false; | 1152 notify_browser_of_print_failure_ = false; |
1155 if (!success) | 1153 if (!success) |
1156 LOG(ERROR) << "Failure in OnPrintingDone"; | 1154 LOG(ERROR) << "Failure in OnPrintingDone"; |
1157 DidFinishPrinting(success ? OK : FAIL_PRINT); | 1155 DidFinishPrinting(success ? OK : FAIL_PRINT); |
1158 } | 1156 } |
1159 | 1157 |
1160 void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) { | 1158 void PrintWebViewHelper::SetScriptedPrintBlocked(bool blocked) { |
1161 is_scripted_printing_blocked_ = blocked; | 1159 is_scripted_printing_blocked_ = blocked; |
1162 } | 1160 } |
1163 | 1161 |
1164 void PrintWebViewHelper::OnPrintNodeUnderContextMenu() { | |
1165 PrintNode(render_view()->GetContextMenuNode()); | |
1166 } | |
1167 | |
1168 void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { | 1162 void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) { |
1169 DCHECK(is_preview_enabled_); | 1163 DCHECK(is_preview_enabled_); |
1170 blink::WebFrame* frame = NULL; | 1164 blink::WebFrame* frame = NULL; |
1171 GetPrintFrame(&frame); | 1165 GetPrintFrame(&frame); |
1172 DCHECK(frame); | 1166 DCHECK(frame); |
1173 print_preview_context_.InitWithFrame(frame); | 1167 print_preview_context_.InitWithFrame(frame); |
1174 RequestPrintPreview(selection_only ? | 1168 RequestPrintPreview(selection_only ? |
1175 PRINT_PREVIEW_USER_INITIATED_SELECTION : | 1169 PRINT_PREVIEW_USER_INITIATED_SELECTION : |
1176 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME); | 1170 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME); |
1177 } | 1171 } |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 } | 1991 } |
1998 | 1992 |
1999 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { | 1993 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { |
2000 prep_frame_view_.reset(); | 1994 prep_frame_view_.reset(); |
2001 metafile_.reset(); | 1995 metafile_.reset(); |
2002 pages_to_render_.clear(); | 1996 pages_to_render_.clear(); |
2003 error_ = PREVIEW_ERROR_NONE; | 1997 error_ = PREVIEW_ERROR_NONE; |
2004 } | 1998 } |
2005 | 1999 |
2006 } // namespace printing | 2000 } // namespace printing |
OLD | NEW |