| 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" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "content/public/renderer/render_view_observer.h" | 12 #include "content/public/renderer/render_view_observer.h" |
| 13 #include "ipc/ipc_sender.h" | 13 #include "ipc/ipc_sender.h" |
| 14 | 14 |
| 15 namespace base { |
| 16 class DictionaryValue; |
| 17 } |
| 18 |
| 15 namespace blink { | 19 namespace blink { |
| 16 class WebFrame; | 20 class WebFrame; |
| 21 class WebNode; |
| 17 struct WebPluginParams; | 22 struct WebPluginParams; |
| 18 } | 23 } |
| 19 | 24 |
| 20 namespace content { | 25 namespace content { |
| 21 | 26 |
| 22 class BrowserPlugin; | 27 class BrowserPlugin; |
| 23 class BrowserPluginManagerFactory; | 28 class BrowserPluginManagerFactory; |
| 24 class RenderViewImpl; | 29 class RenderViewImpl; |
| 25 | 30 |
| 26 // BrowserPluginManager manages the routing of messages to the appropriate | 31 // BrowserPluginManager manages the routing of messages to the appropriate |
| (...skipping 15 matching lines...) Expand all Loading... |
| 42 | 47 |
| 43 // Creates a new BrowserPlugin object. | 48 // Creates a new BrowserPlugin object. |
| 44 // BrowserPlugin is responsible for associating itself with the | 49 // BrowserPlugin is responsible for associating itself with the |
| 45 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is | 50 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is |
| 46 // responsible for removing its association via RemoveBrowserPlugin. | 51 // responsible for removing its association via RemoveBrowserPlugin. |
| 47 virtual BrowserPlugin* CreateBrowserPlugin( | 52 virtual BrowserPlugin* CreateBrowserPlugin( |
| 48 RenderViewImpl* render_view, | 53 RenderViewImpl* render_view, |
| 49 blink::WebFrame* frame, | 54 blink::WebFrame* frame, |
| 50 bool auto_navigate) = 0; | 55 bool auto_navigate) = 0; |
| 51 | 56 |
| 52 void AddBrowserPlugin(int guest_instance_id, BrowserPlugin* browser_plugin); | 57 void Attach(int browser_plugin_instance_id); |
| 53 void RemoveBrowserPlugin(int guest_instance_id); | 58 |
| 54 BrowserPlugin* GetBrowserPlugin(int guest_instance_id) const; | 59 void AddBrowserPlugin(int browser_plugin_instance_id, |
| 60 BrowserPlugin* browser_plugin); |
| 61 void RemoveBrowserPlugin(int browser_plugin_instance_id); |
| 62 BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const; |
| 63 |
| 55 void UpdateDeviceScaleFactor(float device_scale_factor); | 64 void UpdateDeviceScaleFactor(float device_scale_factor); |
| 56 void UpdateFocusState(); | 65 void UpdateFocusState(); |
| 57 RenderViewImpl* render_view() const { return render_view_.get(); } | 66 RenderViewImpl* render_view() const { return render_view_.get(); } |
| 67 int GetNextInstanceID(); |
| 58 | 68 |
| 59 // RenderViewObserver implementation. | 69 // RenderViewObserver implementation. |
| 60 | 70 |
| 61 // BrowserPluginManager must override the default Send behavior. | 71 // BrowserPluginManager must override the default Send behavior. |
| 62 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; | 72 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; |
| 63 | 73 |
| 64 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. | 74 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. |
| 65 // BrowserPluginManager's lifetime is managed by a reference count. Once | 75 // BrowserPluginManager's lifetime is managed by a reference count. Once |
| 66 // the host RenderViewImpl and all BrowserPlugins release their references, | 76 // the host RenderViewImpl and all BrowserPlugins release their references, |
| 67 // then the BrowserPluginManager will be destroyed. | 77 // then the BrowserPluginManager will be destroyed. |
| 68 virtual void OnDestruct() OVERRIDE {} | 78 virtual void OnDestruct() OVERRIDE {} |
| 69 | 79 |
| 70 protected: | 80 protected: |
| 71 // Friend RefCounted so that the dtor can be non-public. | 81 // Friend RefCounted so that the dtor can be non-public. |
| 72 friend class base::RefCounted<BrowserPluginManager>; | 82 friend class base::RefCounted<BrowserPluginManager>; |
| 73 | 83 |
| 74 // Static factory instance (always NULL for non-test). | 84 // Static factory instance (always NULL for non-test). |
| 75 static BrowserPluginManagerFactory* factory_; | 85 static BrowserPluginManagerFactory* factory_; |
| 76 | 86 |
| 77 virtual ~BrowserPluginManager(); | 87 virtual ~BrowserPluginManager(); |
| 78 // This map is keyed by guest instance IDs. | 88 // This map is keyed by guest instance IDs. |
| 79 IDMap<BrowserPlugin> instances_; | 89 IDMap<BrowserPlugin> instances_; |
| 90 int current_instance_id_; |
| 80 base::WeakPtr<RenderViewImpl> render_view_; | 91 base::WeakPtr<RenderViewImpl> render_view_; |
| 81 | 92 |
| 82 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager); | 93 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager); |
| 83 }; | 94 }; |
| 84 | 95 |
| 85 } // namespace content | 96 } // namespace content |
| 86 | 97 |
| 87 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ | 98 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ |
| OLD | NEW |