OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/browser/print_manager.h" | 5 #include "components/printing/browser/print_manager.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "components/printing/common/print_messages.h" | 8 #include "components/printing/common/print_messages.h" |
9 | 9 |
10 namespace printing { | 10 namespace printing { |
11 | 11 |
12 PrintManager::PrintManager(content::WebContents* contents) | 12 PrintManager::PrintManager(content::WebContents* contents) |
13 : content::WebContentsObserver(contents), | 13 : content::WebContentsObserver(contents), |
14 number_pages_(0), | 14 number_pages_(0), |
15 cookie_(0) { | 15 cookie_(0) { |
16 } | 16 } |
17 | 17 |
18 PrintManager::~PrintManager() { | 18 PrintManager::~PrintManager() { |
19 } | 19 } |
20 | 20 |
21 bool PrintManager::OnMessageReceived(const IPC::Message& message) { | 21 bool PrintManager::OnMessageReceived( |
| 22 const IPC::Message& message, |
| 23 content::RenderFrameHost* render_frame_host) { |
22 bool handled = true; | 24 bool handled = true; |
23 IPC_BEGIN_MESSAGE_MAP(PrintManager, message) | 25 IPC_BEGIN_MESSAGE_MAP(PrintManager, message) |
24 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, | 26 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, |
25 OnDidGetPrintedPagesCount) | 27 OnDidGetPrintedPagesCount) |
26 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDocumentCookie, | 28 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDocumentCookie, |
27 OnDidGetDocumentCookie) | 29 OnDidGetDocumentCookie) |
28 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintingFailed, OnPrintingFailed) | 30 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintingFailed, OnPrintingFailed) |
29 IPC_MESSAGE_UNHANDLED(handled = false) | 31 IPC_MESSAGE_UNHANDLED(handled = false) |
30 IPC_END_MESSAGE_MAP() | 32 IPC_END_MESSAGE_MAP() |
31 return handled; | 33 return handled; |
(...skipping 13 matching lines...) Expand all Loading... |
45 void PrintManager::OnPrintingFailed(int cookie) { | 47 void PrintManager::OnPrintingFailed(int cookie) { |
46 if (cookie != cookie_) { | 48 if (cookie != cookie_) { |
47 NOTREACHED(); | 49 NOTREACHED(); |
48 return; | 50 return; |
49 } | 51 } |
50 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
51 PdfWritingDone(false); | 53 PdfWritingDone(false); |
52 #endif | 54 #endif |
53 } | 55 } |
54 | 56 |
55 void PrintManager::RenderProcessGone(base::TerminationStatus status) { | 57 void PrintManager::PrintingRenderFrameDeleted() { |
56 #if defined(OS_ANDROID) | 58 #if defined(OS_ANDROID) |
57 PdfWritingDone(false); | 59 PdfWritingDone(false); |
58 #endif | 60 #endif |
59 } | 61 } |
60 | 62 |
61 #if defined(OS_ANDROID) | 63 #if defined(OS_ANDROID) |
62 void PrintManager::PdfWritingDone(bool result) { | 64 void PrintManager::PdfWritingDone(bool result) { |
63 if (!pdf_writing_done_callback_.is_null()) | 65 if (!pdf_writing_done_callback_.is_null()) |
64 pdf_writing_done_callback_.Run(file_descriptor().fd, result); | 66 pdf_writing_done_callback_.Run(file_descriptor().fd, result); |
65 // Invalidate the file descriptor so it doesn't get reused. | 67 // Invalidate the file descriptor so it doesn't get reused. |
66 file_descriptor_ = base::FileDescriptor(-1, false); | 68 file_descriptor_ = base::FileDescriptor(-1, false); |
67 } | 69 } |
68 #endif | 70 #endif |
69 | 71 |
70 } // namespace printing | 72 } // namespace printing |
OLD | NEW |