• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_MOCK_BROWSER_PLUGIN_MANAGER_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_MOCK_BROWSER_PLUGIN_MANAGER_H_
7 
8 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
9 
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/renderer/browser_plugin_delegate.h"
12 #include "ipc/ipc_message_utils.h"
13 #include "ipc/ipc_test_sink.h"
14 
15 namespace content {
16 
17 class MockBrowserPlugin;
18 
19 class MockBrowserPluginManager : public BrowserPluginManager {
20  public:
21   MockBrowserPluginManager(RenderViewImpl* render_view);
22 
23   // BrowserPluginManager implementation.
24   virtual BrowserPlugin* CreateBrowserPlugin(
25       RenderViewImpl* render_view,
26       blink::WebFrame* frame,
27       scoped_ptr<BrowserPluginDelegate> delegate) OVERRIDE;
28 
29   // Provides access to the messages that have been received by this thread.
sink()30   IPC::TestSink& sink() { return sink_; }
31 
32   // RenderViewObserver override.
33   virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
34   virtual bool Send(IPC::Message* msg) OVERRIDE;
35 
36   // Returns the latest browser plugin that was created by this manager.
last_plugin()37   MockBrowserPlugin* last_plugin() { return last_plugin_; }
38 
39  protected:
40   virtual ~MockBrowserPluginManager();
41 
42   IPC::TestSink sink_;
43 
44   // The last known good deserializer for sync messages.
45   scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_;
46 
47   MockBrowserPlugin* last_plugin_;
48 
49   DISALLOW_COPY_AND_ASSIGN(MockBrowserPluginManager);
50 };
51 
52 }  // namespace content
53 
54 #endif  // CONTENT_RENDERER_BROWSER_PLUGIN_MOCK_BROWSER_PLUGIN_MANAGER_H_
55