OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h" |
| 6 |
| 7 #include "ipc/ipc_message.h" |
| 8 #include "content/renderer/browser_plugin/mock_browser_plugin.h" |
| 9 |
| 10 namespace content { |
| 11 namespace browser_plugin { |
| 12 |
| 13 MockBrowserPluginManager::MockBrowserPluginManager() { |
| 14 } |
| 15 |
| 16 MockBrowserPluginManager::~MockBrowserPluginManager() { |
| 17 } |
| 18 |
| 19 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin( |
| 20 RenderViewImpl* render_view, |
| 21 WebKit::WebFrame* frame, |
| 22 const WebKit::WebPluginParams& params) { |
| 23 return new MockBrowserPlugin(browser_plugin_counter_++, |
| 24 render_view, |
| 25 render_view->GetRoutingID(), |
| 26 frame, |
| 27 params); |
| 28 } |
| 29 |
| 30 void MockBrowserPluginManager::Cleanup() { |
| 31 IDMap<BrowserPlugin>::iterator iter(&instances_); |
| 32 while (!iter.IsAtEnd()) { |
| 33 iter.GetCurrentValue()->Cleanup(); |
| 34 iter.Advance(); |
| 35 } |
| 36 } |
| 37 |
| 38 bool MockBrowserPluginManager::Send(IPC::Message* msg) { |
| 39 // This is a copy-and-paste from MockRenderThread::Send. |
| 40 // We need to simulate a synchronous channel, thus we are going to receive |
| 41 // through this function messages, messages with reply and reply messages. |
| 42 // We can only handle one synchronous message at a time. |
| 43 if (msg->is_reply()) { |
| 44 if (reply_deserializer_.get()) { |
| 45 reply_deserializer_->SerializeOutputParameters(*msg); |
| 46 reply_deserializer_.reset(); |
| 47 } |
| 48 } else { |
| 49 if (msg->is_sync()) { |
| 50 // We actually need to handle deleting the reply deserializer for sync |
| 51 // messages. |
| 52 reply_deserializer_.reset( |
| 53 static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer()); |
| 54 } |
| 55 OnControlMessageReceived(*msg); |
| 56 } |
| 57 delete msg; |
| 58 return true; |
| 59 } |
| 60 |
| 61 bool MockBrowserPluginManager::OnControlMessageReceived( |
| 62 const IPC::Message& message) { |
| 63 // Save the message in the sink. |
| 64 sink_.OnMessageReceived(message); |
| 65 return false; |
| 66 } |
| 67 |
| 68 } // namespace browser_plugin |
| 69 } // namespace content |
OLD | NEW |