Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / browser_plugin / browser_plugin_manager.h
bloba762b889f035f010b3ebbba6f94d366d4a56ad87
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.
5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_
8 #include "base/id_map.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/public/renderer/render_process_observer.h"
11 #include "ipc/ipc_sender.h"
13 namespace blink {
14 class WebFrame;
17 namespace content {
19 class BrowserPlugin;
20 class BrowserPluginDelegate;
21 class RenderFrame;
23 // BrowserPluginManager manages the routing of messages to the appropriate
24 // BrowserPlugin object based on its instance ID. There is one BrowserPlugin
25 // for the RenderThread.
26 class CONTENT_EXPORT BrowserPluginManager : public RenderProcessObserver {
27 public:
28 static BrowserPluginManager* Get();
30 BrowserPluginManager();
31 ~BrowserPluginManager() override;
33 // Creates a new BrowserPlugin object.
34 // BrowserPlugin is responsible for associating itself with the
35 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is
36 // responsible for removing its association via RemoveBrowserPlugin.
37 // The |delegate| is expected to manage its own lifetime.
38 // Generally BrowserPlugin calls DidDestroyElement() on the delegate and
39 // right now the delegate destroys itself once it hears that callback.
40 BrowserPlugin* CreateBrowserPlugin(
41 RenderFrame* render_frame,
42 const base::WeakPtr<BrowserPluginDelegate>& delegate);
44 void Attach(int browser_plugin_instance_id);
46 void Detach(int browser_plugin_instance_id);
48 void AddBrowserPlugin(int browser_plugin_instance_id,
49 BrowserPlugin* browser_plugin);
50 void RemoveBrowserPlugin(int browser_plugin_instance_id);
51 BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const;
53 void UpdateFocusState();
55 // Returns a new instance ID to be used by BrowserPlugin. Instance IDs are
56 // unique per process.
57 int GetNextInstanceID();
59 void DidCommitCompositorFrame(int render_frame_routing_id);
60 bool Send(IPC::Message* msg);
62 // RenderProcessObserver override.
63 bool OnControlMessageReceived(const IPC::Message& message) override;
65 private:
66 // IPC message handlers.
67 void OnCompositorFrameSwappedPluginUnavailable(const IPC::Message& message);
69 // This map is keyed by guest instance IDs.
70 IDMap<BrowserPlugin> instances_;
72 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager);
75 } // namespace content
77 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_