This source file includes following definitions.
- guest_instance_id_counter_
- CreateBrowserPlugin
- AllocateInstanceID
- AllocateInstanceIDACK
- Send
- OnMessageReceived
#include "content/renderer/browser_plugin/mock_browser_plugin_manager.h"
#include "base/message_loop/message_loop.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
#include "content/renderer/browser_plugin/mock_browser_plugin.h"
#include "ipc/ipc_message.h"
namespace content {
MockBrowserPluginManager::MockBrowserPluginManager(
RenderViewImpl* render_view)
: BrowserPluginManager(render_view),
guest_instance_id_counter_(0) {
}
MockBrowserPluginManager::~MockBrowserPluginManager() {
}
BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin(
RenderViewImpl* render_view, blink::WebFrame* frame) {
return new MockBrowserPlugin(render_view, frame);
}
void MockBrowserPluginManager::AllocateInstanceID(
const base::WeakPtr<BrowserPlugin>& browser_plugin) {
int guest_instance_id = ++guest_instance_id_counter_;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&MockBrowserPluginManager::AllocateInstanceIDACK,
this,
browser_plugin.get(),
guest_instance_id));
}
void MockBrowserPluginManager::AllocateInstanceIDACK(
BrowserPlugin* browser_plugin,
int guest_instance_id) {
browser_plugin->OnInstanceIDAllocated(guest_instance_id);
scoped_ptr<base::DictionaryValue> extra_params(new base::DictionaryValue());
browser_plugin->Attach(extra_params.Pass());
}
bool MockBrowserPluginManager::Send(IPC::Message* msg) {
if (msg->is_reply()) {
if (reply_deserializer_) {
reply_deserializer_->SerializeOutputParameters(*msg);
reply_deserializer_.reset();
}
} else {
if (msg->is_sync()) {
reply_deserializer_.reset(
static_cast<IPC::SyncMessage*>(msg)->GetReplyDeserializer());
}
OnMessageReceived(*msg);
}
delete msg;
return true;
}
bool MockBrowserPluginManager::OnMessageReceived(
const IPC::Message& message) {
sink_.OnMessageReceived(message);
return false;
}
}