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 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ |
7 | 7 |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 BrowserPluginManager(RenderViewImpl* render_view); | 41 BrowserPluginManager(RenderViewImpl* render_view); |
42 | 42 |
43 // Creates a new BrowserPlugin object with a unique identifier. | 43 // Creates a new BrowserPlugin object with a unique identifier. |
44 // BrowserPlugin is responsible for associating itself with the | 44 // BrowserPlugin is responsible for associating itself with the |
45 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is | 45 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is |
46 // responsible for removing its association via RemoveBrowserPlugin. | 46 // responsible for removing its association via RemoveBrowserPlugin. |
47 virtual BrowserPlugin* CreateBrowserPlugin( | 47 virtual BrowserPlugin* CreateBrowserPlugin( |
48 RenderViewImpl* render_view, | 48 RenderViewImpl* render_view, |
49 WebKit::WebFrame* frame, | 49 WebKit::WebFrame* frame, |
50 const WebKit::WebPluginParams& params) = 0; | 50 const WebKit::WebPluginParams& params) = 0; |
| 51 virtual void AllocateInstanceID(BrowserPlugin* browser_plugin) = 0; |
51 | 52 |
52 void AddBrowserPlugin(int instance_id, BrowserPlugin* browser_plugin); | 53 void AddBrowserPlugin(int instance_id, BrowserPlugin* browser_plugin); |
53 void RemoveBrowserPlugin(int instance_id); | 54 void RemoveBrowserPlugin(int instance_id); |
54 BrowserPlugin* GetBrowserPlugin(int instance_id) const; | 55 BrowserPlugin* GetBrowserPlugin(int instance_id) const; |
55 void UpdateFocusState(); | 56 void UpdateFocusState(); |
56 RenderViewImpl* render_view() const { return render_view_; } | 57 RenderViewImpl* render_view() const { return render_view_; } |
57 | 58 |
58 // RenderViewObserver implementation. | 59 // RenderViewObserver implementation. |
59 | 60 |
60 // BrowserPluginManager must override the default Send behavior. | 61 // BrowserPluginManager must override the default Send behavior. |
61 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; | 62 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; |
62 | 63 |
63 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. | 64 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. |
64 // BrowserPluginManager's lifetime is managed by a reference count. Once | 65 // BrowserPluginManager's lifetime is managed by a reference count. Once |
65 // the host RenderViewImpl and all BrowserPlugins release their references, | 66 // the host RenderViewImpl and all BrowserPlugins release their references, |
66 // then the BrowserPluginManager will be destroyed. | 67 // then the BrowserPluginManager will be destroyed. |
67 virtual void OnDestruct() OVERRIDE {} | 68 virtual void OnDestruct() OVERRIDE {} |
68 | 69 |
69 protected: | 70 protected: |
70 // Friend RefCounted so that the dtor can be non-public. | 71 // Friend RefCounted so that the dtor can be non-public. |
71 friend class base::RefCounted<BrowserPluginManager>; | 72 friend class base::RefCounted<BrowserPluginManager>; |
72 | 73 |
73 // Static factory instance (always NULL for non-test). | 74 // Static factory instance (always NULL for non-test). |
74 static BrowserPluginManagerFactory* factory_; | 75 static BrowserPluginManagerFactory* factory_; |
75 | 76 |
76 virtual ~BrowserPluginManager(); | 77 virtual ~BrowserPluginManager(); |
77 IDMap<BrowserPlugin> instances_; | 78 IDMap<BrowserPlugin> instances_; |
78 base::WeakPtr<RenderViewImpl> render_view_; | 79 base::WeakPtr<RenderViewImpl> render_view_; |
79 int browser_plugin_counter_; | 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager); |
80 }; | 82 }; |
81 | 83 |
82 } // namespace content | 84 } // namespace content |
83 | 85 |
84 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ | 86 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ |
OLD | NEW |