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 #if defined(OS_WIN) | |
14 #include "base/memory/shared_memory.h" | |
15 #endif | |
16 #include "base/values.h" | 13 #include "base/values.h" |
17 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" | |
18 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 14 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
19 #include "content/renderer/mouse_lock_dispatcher.h" | 15 #include "content/renderer/mouse_lock_dispatcher.h" |
20 #include "content/renderer/render_view_impl.h" | 16 #include "content/renderer/render_view_impl.h" |
21 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 17 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
22 #include "third_party/WebKit/public/web/WebDragStatus.h" | 18 #include "third_party/WebKit/public/web/WebDragStatus.h" |
23 #include "third_party/WebKit/public/web/WebWidget.h" | 19 #include "third_party/WebKit/public/web/WebWidget.h" |
24 | 20 |
25 struct BrowserPluginHostMsg_AutoSize_Params; | 21 struct BrowserPluginHostMsg_AutoSize_Params; |
26 struct BrowserPluginHostMsg_ResizeGuest_Params; | 22 struct BrowserPluginHostMsg_ResizeGuest_Params; |
27 struct BrowserPluginMsg_Attach_ACK_Params; | 23 struct BrowserPluginMsg_Attach_ACK_Params; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 229 |
234 // Parses the attributes of the browser plugin from the element's attributes | 230 // Parses the attributes of the browser plugin from the element's attributes |
235 // and sets them appropriately. | 231 // and sets them appropriately. |
236 void ParseAttributes(); | 232 void ParseAttributes(); |
237 | 233 |
238 // Triggers the event-listeners for |event_name|. Note that the function | 234 // Triggers the event-listeners for |event_name|. Note that the function |
239 // frees all the values in |props|. | 235 // frees all the values in |props|. |
240 void TriggerEvent(const std::string& event_name, | 236 void TriggerEvent(const std::string& event_name, |
241 std::map<std::string, base::Value*>* props); | 237 std::map<std::string, base::Value*>* props); |
242 | 238 |
243 // Creates and maps a shared damage buffer. | 239 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state. |
244 virtual base::SharedMemory* CreateDamageBuffer( | |
245 const size_t size, | |
246 base::SharedMemoryHandle* shared_memory_handle); | |
247 // Swaps out the |current_damage_buffer_| with the |pending_damage_buffer_|. | |
248 void SwapDamageBuffers(); | |
249 | |
250 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state and | |
251 // allocates a new |pending_damage_buffer_| if in software rendering mode. | |
252 void PopulateResizeGuestParameters( | 240 void PopulateResizeGuestParameters( |
253 BrowserPluginHostMsg_ResizeGuest_Params* params, | 241 BrowserPluginHostMsg_ResizeGuest_Params* params, |
254 const gfx::Rect& view_size, | 242 const gfx::Rect& view_size, |
255 bool needs_repaint); | 243 bool needs_repaint); |
256 | 244 |
257 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. | 245 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. |
258 void PopulateAutoSizeParameters( | 246 void PopulateAutoSizeParameters( |
259 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled); | 247 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled); |
260 | 248 |
261 // Populates both AutoSize and ResizeGuest parameters based on the current | 249 // Populates both AutoSize and ResizeGuest parameters based on the current |
262 // autosize state. | 250 // autosize state. |
263 void GetDamageBufferWithSizeParams( | 251 void GetSizeParams( |
264 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 252 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
265 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, | 253 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, |
266 bool needs_repaint); | 254 bool needs_repaint); |
267 | 255 |
268 // Informs the guest of an updated autosize state. | 256 // Informs the guest of an updated autosize state. |
269 void UpdateGuestAutoSizeState(bool auto_size_enabled); | 257 void UpdateGuestAutoSizeState(bool auto_size_enabled); |
270 | 258 |
271 // Indicates whether a damage buffer was used by the guest process for the | |
272 // provided |params|. | |
273 static bool UsesDamageBuffer( | |
274 const BrowserPluginMsg_UpdateRect_Params& params); | |
275 | |
276 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels | |
277 // given the provided |params|. | |
278 bool UsesPendingDamageBuffer( | |
279 const BrowserPluginMsg_UpdateRect_Params& params); | |
280 | 259 |
281 // IPC message handlers. | 260 // IPC message handlers. |
282 // Please keep in alphabetical order. | 261 // Please keep in alphabetical order. |
283 void OnAdvanceFocus(int instance_id, bool reverse); | 262 void OnAdvanceFocus(int instance_id, bool reverse); |
284 void OnAttachACK(int instance_id, | 263 void OnAttachACK(int instance_id, |
285 const BrowserPluginMsg_Attach_ACK_Params& ack_params); | 264 const BrowserPluginMsg_Attach_ACK_Params& ack_params); |
286 void OnBuffersSwapped(int instance_id, | 265 void OnBuffersSwapped(int instance_id, |
287 const FrameMsg_BuffersSwapped_Params& params); | 266 const FrameMsg_BuffersSwapped_Params& params); |
288 void OnCompositorFrameSwapped(const IPC::Message& message); | 267 void OnCompositorFrameSwapped(const IPC::Message& message); |
289 void OnCopyFromCompositingSurface(int instance_id, | 268 void OnCopyFromCompositingSurface(int instance_id, |
(...skipping 16 matching lines...) Expand all Loading... |
306 // This indicates whether this BrowserPlugin has been attached to a | 285 // This indicates whether this BrowserPlugin has been attached to a |
307 // WebContents. | 286 // WebContents. |
308 bool attached_; | 287 bool attached_; |
309 base::WeakPtr<RenderViewImpl> render_view_; | 288 base::WeakPtr<RenderViewImpl> render_view_; |
310 // We cache the |render_view_|'s routing ID because we need it on destruction. | 289 // We cache the |render_view_|'s routing ID because we need it on destruction. |
311 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 290 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
312 // then we will attempt to access a NULL pointer. | 291 // then we will attempt to access a NULL pointer. |
313 int render_view_routing_id_; | 292 int render_view_routing_id_; |
314 blink::WebPluginContainer* container_; | 293 blink::WebPluginContainer* container_; |
315 scoped_ptr<BrowserPluginBindings> bindings_; | 294 scoped_ptr<BrowserPluginBindings> bindings_; |
316 scoped_ptr<BrowserPluginBackingStore> backing_store_; | |
317 scoped_ptr<base::SharedMemory> current_damage_buffer_; | |
318 scoped_ptr<base::SharedMemory> pending_damage_buffer_; | |
319 uint32 damage_buffer_sequence_id_; | |
320 bool paint_ack_received_; | 295 bool paint_ack_received_; |
321 gfx::Rect plugin_rect_; | 296 gfx::Rect plugin_rect_; |
322 float last_device_scale_factor_; | 297 float last_device_scale_factor_; |
323 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 298 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
324 SkBitmap* sad_guest_; | 299 SkBitmap* sad_guest_; |
325 bool guest_crashed_; | 300 bool guest_crashed_; |
326 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; | 301 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; |
327 bool is_auto_size_state_dirty_; | 302 bool is_auto_size_state_dirty_; |
328 // Maximum size constraint for autosize. | 303 // Maximum size constraint for autosize. |
329 gfx::Size max_auto_size_; | 304 gfx::Size max_auto_size_; |
(...skipping 14 matching lines...) Expand all Loading... |
344 gfx::Size last_view_size_; | 319 gfx::Size last_view_size_; |
345 bool before_first_navigation_; | 320 bool before_first_navigation_; |
346 bool mouse_locked_; | 321 bool mouse_locked_; |
347 | 322 |
348 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 323 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
349 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 324 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
350 // avoid accessing the RenderViewImpl. | 325 // avoid accessing the RenderViewImpl. |
351 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 326 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
352 | 327 |
353 // Used for HW compositing. | 328 // Used for HW compositing. |
354 bool compositing_enabled_; | |
355 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 329 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
356 | 330 |
357 // Used to identify the plugin to WebBindings. | 331 // Used to identify the plugin to WebBindings. |
358 scoped_ptr<struct _NPP> npp_; | 332 scoped_ptr<struct _NPP> npp_; |
359 | 333 |
360 // URL for the embedder frame. | 334 // URL for the embedder frame. |
361 GURL embedder_frame_url_; | 335 GURL embedder_frame_url_; |
362 | 336 |
363 std::vector<EditCommand> edit_commands_; | 337 std::vector<EditCommand> edit_commands_; |
364 | 338 |
365 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 339 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
366 // get called after BrowserPlugin has been destroyed. | 340 // get called after BrowserPlugin has been destroyed. |
367 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 341 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
368 | 342 |
369 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 343 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
370 }; | 344 }; |
371 | 345 |
372 } // namespace content | 346 } // namespace content |
373 | 347 |
374 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 348 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |