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 "ipc/ipc_message_utils.h"
12#include "ipc/ipc_test_sink.h"
13
14namespace content {
15
16class MockBrowserPluginManager : public BrowserPluginManager {
17 public:
18  MockBrowserPluginManager(RenderViewImpl* render_view);
19
20  // BrowserPluginManager implementation.
21  virtual BrowserPlugin* CreateBrowserPlugin(
22      RenderViewImpl* render_view, blink::WebFrame* frame) OVERRIDE;
23  virtual void AllocateInstanceID(
24      const base::WeakPtr<BrowserPlugin>& browser_plugin) OVERRIDE;
25
26  // Provides access to the messages that have been received by this thread.
27  IPC::TestSink& sink() { return sink_; }
28
29  // RenderViewObserver override.
30  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
31  virtual bool Send(IPC::Message* msg) OVERRIDE;
32 protected:
33  virtual ~MockBrowserPluginManager();
34  void AllocateInstanceIDACK(BrowserPlugin* browser_plugin,
35                             int guest_instance_id);
36
37  IPC::TestSink sink_;
38
39  // The last known good deserializer for sync messages.
40  scoped_ptr<IPC::MessageReplyDeserializer> reply_deserializer_;
41
42  int guest_instance_id_counter_;
43
44  DISALLOW_COPY_AND_ASSIGN(MockBrowserPluginManager);
45};
46
47}  // namespace content
48
49#endif  // CONTENT_RENDERER_BROWSER_PLUGIN_MOCK_BROWSER_PLUGIN_MANAGER_H_
50