blob: 1d4ff7cee1098bb523bd15b641cd888beb9f692b [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/id_map.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "content/public/renderer/render_thread_observer.h"
#include "ipc/ipc_sender.h"
namespace blink {
class WebFrame;
namespace content {
class BrowserPlugin;
class BrowserPluginDelegate;
class RenderFrame;
// BrowserPluginManager manages the routing of messages to the appropriate
// BrowserPlugin object based on its instance ID. There is one BrowserPlugin
// for the RenderThread.
class CONTENT_EXPORT BrowserPluginManager : public RenderThreadObserver {
static BrowserPluginManager* Get();
~BrowserPluginManager() override;
// Creates a new BrowserPlugin object.
// BrowserPlugin is responsible for associating itself with the
// BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is
// responsible for removing its association via RemoveBrowserPlugin.
// The |delegate| is expected to manage its own lifetime.
// Generally BrowserPlugin calls DidDestroyElement() on the delegate and
// right now the delegate destroys itself once it hears that callback.
BrowserPlugin* CreateBrowserPlugin(
RenderFrame* render_frame,
const base::WeakPtr<BrowserPluginDelegate>& delegate);
void Attach(int browser_plugin_instance_id);
void Detach(int browser_plugin_instance_id);
void AddBrowserPlugin(int browser_plugin_instance_id,
BrowserPlugin* browser_plugin);
void RemoveBrowserPlugin(int browser_plugin_instance_id);
BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const;
void UpdateFocusState();
// Returns a new instance ID to be used by BrowserPlugin. Instance IDs are
// unique per process.
int GetNextInstanceID();
void DidCommitCompositorFrame(int render_frame_routing_id);
bool Send(IPC::Message* msg);
// RenderThreadObserver override.
bool OnControlMessageReceived(const IPC::Message& message) override;
// This map is keyed by guest instance IDs.
IDMap<BrowserPlugin> instances_;
} // namespace content