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

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

Issue 617123005: Remove BrowserPlugin tests (only one test remaining with existing coverage) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make_lifetime_explicit
Patch Set: More cleanup Created 6 years, 2 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
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"
12 #include "content/public/renderer/render_view_observer.h" 11 #include "content/public/renderer/render_view_observer.h"
13 #include "ipc/ipc_sender.h" 12 #include "ipc/ipc_sender.h"
14 13
15 namespace base {
16 class DictionaryValue;
17 }
18
19 namespace blink { 14 namespace blink {
20 class WebFrame; 15 class WebFrame;
21 class WebNode;
22 struct WebPluginParams;
23 } 16 }
24 17
25 namespace content { 18 namespace content {
26 19
27 class BrowserPlugin; 20 class BrowserPlugin;
28 class BrowserPluginDelegate; 21 class BrowserPluginDelegate;
29 class BrowserPluginManagerFactory;
30 class RenderViewImpl; 22 class RenderViewImpl;
31 23
32 // BrowserPluginManager manages the routing of messages to the appropriate 24 // BrowserPluginManager manages the routing of messages to the appropriate
33 // BrowserPlugin object based on its instance ID. 25 // BrowserPlugin object based on its instance ID.
34 class CONTENT_EXPORT BrowserPluginManager 26 class CONTENT_EXPORT BrowserPluginManager
35 : public RenderViewObserver, 27 : public RenderViewObserver,
36 public base::RefCounted<BrowserPluginManager> { 28 public base::RefCounted<BrowserPluginManager> {
37 public: 29 public:
38 // Returns the one BrowserPluginManager for this process. 30 // Returns the one BrowserPluginManager for this process.
39 static BrowserPluginManager* Create(RenderViewImpl* render_view); 31 static BrowserPluginManager* Create(RenderViewImpl* render_view);
40 32
41 // Overrides factory for testing. Default (NULL) value indicates regular
42 // (non-test) environment.
43 static void set_factory_for_testing(BrowserPluginManagerFactory* factory) {
44 BrowserPluginManager::factory_ = factory;
45 }
46
47 explicit BrowserPluginManager(RenderViewImpl* render_view); 33 explicit BrowserPluginManager(RenderViewImpl* render_view);
48 34
49 // Creates a new BrowserPlugin object. 35 // Creates a new BrowserPlugin object.
50 // BrowserPlugin is responsible for associating itself with the 36 // BrowserPlugin is responsible for associating itself with the
51 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is 37 // BrowserPluginManager via AddBrowserPlugin. When it is destroyed, it is
52 // responsible for removing its association via RemoveBrowserPlugin. 38 // responsible for removing its association via RemoveBrowserPlugin.
53 virtual BrowserPlugin* CreateBrowserPlugin( 39 BrowserPlugin* CreateBrowserPlugin(
54 RenderViewImpl* render_view, 40 RenderViewImpl* render_view,
55 blink::WebFrame* frame, 41 blink::WebFrame* frame,
56 scoped_ptr<BrowserPluginDelegate> delegate) = 0; 42 scoped_ptr<BrowserPluginDelegate> delegate);
57 43
58 void Attach(int browser_plugin_instance_id); 44 void Attach(int browser_plugin_instance_id);
59 45
60 void AddBrowserPlugin(int browser_plugin_instance_id, 46 void AddBrowserPlugin(int browser_plugin_instance_id,
61 BrowserPlugin* browser_plugin); 47 BrowserPlugin* browser_plugin);
62 void RemoveBrowserPlugin(int browser_plugin_instance_id); 48 void RemoveBrowserPlugin(int browser_plugin_instance_id);
63 BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const; 49 BrowserPlugin* GetBrowserPlugin(int browser_plugin_instance_id) const;
64 50
65 void UpdateDeviceScaleFactor(); 51 void UpdateDeviceScaleFactor();
66 void UpdateFocusState(); 52 void UpdateFocusState();
67 RenderViewImpl* render_view() const { return render_view_.get(); } 53 RenderViewImpl* render_view() const { return render_view_.get(); }
68 int GetNextInstanceID(); 54 int GetNextInstanceID();
69 55
70 // RenderViewObserver implementation. 56 // RenderViewObserver override. Call on render thread.
71 57 virtual void DidCommitCompositorFrame() OVERRIDE;
72 // BrowserPluginManager must override the default Send behavior. 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
73 virtual bool Send(IPC::Message* msg) OVERRIDE = 0; 59 virtual bool Send(IPC::Message* msg) OVERRIDE;
74 60
75 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away. 61 // Don't destroy the BrowserPluginManager when the RenderViewImpl goes away.
76 // BrowserPluginManager's lifetime is managed by a reference count. Once 62 // BrowserPluginManager's lifetime is managed by a reference count. Once
77 // the host RenderViewImpl and all BrowserPlugins release their references, 63 // the host RenderViewImpl and all BrowserPlugins release their references,
78 // then the BrowserPluginManager will be destroyed. 64 // then the BrowserPluginManager will be destroyed.
79 virtual void OnDestruct() OVERRIDE {} 65 virtual void OnDestruct() OVERRIDE {}
80 66
81 protected: 67 protected:
82 // Friend RefCounted so that the dtor can be non-public. 68 // Friend RefCounted so that the dtor can be non-public.
83 friend class base::RefCounted<BrowserPluginManager>; 69 friend class base::RefCounted<BrowserPluginManager>;
84 70
85 // Static factory instance (always NULL for non-test).
86 static BrowserPluginManagerFactory* factory_;
87
88 virtual ~BrowserPluginManager(); 71 virtual ~BrowserPluginManager();
89 // This map is keyed by guest instance IDs. 72 // This map is keyed by guest instance IDs.
90 IDMap<BrowserPlugin> instances_; 73 IDMap<BrowserPlugin> instances_;
91 int current_instance_id_; 74 int current_instance_id_;
92 base::WeakPtr<RenderViewImpl> render_view_; 75 base::WeakPtr<RenderViewImpl> render_view_;
93 76
94 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager); 77 DISALLOW_COPY_AND_ASSIGN(BrowserPluginManager);
95 }; 78 };
96 79
97 } // namespace content 80 } // namespace content
98 81
99 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_ 82 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698