OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/mock_render_thread.h" | 5 #include "chrome/renderer/mock_render_thread.h" |
6 | 6 |
7 #include "base/process_util.h" | 7 #include "base/process_util.h" |
8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 #include "ipc/ipc_message_utils.h" | 9 #include "ipc/ipc_message_utils.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // Save the message in the sink. | 78 // Save the message in the sink. |
79 sink_.OnMessageReceived(msg); | 79 sink_.OnMessageReceived(msg); |
80 | 80 |
81 // Some messages we do special handling. | 81 // Some messages we do special handling. |
82 bool handled = true; | 82 bool handled = true; |
83 bool msg_is_ok = true; | 83 bool msg_is_ok = true; |
84 IPC_BEGIN_MESSAGE_MAP_EX(MockRenderThread, msg, msg_is_ok) | 84 IPC_BEGIN_MESSAGE_MAP_EX(MockRenderThread, msg, msg_is_ok) |
85 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget); | 85 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWidget, OnMsgCreateWidget); |
86 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, | 86 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenChannelToExtension, |
87 OnMsgOpenChannelToExtension); | 87 OnMsgOpenChannelToExtension); |
| 88 IPC_MESSAGE_HANDLER(ViewHostMsg_GetExtensionMessageBundle, |
| 89 OnMsgGetExtensionMessageBundle); |
88 #if defined(OS_WIN) || defined(OS_MACOSX) | 90 #if defined(OS_WIN) || defined(OS_MACOSX) |
89 IPC_MESSAGE_HANDLER(ViewHostMsg_GetDefaultPrintSettings, | 91 IPC_MESSAGE_HANDLER(ViewHostMsg_GetDefaultPrintSettings, |
90 OnGetDefaultPrintSettings); | 92 OnGetDefaultPrintSettings); |
91 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptedPrint, | 93 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptedPrint, |
92 OnScriptedPrint); | 94 OnScriptedPrint); |
93 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, | 95 IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetPrintedPagesCount, |
94 OnDidGetPrintedPagesCount) | 96 OnDidGetPrintedPagesCount) |
95 IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) | 97 IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, OnDidPrintPage) |
96 #endif | 98 #endif |
97 #if defined(OS_WIN) | 99 #if defined(OS_WIN) |
(...skipping 15 matching lines...) Expand all Loading... |
113 *route_id = routing_id_; | 115 *route_id = routing_id_; |
114 } | 116 } |
115 | 117 |
116 void MockRenderThread::OnMsgOpenChannelToExtension( | 118 void MockRenderThread::OnMsgOpenChannelToExtension( |
117 int routing_id, const std::string& source_extension_id, | 119 int routing_id, const std::string& source_extension_id, |
118 const std::string& target_extension_id, | 120 const std::string& target_extension_id, |
119 const std::string& channel_name, int* port_id) { | 121 const std::string& channel_name, int* port_id) { |
120 *port_id = 0; | 122 *port_id = 0; |
121 } | 123 } |
122 | 124 |
| 125 void MockRenderThread::OnMsgGetExtensionMessageBundle( |
| 126 const std::string extension_id, |
| 127 std::map<std::string, std::string>* messages) { |
| 128 DCHECK(messages); |
| 129 messages->insert(std::make_pair("@@extension_id", extension_id)); |
| 130 } |
| 131 |
123 #if defined(OS_WIN) | 132 #if defined(OS_WIN) |
124 void MockRenderThread::OnDuplicateSection( | 133 void MockRenderThread::OnDuplicateSection( |
125 base::SharedMemoryHandle renderer_handle, | 134 base::SharedMemoryHandle renderer_handle, |
126 base::SharedMemoryHandle* browser_handle) { | 135 base::SharedMemoryHandle* browser_handle) { |
127 // We don't have to duplicate the input handles since RenderViewTest does not | 136 // We don't have to duplicate the input handles since RenderViewTest does not |
128 // separate a browser process from a renderer process. | 137 // separate a browser process from a renderer process. |
129 *browser_handle = renderer_handle; | 138 *browser_handle = renderer_handle; |
130 } | 139 } |
131 #endif | 140 #endif |
132 | 141 |
(...skipping 30 matching lines...) Expand all Loading... |
163 void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) { | 172 void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) { |
164 if (printer_.get()) | 173 if (printer_.get()) |
165 printer_->SetPrintedPagesCount(cookie, number_pages); | 174 printer_->SetPrintedPagesCount(cookie, number_pages); |
166 } | 175 } |
167 | 176 |
168 void MockRenderThread::OnDidPrintPage( | 177 void MockRenderThread::OnDidPrintPage( |
169 const ViewHostMsg_DidPrintPage_Params& params) { | 178 const ViewHostMsg_DidPrintPage_Params& params) { |
170 if (printer_.get()) | 179 if (printer_.get()) |
171 printer_->PrintPage(params); | 180 printer_->PrintPage(params); |
172 } | 181 } |
OLD | NEW |