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" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values. | 73 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values. |
74 void ParseSizeContraintsChanged(); | 74 void ParseSizeContraintsChanged(); |
75 | 75 |
76 bool InAutoSizeBounds(const gfx::Size& size) const; | 76 bool InAutoSizeBounds(const gfx::Size& size) const; |
77 | 77 |
78 // Get the guest's DOMWindow proxy. | 78 // Get the guest's DOMWindow proxy. |
79 NPObject* GetContentWindow() const; | 79 NPObject* GetContentWindow() const; |
80 | 80 |
81 // Returns whether the guest process has crashed. | 81 // Returns whether the guest process has crashed. |
82 bool guest_crashed() const { return guest_crashed_; } | 82 bool guest_crashed() const { return guest_crashed_; } |
83 // Returns whether this BrowserPlugin has allocated an instance ID. | |
84 bool HasGuestInstanceID() const; | |
85 | 83 |
86 // Informs the guest of an updated focus state. | 84 // Informs the guest of an updated focus state. |
87 void UpdateGuestFocusState(); | 85 void UpdateGuestFocusState(); |
88 // Indicates whether the guest should be focused. | 86 // Indicates whether the guest should be focused. |
89 bool ShouldGuestBeFocused() const; | 87 bool ShouldGuestBeFocused() const; |
90 | 88 |
91 // Embedder's device scale factor changed, we need to update the guest | 89 // Embedder's device scale factor changed, we need to update the guest |
92 // renderer. | 90 // renderer. |
93 void UpdateDeviceScaleFactor(float device_scale_factor); | 91 void UpdateDeviceScaleFactor(float device_scale_factor); |
94 | 92 |
95 // A request to enable hardware compositing. | 93 // A request to enable hardware compositing. |
96 void EnableCompositing(bool enable); | 94 void EnableCompositing(bool enable); |
97 | 95 |
98 // Provided that a guest instance ID has been allocated, this method attaches | 96 // Provided that a guest instance ID has been allocated, this method attaches |
99 // this BrowserPlugin instance to that guest. |extra_params| are parameters | 97 // this BrowserPlugin instance to that guest. |
100 // passed in by the content embedder to the browser process. | 98 void Attach(); |
101 void Attach(int guest_instance_id, | |
102 scoped_ptr<base::DictionaryValue> extra_params); | |
103 | 99 |
104 // Notify the plugin about a compositor commit so that frame ACKs could be | 100 // Notify the plugin about a compositor commit so that frame ACKs could be |
105 // sent, if needed. | 101 // sent, if needed. |
106 void DidCommitCompositorFrame(); | 102 void DidCommitCompositorFrame(); |
107 | 103 |
| 104 static BrowserPlugin* FromNode(blink::WebNode& node); |
| 105 |
108 // Returns whether a message should be forwarded to BrowserPlugin. | 106 // Returns whether a message should be forwarded to BrowserPlugin. |
109 static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); | 107 static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); |
110 | 108 |
111 // blink::WebPlugin implementation. | 109 // blink::WebPlugin implementation. |
112 virtual blink::WebPluginContainer* container() const OVERRIDE; | 110 virtual blink::WebPluginContainer* container() const OVERRIDE; |
113 virtual bool initialize(blink::WebPluginContainer* container) OVERRIDE; | 111 virtual bool initialize(blink::WebPluginContainer* container) OVERRIDE; |
114 virtual void destroy() OVERRIDE; | 112 virtual void destroy() OVERRIDE; |
115 virtual NPObject* scriptableObject() OVERRIDE; | 113 virtual NPObject* scriptableObject() OVERRIDE; |
116 virtual struct _NPP* pluginNPP() OVERRIDE; | 114 virtual struct _NPP* pluginNPP() OVERRIDE; |
117 virtual bool supportsKeyboardFocus() const OVERRIDE; | 115 virtual bool supportsKeyboardFocus() const OVERRIDE; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, | 226 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, |
229 bool needs_repaint); | 227 bool needs_repaint); |
230 | 228 |
231 // Informs the guest of an updated autosize state. | 229 // Informs the guest of an updated autosize state. |
232 void UpdateGuestAutoSizeState(bool auto_size_enabled); | 230 void UpdateGuestAutoSizeState(bool auto_size_enabled); |
233 | 231 |
234 | 232 |
235 // IPC message handlers. | 233 // IPC message handlers. |
236 // Please keep in alphabetical order. | 234 // Please keep in alphabetical order. |
237 void OnAdvanceFocus(int instance_id, bool reverse); | 235 void OnAdvanceFocus(int instance_id, bool reverse); |
238 void OnAttachACK(int instance_id); | 236 void OnAttachACK(int browser_plugin_instance_id, int guest_instance_id); |
239 void OnBuffersSwapped(int instance_id, | 237 void OnBuffersSwapped(int instance_id, |
240 const FrameMsg_BuffersSwapped_Params& params); | 238 const FrameMsg_BuffersSwapped_Params& params); |
241 void OnCompositorFrameSwapped(const IPC::Message& message); | 239 void OnCompositorFrameSwapped(const IPC::Message& message); |
242 void OnCopyFromCompositingSurface(int instance_id, | 240 void OnCopyFromCompositingSurface(int instance_id, |
243 int request_id, | 241 int request_id, |
244 gfx::Rect source_rect, | 242 gfx::Rect source_rect, |
245 gfx::Size dest_size); | 243 gfx::Size dest_size); |
246 void OnGuestContentWindowReady(int instance_id, | 244 void OnGuestContentWindowReady(int instance_id, |
247 int content_window_routing_id); | 245 int content_window_routing_id); |
248 void OnGuestGone(int instance_id); | 246 void OnGuestGone(int instance_id); |
249 void OnSetCursor(int instance_id, const WebCursor& cursor); | 247 void OnSetCursor(int instance_id, const WebCursor& cursor); |
250 void OnSetMouseLock(int instance_id, bool enable); | 248 void OnSetMouseLock(int instance_id, bool enable); |
251 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | 249 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
252 void OnUpdateRect(int instance_id, | 250 void OnUpdateRect(int instance_id, |
253 const BrowserPluginMsg_UpdateRect_Params& params); | 251 const BrowserPluginMsg_UpdateRect_Params& params); |
254 | 252 |
255 // This is the browser-process-allocated instance ID that uniquely identifies | 253 // This is the browser-process-allocated instance ID that uniquely identifies |
256 // a guest WebContents. | 254 // a guest WebContents. |
257 int guest_instance_id_; | 255 int guest_instance_id_; |
258 // This indicates whether this BrowserPlugin has been attached to a | 256 // This indicates whether this BrowserPlugin has been attached to a |
259 // WebContents. | 257 // WebContents. |
260 bool attached_; | 258 bool attached_; |
| 259 // This indicates that this BrowserPlugin is in the process of being attached. |
| 260 bool attach_pending_; |
261 const base::WeakPtr<RenderViewImpl> render_view_; | 261 const base::WeakPtr<RenderViewImpl> render_view_; |
262 // We cache the |render_view_|'s routing ID because we need it on destruction. | 262 // We cache the |render_view_|'s routing ID because we need it on destruction. |
263 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 263 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
264 // then we will attempt to access a NULL pointer. | 264 // then we will attempt to access a NULL pointer. |
265 const int render_view_routing_id_; | 265 const int render_view_routing_id_; |
266 blink::WebPluginContainer* container_; | 266 blink::WebPluginContainer* container_; |
267 scoped_ptr<BrowserPluginBindings> bindings_; | 267 scoped_ptr<BrowserPluginBindings> bindings_; |
268 bool paint_ack_received_; | 268 bool paint_ack_received_; |
269 gfx::Rect plugin_rect_; | 269 gfx::Rect plugin_rect_; |
270 float last_device_scale_factor_; | 270 float last_device_scale_factor_; |
(...skipping 21 matching lines...) Expand all Loading... |
292 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 292 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
293 // avoid accessing the RenderViewImpl. | 293 // avoid accessing the RenderViewImpl. |
294 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 294 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
295 | 295 |
296 // Used for HW compositing. | 296 // Used for HW compositing. |
297 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 297 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
298 | 298 |
299 // Used to identify the plugin to WebBindings. | 299 // Used to identify the plugin to WebBindings. |
300 scoped_ptr<struct _NPP> npp_; | 300 scoped_ptr<struct _NPP> npp_; |
301 | 301 |
| 302 // URL for the embedder frame. |
| 303 bool in_render_tree_; |
| 304 int instance_id_; |
| 305 |
302 std::vector<EditCommand> edit_commands_; | 306 std::vector<EditCommand> edit_commands_; |
303 | 307 |
304 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 308 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
305 // get called after BrowserPlugin has been destroyed. | 309 // get called after BrowserPlugin has been destroyed. |
306 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 310 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
307 | 311 |
308 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 312 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
309 }; | 313 }; |
310 | 314 |
311 } // namespace content | 315 } // namespace content |
312 | 316 |
313 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 317 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |