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 WebKit { | 15 namespace WebKit { |
16 class WebFrame; | 16 class WebFrame; |
17 struct WebPluginParams; | 17 struct WebPluginParams; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 class BrowserPlugin; | 22 class BrowserPluginImpl; |
23 class BrowserPluginManagerFactory; | 23 class BrowserPluginManagerFactory; |
24 class RenderViewImpl; | 24 class RenderViewImpl; |
25 | 25 |
26 // BrowserPluginManager manages the routing of messages to the appropriate | 26 // BrowserPluginManager manages the routing of messages to the appropriate |
27 // BrowserPlugin object based on its instance ID. | 27 // BrowserPlugin object based on its instance ID. |
28 class CONTENT_EXPORT BrowserPluginManager | 28 class CONTENT_EXPORT BrowserPluginManager |
29 : public RenderViewObserver, | 29 : public RenderViewObserver, |
30 public base::RefCounted<BrowserPluginManager> { | 30 public base::RefCounted<BrowserPluginManager> { |
31 public: | 31 public: |
32 // Returns the one BrowserPluginManager for this process. | 32 // Returns the one BrowserPluginManager for this process. |
33 static BrowserPluginManager* Create(RenderViewImpl* render_view); | 33 static BrowserPluginManager* Create(RenderViewImpl* render_view); |
34 | 34 |
35 // Overrides factory for testing. Default (NULL) value indicates regular | 35 // Overrides factory for testing. Default (NULL) value indicates regular |
36 // (non-test) environment. | 36 // (non-test) environment. |
37 static void set_factory_for_testing(BrowserPluginManagerFactory* factory) { | 37 static void set_factory_for_testing(BrowserPluginManagerFactory* factory) { |
38 BrowserPluginManager::factory_ = factory; | 38 BrowserPluginManager::factory_ = factory; |
39 } | 39 } |
40 | 40 |
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 BrowserPluginImpl* 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 | 51 |
52 void AddBrowserPlugin(int instance_id, BrowserPlugin* browser_plugin); | 52 void AddBrowserPlugin(int instance_id, BrowserPluginImpl* browser_plugin); |
53 void RemoveBrowserPlugin(int instance_id); | 53 void RemoveBrowserPlugin(int instance_id); |
54 BrowserPlugin* GetBrowserPlugin(int instance_id) const; | 54 BrowserPluginImpl* GetBrowserPlugin(int instance_id) const; |
55 void SetEmbedderFocus(const RenderViewImpl* embedder, bool focused); | 55 void SetEmbedderFocus(const RenderViewImpl* embedder, bool focused); |
56 RenderViewImpl* render_view() const { return render_view_; } | 56 RenderViewImpl* render_view() const { return render_view_; } |
57 | 57 |
58 void RequestMessage(uint32 message_id); | |
sadrul
2013/01/09 15:21:54
doc
Fady Samuel
2013/01/09 17:41:24
Done.
| |
59 | |
58 // RenderViewObserver implementation. | 60 // RenderViewObserver implementation. |
59 | 61 |
60 // BrowserPluginManager must override the default Send behavior. | 62 // BrowserPluginManager must override the default Send behavior. |
61 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; | 63 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; |
62 | 64 |
63 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. | 65 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. |
64 // BrowserPluginManager's lifetime is managed by a reference count. Once | 66 // BrowserPluginManager's lifetime is managed by a reference count. Once |
65 // the host RenderViewImpl and all BrowserPlugins release their references, | 67 // the host RenderViewImpl and all BrowserPlugins release their references, |
66 // then the BrowserPluginManager will be destroyed. | 68 // then the BrowserPluginManager will be destroyed. |
67 virtual void OnDestruct() OVERRIDE {} | 69 virtual void OnDestruct() OVERRIDE {} |
68 | 70 |
69 protected: | 71 protected: |
70 // Friend RefCounted so that the dtor can be non-public. | 72 // Friend RefCounted so that the dtor can be non-public. |
71 friend class base::RefCounted<BrowserPluginManager>; | 73 friend class base::RefCounted<BrowserPluginManager>; |
72 | 74 |
75 | |
sadrul
2013/01/09 15:21:54
too many new lines
Fady Samuel
2013/01/09 17:41:24
Done.
| |
76 // Returns whether a message should be forwarded to BrowserPlugins. | |
77 bool ShouldForwardToBrowserPlugin(const IPC::Message& message); | |
78 | |
73 // Static factory instance (always NULL for non-test). | 79 // Static factory instance (always NULL for non-test). |
74 static BrowserPluginManagerFactory* factory_; | 80 static BrowserPluginManagerFactory* factory_; |
75 | 81 |
76 virtual ~BrowserPluginManager(); | 82 virtual ~BrowserPluginManager(); |
77 IDMap<BrowserPlugin> instances_; | 83 IDMap<BrowserPluginImpl> instances_; |
78 base::WeakPtr<RenderViewImpl> render_view_; | 84 base::WeakPtr<RenderViewImpl> render_view_; |
79 int browser_plugin_counter_; | 85 int browser_plugin_counter_; |
86 // Set of messages requested by BrowserPluginObservers. | |
87 std::set<uint32> browser_plugin_messages_; | |
80 }; | 88 }; |
sadrul
2013/01/09 15:21:54
You should have a DISALLOW_COPY_AND_ASSIGN inside
Fady Samuel
2013/01/09 17:41:24
Done.
| |
81 | 89 |
82 } // namespace content | 90 } // namespace content |
83 | 91 |
84 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ | 92 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ |
OLD | NEW |