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

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

Issue 801173002: Fix message routing for BrowserPlugin in iframe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup Created 6 years 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
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/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "content/public/renderer/render_process_observer.h"
11 #include "content/public/renderer/render_view_observer.h"
12 #include "ipc/ipc_sender.h" 11 #include "ipc/ipc_sender.h"
13 12
14 namespace blink { 13 namespace blink {
15 class WebFrame; 14 class WebFrame;
16 } 15 }
17 16
18 namespace content { 17 namespace content {
19 18
20 class BrowserPlugin; 19 class BrowserPlugin;
21 class BrowserPluginDelegate; 20 class BrowserPluginDelegate;
22 class RenderViewImpl; 21 class RenderViewImpl;
23 22
24 // BrowserPluginManager manages the routing of messages to the appropriate 23 // BrowserPluginManager manages the routing of messages to the appropriate
Charlie Reis 2014/12/17 00:06:44 Since this is no longer specific to a RenderView,
Fady Samuel 2014/12/17 19:30:35 Done.
25 // BrowserPlugin object based on its instance ID. 24 // BrowserPlugin object based on its instance ID.
26 class CONTENT_EXPORT BrowserPluginManager 25 class CONTENT_EXPORT BrowserPluginManager : public RenderProcessObserver {
27 : public RenderViewObserver,
28 public base::RefCounted<BrowserPluginManager> {
29 public: 26 public:
30 // Returns the one BrowserPluginManager for this process. 27 static BrowserPluginManager* Get();
31 static BrowserPluginManager* Create(RenderViewImpl* render_view);
32 28
33 explicit BrowserPluginManager(RenderViewImpl* render_view); 29 BrowserPluginManager();
30 ~BrowserPluginManager() override;
34 31
35 // Creates a new BrowserPlugin object. 32 // Creates a new BrowserPlugin object.
36 // BrowserPlugin is responsible for associating itself with the 33 // BrowserPlugin is responsible for associating itself with the
37 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is 34 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is
38 // responsible for removing its association via RemoveBrowserPlugin. 35 // responsible for removing its association via RemoveBrowserPlugin.
39 BrowserPlugin* CreateBrowserPlugin( 36 BrowserPlugin* CreateBrowserPlugin(
40 RenderViewImpl* render_view, 37 RenderViewImpl* render_view,
41 blink::WebFrame* frame, 38 blink::WebFrame* frame,
42 scoped_ptr<BrowserPluginDelegate> delegate); 39 scoped_ptr<BrowserPluginDelegate> delegate);
43 40
44 void Attach(int browser_plugin_instance_id); 41 void Attach(int browser_plugin_instance_id);
45 42
46 void Detach(int browser_plugin_instance_id); 43 void Detach(int browser_plugin_instance_id);
47 44
48 void AddBrowserPlugin(int browser_plugin_instance_id, 45 void AddBrowserPlugin(int browser_plugin_instance_id,
49 BrowserPlugin* browser_plugin); 46 BrowserPlugin* browser_plugin);
50 void RemoveBrowserPlugin(int browser_plugin_instance_id); 47 void RemoveBrowserPlugin(int browser_plugin_instance_id);
51 BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const; 48 BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const;
52 49
53 void UpdateDeviceScaleFactor(); 50 void UpdateDeviceScaleFactor();
54 void UpdateFocusState(); 51 void UpdateFocusState();
55 RenderViewImpl* render_view() const { return render_view_.get(); }
56 52
57 // Returns a new instance ID to be used by BrowserPlugin. Instance IDs are 53 // Returns a new instance ID to be used by BrowserPlugin. Instance IDs are
58 // unique per process. 54 // unique per process.
59 int GetNextInstanceID(); 55 int GetNextInstanceID();
60 56
61 // RenderViewObserver override. Call on render thread. 57 void DidCommitCompositorFrame();
62 void DidCommitCompositorFrame() override; 58 bool Send(IPC::Message* msg);
63 bool OnMessageReceived(const IPC::Message& message) override;
64 bool Send(IPC::Message* msg) override;
65 59
66 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. 60 // RenderProcessObserver override.
67 // BrowserPluginManager's lifetime is managed by a reference count. Once 61 bool OnControlMessageReceived(const IPC::Message& message) override;
68 // the host RenderViewImpl and all BrowserPlugins release their references,
69 // then the BrowserPluginManager will be destroyed.
70 void OnDestruct() override {}
71 62
72 private: 63 private:
73 // Friend RefCounted so that the dtor can be non-public.
74 friend class base::RefCounted<BrowserPluginManager>;
75
76 ~BrowserPluginManager() override;
77
78 // IPC message handlers. 64 // IPC message handlers.
79 void OnCompositorFrameSwappedPluginUnavailable(const IPC::Message& message); 65 void OnCompositorFrameSwappedPluginUnavailable(const IPC::Message& message);
80 66
81 // This map is keyed by guest instance IDs. 67 // This map is keyed by guest instance IDs.
82 IDMap<BrowserPlugin> instances_; 68 IDMap<BrowserPlugin> instances_;
83 base::WeakPtr<RenderViewImpl> render_view_;
84 69
85 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager); 70 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager);
86 }; 71 };
87 72
88 } // namespace content 73 } // namespace content
89 74
90 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ 75 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698