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