| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "android_webview/browser/renderer_host/print_manager.h" | 5 #include "android_webview/browser/renderer_host/print_manager.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_browser_context.h" | 7 #include "android_webview/browser/aw_browser_context.h" |
| 8 #include "android_webview/common/print_messages.h" | |
| 9 #include "android_webview/common/render_view_messages.h" | 8 #include "android_webview/common/render_view_messages.h" |
| 10 #include "base/android/scoped_java_ref.h" | 9 #include "base/android/scoped_java_ref.h" |
| 11 #include "base/callback.h" | 10 #include "base/callback.h" |
| 12 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "components/printing/common/print_messages.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "printing/print_settings.h" | 15 #include "printing/print_settings.h" |
| 16 | 16 |
| 17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 using printing::PrintSettings; | 18 using printing::PrintSettings; |
| 19 | 19 |
| 20 namespace android_webview { | 20 namespace android_webview { |
| 21 | 21 |
| 22 PrintManager::PrintManager(content::WebContents* contents, | 22 PrintManager::PrintManager(content::WebContents* contents, |
| 23 PrintSettings* settings, | 23 PrintSettings* settings, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 49 OnAllocateTempFileForPrinting) | 49 OnAllocateTempFileForPrinting) |
| 50 IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, | 50 IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, |
| 51 OnTempFileForPrintingWritten) | 51 OnTempFileForPrintingWritten) |
| 52 IPC_MESSAGE_UNHANDLED(handled = false) | 52 IPC_MESSAGE_UNHANDLED(handled = false) |
| 53 IPC_END_MESSAGE_MAP() | 53 IPC_END_MESSAGE_MAP() |
| 54 | 54 |
| 55 return handled ? true : WebContentsObserver::OnMessageReceived(message); | 55 return handled ? true : WebContentsObserver::OnMessageReceived(message); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void PrintManager::OnAllocateTempFileForPrinting( | 58 void PrintManager::OnAllocateTempFileForPrinting( |
| 59 int render_view_id, |
| 59 base::FileDescriptor* temp_file_fd, | 60 base::FileDescriptor* temp_file_fd, |
| 60 int* sequence_number) { | 61 int* sequence_number) { |
| 61 // we don't really use the sequence number. | 62 // we don't really use the sequence number. |
| 62 *sequence_number = 0; | 63 *sequence_number = 0; |
| 63 temp_file_fd->fd = fd_; | 64 temp_file_fd->fd = fd_; |
| 64 temp_file_fd->auto_close = false; | 65 temp_file_fd->auto_close = false; |
| 65 } | 66 } |
| 66 | 67 |
| 67 void PrintManager::OnTempFileForPrintingWritten(int sequence_number) { | 68 void PrintManager::OnTempFileForPrintingWritten(int render_view_id, |
| 69 int sequence_number) { |
| 68 delegate_->DidExportPdf(true); | 70 delegate_->DidExportPdf(true); |
| 69 } | 71 } |
| 70 | 72 |
| 71 void PrintManager::OnDidGetPrintedPagesCount(int cookie, | 73 void PrintManager::OnDidGetPrintedPagesCount(int cookie, |
| 72 int number_pages) { | 74 int number_pages) { |
| 73 DCHECK_GT(cookie, 0); | 75 DCHECK_GT(cookie, 0); |
| 74 DCHECK_GT(number_pages, 0); | 76 DCHECK_GT(number_pages, 0); |
| 75 number_pages_ = number_pages; | 77 number_pages_ = number_pages; |
| 76 } | 78 } |
| 77 | 79 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 bool PrintManager::PrintNow() { | 136 bool PrintManager::PrintNow() { |
| 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 136 if (printing_) | 138 if (printing_) |
| 137 return false; | 139 return false; |
| 138 | 140 |
| 139 printing_ = true; | 141 printing_ = true; |
| 140 return Send(new PrintMsg_PrintPages(routing_id())); | 142 return Send(new PrintMsg_PrintPages(routing_id())); |
| 141 } | 143 } |
| 142 | 144 |
| 143 } // namespace android_webview | 145 } // namespace android_webview |
| OLD | NEW |