| 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/chrome_mock_render_thread.h" | 5 #include "chrome/renderer/chrome_mock_render_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/renderer/printing/mock_printer.h" | 10 #include "chrome/renderer/printing/mock_printer.h" |
| 11 #include "extensions/common/extension_messages.h" | |
| 12 #include "ipc/ipc_sync_message.h" | 11 #include "ipc/ipc_sync_message.h" |
| 13 #include "printing/page_range.h" | 12 #include "printing/page_range.h" |
| 14 #include "printing/print_job_constants.h" | 13 #include "printing/print_job_constants.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
| 18 #include <fcntl.h> | 17 #include <fcntl.h> |
| 19 | 18 |
| 20 #include "base/files/file_util.h" | 19 #include "base/files/file_util.h" |
| 21 #endif | 20 #endif |
| 22 | 21 |
| 22 #if defined(ENABLE_EXTENSIONS) |
| 23 #include "extensions/common/extension_messages.h" |
| 24 #endif |
| 25 |
| 23 #if defined(ENABLE_PRINTING) | 26 #if defined(ENABLE_PRINTING) |
| 24 #include "chrome/common/print_messages.h" | 27 #include "chrome/common/print_messages.h" |
| 25 #endif | 28 #endif |
| 26 | 29 |
| 27 ChromeMockRenderThread::ChromeMockRenderThread() | 30 ChromeMockRenderThread::ChromeMockRenderThread() |
| 28 #if defined(ENABLE_PRINTING) | 31 #if defined(ENABLE_PRINTING) |
| 29 : printer_(new MockPrinter), | 32 : printer_(new MockPrinter), |
| 30 print_dialog_user_response_(true), | 33 print_dialog_user_response_(true), |
| 31 print_preview_cancel_page_number_(-1), | 34 print_preview_cancel_page_number_(-1), |
| 32 print_preview_pages_remaining_(0) | 35 print_preview_pages_remaining_(0) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 47 io_message_loop_proxy_ = proxy; | 50 io_message_loop_proxy_ = proxy; |
| 48 } | 51 } |
| 49 | 52 |
| 50 bool ChromeMockRenderThread::OnMessageReceived(const IPC::Message& msg) { | 53 bool ChromeMockRenderThread::OnMessageReceived(const IPC::Message& msg) { |
| 51 if (content::MockRenderThread::OnMessageReceived(msg)) | 54 if (content::MockRenderThread::OnMessageReceived(msg)) |
| 52 return true; | 55 return true; |
| 53 | 56 |
| 54 // Some messages we do special handling. | 57 // Some messages we do special handling. |
| 55 bool handled = true; | 58 bool handled = true; |
| 56 IPC_BEGIN_MESSAGE_MAP(ChromeMockRenderThread, msg) | 59 IPC_BEGIN_MESSAGE_MAP(ChromeMockRenderThread, msg) |
| 60 #if defined(ENABLE_EXTENSIONS) |
| 57 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, | 61 IPC_MESSAGE_HANDLER(ExtensionHostMsg_OpenChannelToExtension, |
| 58 OnOpenChannelToExtension) | 62 OnOpenChannelToExtension) |
| 63 #endif |
| 59 #if defined(ENABLE_PRINTING) | 64 #if defined(ENABLE_PRINTING) |
| 60 IPC_MESSAGE_HANDLER(PrintHostMsg_GetDefaultPrintSettings, | 65 IPC_MESSAGE_HANDLER(PrintHostMsg_GetDefaultPrintSettings, |
| 61 OnGetDefaultPrintSettings) | 66 OnGetDefaultPrintSettings) |
| 62 IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptedPrint, OnScriptedPrint) | 67 IPC_MESSAGE_HANDLER(PrintHostMsg_ScriptedPrint, OnScriptedPrint) |
| 63 IPC_MESSAGE_HANDLER(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings) | 68 IPC_MESSAGE_HANDLER(PrintHostMsg_UpdatePrintSettings, OnUpdatePrintSettings) |
| 64 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, | 69 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount, |
| 65 OnDidGetPrintedPagesCount) | 70 OnDidGetPrintedPagesCount) |
| 66 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) | 71 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage) |
| 67 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, | 72 IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPreviewPageCount, |
| 68 OnDidGetPreviewPageCount) | 73 OnDidGetPreviewPageCount) |
| 69 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage) | 74 IPC_MESSAGE_HANDLER(PrintHostMsg_DidPreviewPage, OnDidPreviewPage) |
| 70 IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel) | 75 IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel) |
| 71 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 72 IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection) | 77 IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection) |
| 73 #endif | 78 #endif |
| 74 #if defined(OS_CHROMEOS) | 79 #if defined(OS_CHROMEOS) |
| 75 IPC_MESSAGE_HANDLER(PrintHostMsg_AllocateTempFileForPrinting, | 80 IPC_MESSAGE_HANDLER(PrintHostMsg_AllocateTempFileForPrinting, |
| 76 OnAllocateTempFileForPrinting) | 81 OnAllocateTempFileForPrinting) |
| 77 IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, | 82 IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten, |
| 78 OnTempFileForPrintingWritten) | 83 OnTempFileForPrintingWritten) |
| 79 #endif // defined(OS_CHROMEOS) | 84 #endif // defined(OS_CHROMEOS) |
| 80 #endif // defined(ENABLE_PRINTING) | 85 #endif // defined(ENABLE_PRINTING) |
| 81 IPC_MESSAGE_UNHANDLED(handled = false) | 86 IPC_MESSAGE_UNHANDLED(handled = false) |
| 82 IPC_END_MESSAGE_MAP() | 87 IPC_END_MESSAGE_MAP() |
| 83 return handled; | 88 return handled; |
| 84 } | 89 } |
| 85 | 90 |
| 91 #if defined(ENABLE_EXTENSIONS) |
| 86 void ChromeMockRenderThread::OnOpenChannelToExtension( | 92 void ChromeMockRenderThread::OnOpenChannelToExtension( |
| 87 int routing_id, | 93 int routing_id, |
| 88 const ExtensionMsg_ExternalConnectionInfo& info, | 94 const ExtensionMsg_ExternalConnectionInfo& info, |
| 89 const std::string& channel_name, | 95 const std::string& channel_name, |
| 90 bool include_tls_channel_id, | 96 bool include_tls_channel_id, |
| 91 int* port_id) { | 97 int* port_id) { |
| 92 *port_id = 0; | 98 *port_id = 0; |
| 93 } | 99 } |
| 100 #endif |
| 94 | 101 |
| 95 #if defined(ENABLE_PRINTING) | 102 #if defined(ENABLE_PRINTING) |
| 96 #if defined(OS_CHROMEOS) | 103 #if defined(OS_CHROMEOS) |
| 97 void ChromeMockRenderThread::OnAllocateTempFileForPrinting( | 104 void ChromeMockRenderThread::OnAllocateTempFileForPrinting( |
| 98 int render_view_id, | 105 int render_view_id, |
| 99 base::FileDescriptor* renderer_fd, | 106 base::FileDescriptor* renderer_fd, |
| 100 int* browser_fd) { | 107 int* browser_fd) { |
| 101 renderer_fd->fd = *browser_fd = -1; | 108 renderer_fd->fd = *browser_fd = -1; |
| 102 renderer_fd->auto_close = false; | 109 renderer_fd->auto_close = false; |
| 103 | 110 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 229 } |
| 223 | 230 |
| 224 void ChromeMockRenderThread::set_print_preview_cancel_page_number(int page) { | 231 void ChromeMockRenderThread::set_print_preview_cancel_page_number(int page) { |
| 225 print_preview_cancel_page_number_ = page; | 232 print_preview_cancel_page_number_ = page; |
| 226 } | 233 } |
| 227 | 234 |
| 228 int ChromeMockRenderThread::print_preview_pages_remaining() const { | 235 int ChromeMockRenderThread::print_preview_pages_remaining() const { |
| 229 return print_preview_pages_remaining_; | 236 return print_preview_pages_remaining_; |
| 230 } | 237 } |
| 231 #endif // defined(ENABLE_PRINTING) | 238 #endif // defined(ENABLE_PRINTING) |
| OLD | NEW |