| 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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "content/common/browser_plugin/browser_plugin_messages.h" | 8 #include "content/common/browser_plugin/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 guest_instance_id_counter_(0) { | 17 guest_instance_id_counter_(0), |
| 18 last_plugin_(NULL) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 MockBrowserPluginManager::~MockBrowserPluginManager() { | 21 MockBrowserPluginManager::~MockBrowserPluginManager() { |
| 21 } | 22 } |
| 22 | 23 |
| 23 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin( | 24 BrowserPlugin* MockBrowserPluginManager::CreateBrowserPlugin( |
| 24 RenderViewImpl* render_view, | 25 RenderViewImpl* render_view, |
| 25 blink::WebFrame* frame, | 26 blink::WebFrame* frame, |
| 26 bool auto_navigate) { | 27 bool auto_navigate) { |
| 27 return new MockBrowserPlugin(render_view, frame, auto_navigate); | 28 last_plugin_ = new MockBrowserPlugin(render_view, frame, auto_navigate); |
| 29 return last_plugin_; |
| 28 } | 30 } |
| 29 | 31 |
| 30 void MockBrowserPluginManager::AllocateInstanceID( | 32 void MockBrowserPluginManager::AllocateInstanceID( |
| 31 const base::WeakPtr<BrowserPlugin>& browser_plugin) { | 33 BrowserPlugin* browser_plugin) { |
| 32 int guest_instance_id = ++guest_instance_id_counter_; | 34 AllocateInstanceIDACK(browser_plugin, ++guest_instance_id_counter_); |
| 33 base::MessageLoop::current()->PostTask( | |
| 34 FROM_HERE, | |
| 35 base::Bind(&MockBrowserPluginManager::AllocateInstanceIDACK, | |
| 36 this, | |
| 37 browser_plugin.get(), | |
| 38 guest_instance_id)); | |
| 39 } | 35 } |
| 40 | 36 |
| 41 void MockBrowserPluginManager::AllocateInstanceIDACK( | 37 void MockBrowserPluginManager::AllocateInstanceIDACK( |
| 42 BrowserPlugin* browser_plugin, | 38 BrowserPlugin* browser_plugin, |
| 43 int guest_instance_id) { | 39 int guest_instance_id) { |
| 44 scoped_ptr<base::DictionaryValue> extra_params(new base::DictionaryValue()); | 40 scoped_ptr<base::DictionaryValue> extra_params(new base::DictionaryValue()); |
| 45 browser_plugin->Attach(guest_instance_id, extra_params.Pass()); | 41 browser_plugin->Attach(guest_instance_id, extra_params.Pass()); |
| 46 } | 42 } |
| 47 | 43 |
| 48 bool MockBrowserPluginManager::Send(IPC::Message* msg) { | 44 bool MockBrowserPluginManager::Send(IPC::Message* msg) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 69 } | 65 } |
| 70 | 66 |
| 71 bool MockBrowserPluginManager::OnMessageReceived( | 67 bool MockBrowserPluginManager::OnMessageReceived( |
| 72 const IPC::Message& message) { | 68 const IPC::Message& message) { |
| 73 // Save the message in the sink. | 69 // Save the message in the sink. |
| 74 sink_.OnMessageReceived(message); | 70 sink_.OnMessageReceived(message); |
| 75 return false; | 71 return false; |
| 76 } | 72 } |
| 77 | 73 |
| 78 } // namespace content | 74 } // namespace content |
| OLD | NEW |