OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
7 | 7 |
8 #include "third_party/WebKit/public/web/WebPlugin.h" | 8 #include "third_party/WebKit/public/web/WebPlugin.h" |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/sequenced_task_runner_helpers.h" | 12 #include "base/sequenced_task_runner_helpers.h" |
13 #include "content/renderer/mouse_lock_dispatcher.h" | 13 #include "content/renderer/mouse_lock_dispatcher.h" |
14 #include "content/renderer/render_view_impl.h" | 14 #include "content/renderer/render_view_impl.h" |
15 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 15 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
16 #include "third_party/WebKit/public/web/WebDragStatus.h" | 16 #include "third_party/WebKit/public/web/WebDragStatus.h" |
17 #include "third_party/WebKit/public/web/WebNode.h" | 17 #include "third_party/WebKit/public/web/WebNode.h" |
18 #include "third_party/WebKit/public/web/WebWidget.h" | 18 #include "third_party/WebKit/public/web/WebWidget.h" |
19 | 19 |
20 struct BrowserPluginHostMsg_ResizeGuest_Params; | 20 struct BrowserPluginHostMsg_ResizeGuest_Params; |
21 struct FrameMsg_BuffersSwapped_Params; | 21 struct FrameMsg_BuffersSwapped_Params; |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class BrowserPluginDelegate; | 25 class BrowserPluginDelegate; |
| 26 class BrowserPluginManager; |
26 class ChildFrameCompositingHelper; | 27 class ChildFrameCompositingHelper; |
27 class BrowserPluginManager; | |
28 class MockBrowserPlugin; | |
29 | 28 |
30 class CONTENT_EXPORT BrowserPlugin : | 29 class CONTENT_EXPORT BrowserPlugin : |
31 NON_EXPORTED_BASE(public blink::WebPlugin), | 30 NON_EXPORTED_BASE(public blink::WebPlugin), |
32 public MouseLockDispatcher::LockTarget { | 31 public MouseLockDispatcher::LockTarget { |
33 public: | 32 public: |
34 static BrowserPlugin* GetFromNode(blink::WebNode& node); | 33 static BrowserPlugin* GetFromNode(blink::WebNode& node); |
35 | 34 |
36 RenderViewImpl* render_view() const { return render_view_.get(); } | |
37 int render_view_routing_id() const { return render_view_routing_id_; } | 35 int render_view_routing_id() const { return render_view_routing_id_; } |
38 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } | 36 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } |
39 bool attached() const { return attached_; } | 37 bool attached() const { return attached_; } |
40 BrowserPluginManager* browser_plugin_manager() const { | |
41 return browser_plugin_manager_.get(); | |
42 } | |
43 | 38 |
44 bool OnMessageReceived(const IPC::Message& msg); | 39 bool OnMessageReceived(const IPC::Message& msg); |
45 | 40 |
46 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value | 41 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value |
47 // |attribute_value|. | 42 // |attribute_value|. |
48 void UpdateDOMAttribute(const std::string& attribute_name, | 43 void UpdateDOMAttribute(const std::string& attribute_name, |
49 const base::string16& attribute_value); | 44 const base::string16& attribute_value); |
50 | 45 |
51 // Returns whether the guest process has crashed. | 46 // Returns whether the guest process has crashed. |
52 bool guest_crashed() const { return guest_crashed_; } | 47 bool guest_crashed() const { return guest_crashed_; } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // MouseLockDispatcher::LockTarget implementation. | 129 // MouseLockDispatcher::LockTarget implementation. |
135 void OnLockMouseACK(bool succeeded) override; | 130 void OnLockMouseACK(bool succeeded) override; |
136 void OnMouseLockLost() override; | 131 void OnMouseLockLost() override; |
137 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override; | 132 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override; |
138 | 133 |
139 private: | 134 private: |
140 friend class base::DeleteHelper<BrowserPlugin>; | 135 friend class base::DeleteHelper<BrowserPlugin>; |
141 // Only the manager is allowed to create a BrowserPlugin. | 136 // Only the manager is allowed to create a BrowserPlugin. |
142 friend class BrowserPluginManager; | 137 friend class BrowserPluginManager; |
143 | 138 |
144 // For unit/integration tests. | |
145 friend class MockBrowserPlugin; | |
146 | |
147 // A BrowserPlugin object is a controller that represents an instance of a | 139 // A BrowserPlugin object is a controller that represents an instance of a |
148 // browser plugin within the embedder renderer process. Once a BrowserPlugin | 140 // browser plugin within the embedder renderer process. Once a BrowserPlugin |
149 // does an initial navigation or is attached to a newly created guest, it | 141 // does an initial navigation or is attached to a newly created guest, it |
150 // acquires a browser_plugin_instance_id as well. The guest instance ID | 142 // acquires a browser_plugin_instance_id as well. The guest instance ID |
151 // uniquely identifies a guest WebContents that's hosted by this | 143 // uniquely identifies a guest WebContents that's hosted by this |
152 // BrowserPlugin. | 144 // BrowserPlugin. |
153 BrowserPlugin(RenderViewImpl* render_view, | 145 BrowserPlugin(RenderFrame* render_frame, |
154 blink::WebFrame* frame, | |
155 scoped_ptr<BrowserPluginDelegate> delegate); | 146 scoped_ptr<BrowserPluginDelegate> delegate); |
156 | 147 |
157 ~BrowserPlugin() override; | 148 ~BrowserPlugin() override; |
158 | 149 |
159 int width() const { return plugin_rect_.width(); } | 150 int width() const { return plugin_rect_.width(); } |
160 int height() const { return plugin_rect_.height(); } | 151 int height() const { return plugin_rect_.height(); } |
161 gfx::Size plugin_size() const { return plugin_rect_.size(); } | 152 gfx::Size plugin_size() const { return plugin_rect_.size(); } |
162 gfx::Rect plugin_rect() const { return plugin_rect_; } | 153 gfx::Rect plugin_rect() const { return plugin_rect_; } |
163 | 154 |
164 float GetDeviceScaleFactor() const; | 155 float GetDeviceScaleFactor() const; |
(...skipping 13 matching lines...) Expand all Loading... |
178 void OnSetContentsOpaque(int instance_id, bool opaque); | 169 void OnSetContentsOpaque(int instance_id, bool opaque); |
179 void OnSetCursor(int instance_id, const WebCursor& cursor); | 170 void OnSetCursor(int instance_id, const WebCursor& cursor); |
180 void OnSetMouseLock(int instance_id, bool enable); | 171 void OnSetMouseLock(int instance_id, bool enable); |
181 void OnSetTooltipText(int browser_plugin_instance_id, | 172 void OnSetTooltipText(int browser_plugin_instance_id, |
182 const base::string16& tooltip_text); | 173 const base::string16& tooltip_text); |
183 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | 174 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
184 | 175 |
185 // This indicates whether this BrowserPlugin has been attached to a | 176 // This indicates whether this BrowserPlugin has been attached to a |
186 // WebContents and is ready to receive IPCs. | 177 // WebContents and is ready to receive IPCs. |
187 bool attached_; | 178 bool attached_; |
188 const base::WeakPtr<RenderViewImpl> render_view_; | |
189 // We cache the |render_view_|'s routing ID because we need it on destruction. | 179 // We cache the |render_view_|'s routing ID because we need it on destruction. |
190 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 180 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
191 // then we will attempt to access a NULL pointer. | 181 // then we will attempt to access a NULL pointer. |
192 const int render_view_routing_id_; | 182 const int render_view_routing_id_; |
193 blink::WebPluginContainer* container_; | 183 blink::WebPluginContainer* container_; |
194 gfx::Rect plugin_rect_; | 184 gfx::Rect plugin_rect_; |
195 float last_device_scale_factor_; | 185 float last_device_scale_factor_; |
196 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 186 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
197 SkBitmap* sad_guest_; | 187 SkBitmap* sad_guest_; |
198 bool guest_crashed_; | 188 bool guest_crashed_; |
199 bool plugin_focused_; | 189 bool plugin_focused_; |
200 // Tracks the visibility of the browser plugin regardless of the whole | 190 // Tracks the visibility of the browser plugin regardless of the whole |
201 // embedder RenderView's visibility. | 191 // embedder RenderView's visibility. |
202 bool visible_; | 192 bool visible_; |
203 | 193 |
204 WebCursor cursor_; | 194 WebCursor cursor_; |
205 | 195 |
206 bool mouse_locked_; | 196 bool mouse_locked_; |
207 | 197 |
208 // This indicates that the BrowserPlugin has a geometry. | 198 // This indicates that the BrowserPlugin has a geometry. |
209 bool ready_; | 199 bool ready_; |
210 | 200 |
211 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | |
212 // store the BrowserPlugin's BrowserPluginManager in a member variable to | |
213 // avoid accessing the RenderViewImpl. | |
214 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | |
215 | |
216 // Used for HW compositing. | 201 // Used for HW compositing. |
217 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 202 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
218 | 203 |
219 // URL for the embedder frame. | 204 // URL for the embedder frame. |
220 int browser_plugin_instance_id_; | 205 int browser_plugin_instance_id_; |
221 | 206 |
222 // Indicates whether the guest content is opaque. | 207 // Indicates whether the guest content is opaque. |
223 bool contents_opaque_; | 208 bool contents_opaque_; |
224 | 209 |
225 std::vector<EditCommand> edit_commands_; | 210 std::vector<EditCommand> edit_commands_; |
226 | 211 |
227 scoped_ptr<BrowserPluginDelegate> delegate_; | 212 scoped_ptr<BrowserPluginDelegate> delegate_; |
228 | 213 |
229 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 214 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
230 // get called after BrowserPlugin has been destroyed. | 215 // get called after BrowserPlugin has been destroyed. |
231 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 216 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
232 | 217 |
233 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 218 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
234 }; | 219 }; |
235 | 220 |
236 } // namespace content | 221 } // namespace content |
237 | 222 |
238 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 223 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |