Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_manager.h

Issue 11826005: Browser Plugin: Implement BrowserPluginObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 explicit BrowserPluginManager(RenderViewImpl* render_view); 41 explicit 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 virtual void AllocateInstanceID(BrowserPlugin* browser_plugin) = 0; 51 virtual void AllocateInstanceID(BrowserPluginImpl* browser_plugin) = 0;
52 52
53 void AddBrowserPlugin(int instance_id, BrowserPlugin* browser_plugin); 53 void AddBrowserPlugin(int instance_id, BrowserPluginImpl* browser_plugin);
54 void RemoveBrowserPlugin(int instance_id); 54 void RemoveBrowserPlugin(int instance_id);
55 BrowserPlugin* GetBrowserPlugin(int instance_id) const; 55 BrowserPluginImpl* GetBrowserPlugin(int instance_id) const;
56 void UpdateFocusState(); 56 void UpdateFocusState();
57 RenderViewImpl* render_view() const { return render_view_; } 57 RenderViewImpl* render_view() const { return render_view_; }
58 58
59 // RenderViewObserver implementation. 59 // RenderViewObserver implementation.
60 60
61 // BrowserPluginManager must override the default Send behavior. 61 // BrowserPluginManager must override the default Send behavior.
62 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; 62 virtual bool Send(IPC::Message* msg) OVERRIDE = 0;
63 63
64 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. 64 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away.
65 // BrowserPluginManager's lifetime is managed by a reference count. Once 65 // BrowserPluginManager's lifetime is managed by a reference count. Once
66 // the host RenderViewImpl and all BrowserPlugins release their references, 66 // the host RenderViewImpl and all BrowserPlugins release their references,
67 // then the BrowserPluginManager will be destroyed. 67 // then the BrowserPluginManager will be destroyed.
68 virtual void OnDestruct() OVERRIDE {} 68 virtual void OnDestruct() OVERRIDE {}
69 69
70 protected: 70 protected:
71 // Friend RefCounted so that the dtor can be non-public. 71 // Friend RefCounted so that the dtor can be non-public.
72 friend class base::RefCounted<BrowserPluginManager>; 72 friend class base::RefCounted<BrowserPluginManager>;
73 73
74 // Initialize the set of message types that should be forwarded to
75 // BrowserPlugins.
76 void InitializeMessageSet();
77
78 // Returns whether a message should be forwarded to BrowserPlugins.
79 bool ShouldForwardToBrowserPlugin(const IPC::Message& message);
80
74 // Static factory instance (always NULL for non-test). 81 // Static factory instance (always NULL for non-test).
75 static BrowserPluginManagerFactory* factory_; 82 static BrowserPluginManagerFactory* factory_;
76 83
77 virtual ~BrowserPluginManager(); 84 virtual ~BrowserPluginManager();
78 IDMap<BrowserPlugin> instances_; 85 IDMap<BrowserPluginImpl> instances_;
79 base::WeakPtr<RenderViewImpl> render_view_; 86 base::WeakPtr<RenderViewImpl> render_view_;
87 // Set of messages requested by BrowserPluginObservers.
88 std::set<uint32> browser_plugin_messages_;
80 89
81 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager); 90 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager);
82 }; 91 };
83 92
84 } // namespace content 93 } // namespace content
85 94
86 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ 95 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_impl.cc ('k') | content/renderer/browser_plugin/browser_plugin_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698