| 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 "content/renderer/browser_plugin/mock_browser_plugin_manager.h" | 5 #include "content/renderer/browser_plugin/mock_browser_plugin_manager.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "content/common/browser_plugin_messages.h" | 8 #include "content/common/browser_plugin_messages.h" |
| 9 #include "content/renderer/browser_plugin/mock_browser_plugin.h" | 9 #include "content/renderer/browser_plugin/mock_browser_plugin.h" |
| 10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 MockBrowserPluginManager::MockBrowserPluginManager( | 14 MockBrowserPluginManager::MockBrowserPluginManager( |
| 15 RenderViewImpl* render_view) | 15 RenderViewImpl* render_view) |
| 16 : BrowserPluginManager(render_view), | 16 : BrowserPluginManager(render_view), |
| 17 browser_plugin_counter_(0) { | 17 browser_plugin_counter_(0) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 MockBrowserPluginManager::~MockBrowserPluginManager() { | 20 MockBrowserPluginManager::~MockBrowserPluginManager() { |
| 21 } | 21 } |
| 22 | 22 |
| 23 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin( | 23 BrowserPluginImpl* MockBrowserPluginManager::CreateBrowserPlugin( |
| 24 RenderViewImpl* render_view, | 24 RenderViewImpl* render_view, |
| 25 WebKit::WebFrame* frame, | 25 WebKit::WebFrame* frame, |
| 26 const WebKit::WebPluginParams& params) { | 26 const WebKit::WebPluginParams& params) { |
| 27 return new MockBrowserPlugin(render_view, frame, params); | 27 return new MockBrowserPlugin(render_view, frame, params); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void MockBrowserPluginManager::AllocateInstanceID( | 30 void MockBrowserPluginManager::AllocateInstanceID( |
| 31 BrowserPlugin* browser_plugin) { | 31 BrowserPluginImpl* browser_plugin) { |
| 32 int instance_id = ++browser_plugin_counter_; | 32 int instance_id = ++browser_plugin_counter_; |
| 33 MessageLoop::current()->PostTask( | 33 MessageLoop::current()->PostTask( |
| 34 FROM_HERE, | 34 FROM_HERE, |
| 35 base::Bind(&MockBrowserPluginManager::AllocateInstanceIDACK, | 35 base::Bind(&MockBrowserPluginManager::AllocateInstanceIDACK, |
| 36 this, | 36 this, |
| 37 base::Unretained(browser_plugin), | 37 base::Unretained(browser_plugin), |
| 38 instance_id)); | 38 instance_id)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void MockBrowserPluginManager::AllocateInstanceIDACK( | 41 void MockBrowserPluginManager::AllocateInstanceIDACK( |
| 42 BrowserPlugin* browser_plugin, | 42 BrowserPluginImpl* browser_plugin, |
| 43 int instance_id) { | 43 int instance_id) { |
| 44 browser_plugin->SetInstanceID(instance_id); | 44 browser_plugin->SetInstanceID(instance_id); |
| 45 } | 45 } |
| 46 | 46 |
| 47 bool MockBrowserPluginManager::Send(IPC::Message* msg) { | 47 bool MockBrowserPluginManager::Send(IPC::Message* msg) { |
| 48 // This is a copy-and-paste from MockRenderThread::Send. | 48 // This is a copy-and-paste from MockRenderThread::Send. |
| 49 // We need to simulate a synchronous channel, thus we are going to receive | 49 // We need to simulate a synchronous channel, thus we are going to receive |
| 50 // through this function messages, messages with reply and reply messages. | 50 // through this function messages, messages with reply and reply messages. |
| 51 // We can only handle one synchronous message at a time. | 51 // We can only handle one synchronous message at a time. |
| 52 if (msg->is_reply()) { | 52 if (msg->is_reply()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool MockBrowserPluginManager::OnMessageReceived( | 70 bool MockBrowserPluginManager::OnMessageReceived( |
| 71 const IPC::Message& message) { | 71 const IPC::Message& message) { |
| 72 // Save the message in the sink. | 72 // Save the message in the sink. |
| 73 sink_.OnMessageReceived(message); | 73 sink_.OnMessageReceived(message); |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace content | 77 } // namespace content |
| OLD | NEW |