| 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 "base/values.h" | |
| 14 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 13 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 15 #include "content/renderer/mouse_lock_dispatcher.h" | 14 #include "content/renderer/mouse_lock_dispatcher.h" |
| 16 #include "content/renderer/render_view_impl.h" | 15 #include "content/renderer/render_view_impl.h" |
| 17 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 16 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 18 #include "third_party/WebKit/public/web/WebDragStatus.h" | 17 #include "third_party/WebKit/public/web/WebDragStatus.h" |
| 19 #include "third_party/WebKit/public/web/WebWidget.h" | 18 #include "third_party/WebKit/public/web/WebWidget.h" |
| 20 | 19 |
| 21 struct BrowserPluginHostMsg_AutoSize_Params; | 20 struct BrowserPluginHostMsg_AutoSize_Params; |
| 22 struct BrowserPluginHostMsg_ResizeGuest_Params; | 21 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 23 struct BrowserPluginMsg_Attach_ACK_Params; | |
| 24 struct BrowserPluginMsg_UpdateRect_Params; | 22 struct BrowserPluginMsg_UpdateRect_Params; |
| 25 struct FrameMsg_BuffersSwapped_Params; | 23 struct FrameMsg_BuffersSwapped_Params; |
| 26 | 24 |
| 27 namespace content { | 25 namespace content { |
| 28 | 26 |
| 29 class ChildFrameCompositingHelper; | 27 class ChildFrameCompositingHelper; |
| 30 class BrowserPluginManager; | 28 class BrowserPluginManager; |
| 31 class MockBrowserPlugin; | 29 class MockBrowserPlugin; |
| 32 | 30 |
| 33 class CONTENT_EXPORT BrowserPlugin : | 31 class CONTENT_EXPORT BrowserPlugin : |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. | 51 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. |
| 54 std::string GetDOMAttributeValue(const std::string& attribute_name) const; | 52 std::string GetDOMAttributeValue(const std::string& attribute_name) const; |
| 55 // Checks if the attribute |attribute_name| exists in the DOM. | 53 // Checks if the attribute |attribute_name| exists in the DOM. |
| 56 bool HasDOMAttribute(const std::string& attribute_name) const; | 54 bool HasDOMAttribute(const std::string& attribute_name) const; |
| 57 | 55 |
| 58 // Get the allowtransparency attribute value. | 56 // Get the allowtransparency attribute value. |
| 59 bool GetAllowTransparencyAttribute() const; | 57 bool GetAllowTransparencyAttribute() const; |
| 60 // Parse the allowtransparency attribute and adjust transparency of | 58 // Parse the allowtransparency attribute and adjust transparency of |
| 61 // BrowserPlugin accordingly. | 59 // BrowserPlugin accordingly. |
| 62 void ParseAllowTransparencyAttribute(); | 60 void ParseAllowTransparencyAttribute(); |
| 63 // Get the src attribute value of the BrowserPlugin instance. | |
| 64 std::string GetSrcAttribute() const; | |
| 65 // Parse the src attribute value of the BrowserPlugin instance. | |
| 66 bool ParseSrcAttribute(std::string* error_message); | |
| 67 // Get the autosize attribute value. | 61 // Get the autosize attribute value. |
| 68 bool GetAutoSizeAttribute() const; | 62 bool GetAutoSizeAttribute() const; |
| 69 // Parses the autosize attribute value. | 63 // Parses the autosize attribute value. |
| 70 void ParseAutoSizeAttribute(); | 64 void ParseAutoSizeAttribute(); |
| 71 // Get the maxheight attribute value. | 65 // Get the maxheight attribute value. |
| 72 int GetMaxHeightAttribute() const; | 66 int GetMaxHeightAttribute() const; |
| 73 // Get the maxwidth attribute value. | 67 // Get the maxwidth attribute value. |
| 74 int GetMaxWidthAttribute() const; | 68 int GetMaxWidthAttribute() const; |
| 75 // Get the minheight attribute value. | 69 // Get the minheight attribute value. |
| 76 int GetMinHeightAttribute() const; | 70 int GetMinHeightAttribute() const; |
| 77 // Get the minwidth attribute value. | 71 // Get the minwidth attribute value. |
| 78 int GetMinWidthAttribute() const; | 72 int GetMinWidthAttribute() const; |
| 79 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values. | 73 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values. |
| 80 void ParseSizeContraintsChanged(); | 74 void ParseSizeContraintsChanged(); |
| 81 // The partition identifier string is stored as UTF-8. | |
| 82 std::string GetPartitionAttribute() const; | |
| 83 // This method can be successfully called only before the first navigation for | |
| 84 // this instance of BrowserPlugin. If an error occurs, the |error_message| is | |
| 85 // set appropriately to indicate the failure reason. | |
| 86 bool ParsePartitionAttribute(std::string* error_message); | |
| 87 // True if the partition attribute can be removed. | 75 // True if the partition attribute can be removed. |
| 88 bool CanRemovePartitionAttribute(std::string* error_message); | 76 bool CanRemovePartitionAttribute(std::string* error_message); |
| 89 | 77 |
| 90 bool InAutoSizeBounds(const gfx::Size& size) const; | 78 bool InAutoSizeBounds(const gfx::Size& size) const; |
| 91 | 79 |
| 92 // Get the guest's DOMWindow proxy. | 80 // Get the guest's DOMWindow proxy. |
| 93 NPObject* GetContentWindow() const; | 81 NPObject* GetContentWindow() const; |
| 94 | 82 |
| 95 // Returns whether the guest process has crashed. | 83 // Returns whether the guest process has crashed. |
| 96 bool guest_crashed() const { return guest_crashed_; } | 84 bool guest_crashed() const { return guest_crashed_; } |
| 97 // Returns whether this BrowserPlugin has requested an instance ID. | |
| 98 bool HasNavigated() const; | |
| 99 // Returns whether this BrowserPlugin has allocated an instance ID. | 85 // Returns whether this BrowserPlugin has allocated an instance ID. |
| 100 bool HasGuestInstanceID() const; | 86 bool HasGuestInstanceID() const; |
| 101 | 87 |
| 102 // Informs the guest of an updated focus state. | 88 // Informs the guest of an updated focus state. |
| 103 void UpdateGuestFocusState(); | 89 void UpdateGuestFocusState(); |
| 104 // Indicates whether the guest should be focused. | 90 // Indicates whether the guest should be focused. |
| 105 bool ShouldGuestBeFocused() const; | 91 bool ShouldGuestBeFocused() const; |
| 106 | 92 |
| 107 // Embedder's device scale factor changed, we need to update the guest | 93 // Embedder's device scale factor changed, we need to update the guest |
| 108 // renderer. | 94 // renderer. |
| 109 void UpdateDeviceScaleFactor(float device_scale_factor); | 95 void UpdateDeviceScaleFactor(float device_scale_factor); |
| 110 | 96 |
| 111 // A request to enable hardware compositing. | 97 // A request to enable hardware compositing. |
| 112 void EnableCompositing(bool enable); | 98 void EnableCompositing(bool enable); |
| 113 | 99 |
| 114 // Called when a guest instance ID has been allocated by the browser process. | |
| 115 void OnInstanceIDAllocated(int guest_instance_id); | |
| 116 // Provided that a guest instance ID has been allocated, this method attaches | 100 // Provided that a guest instance ID has been allocated, this method attaches |
| 117 // this BrowserPlugin instance to that guest. |extra_params| are parameters | 101 // this BrowserPlugin instance to that guest. |extra_params| are parameters |
| 118 // passed in by the content embedder to the browser process. | 102 // passed in by the content embedder to the browser process. |
| 119 void Attach(int guest_instance_id, | 103 void Attach(int guest_instance_id, |
| 120 scoped_ptr<base::DictionaryValue> extra_params); | 104 scoped_ptr<base::DictionaryValue> extra_params); |
| 121 | 105 |
| 122 // Notify the plugin about a compositor commit so that frame ACKs could be | 106 // Notify the plugin about a compositor commit so that frame ACKs could be |
| 123 // sent, if needed. | 107 // sent, if needed. |
| 124 void DidCommitCompositorFrame(); | 108 void DidCommitCompositorFrame(); |
| 125 | 109 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // Gets the Min Height value used for auto size. | 200 // Gets the Min Height value used for auto size. |
| 217 int GetAdjustedMinHeight() const; | 201 int GetAdjustedMinHeight() const; |
| 218 // Gets the Min Width value used for auto size. | 202 // Gets the Min Width value used for auto size. |
| 219 int GetAdjustedMinWidth() const; | 203 int GetAdjustedMinWidth() const; |
| 220 | 204 |
| 221 // Virtual to allow for mocking in tests. | 205 // Virtual to allow for mocking in tests. |
| 222 virtual float GetDeviceScaleFactor() const; | 206 virtual float GetDeviceScaleFactor() const; |
| 223 | 207 |
| 224 void ShowSadGraphic(); | 208 void ShowSadGraphic(); |
| 225 | 209 |
| 226 // Parses the attributes of the browser plugin from the element's attributes | |
| 227 // and sets them appropriately. | |
| 228 void ParseAttributes(); | |
| 229 | |
| 230 // Triggers the event-listeners for |event_name|. Note that the function | 210 // Triggers the event-listeners for |event_name|. Note that the function |
| 231 // frees all the values in |props|. | 211 // frees all the values in |props|. |
| 232 void TriggerEvent(const std::string& event_name, | 212 void TriggerEvent(const std::string& event_name, |
| 233 std::map<std::string, base::Value*>* props); | 213 std::map<std::string, base::Value*>* props); |
| 234 | 214 |
| 235 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state. | 215 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state. |
| 236 void PopulateResizeGuestParameters( | 216 void PopulateResizeGuestParameters( |
| 237 BrowserPluginHostMsg_ResizeGuest_Params* params, | 217 BrowserPluginHostMsg_ResizeGuest_Params* params, |
| 238 const gfx::Rect& view_size, | 218 const gfx::Rect& view_size, |
| 239 bool needs_repaint); | 219 bool needs_repaint); |
| 240 | 220 |
| 241 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. | 221 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. |
| 242 void PopulateAutoSizeParameters( | 222 void PopulateAutoSizeParameters( |
| 243 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled); | 223 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled); |
| 244 | 224 |
| 245 // Populates both AutoSize and ResizeGuest parameters based on the current | 225 // Populates both AutoSize and ResizeGuest parameters based on the current |
| 246 // autosize state. | 226 // autosize state. |
| 247 void GetSizeParams( | 227 void GetSizeParams( |
| 248 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 228 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
| 249 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, | 229 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, |
| 250 bool needs_repaint); | 230 bool needs_repaint); |
| 251 | 231 |
| 252 // Informs the guest of an updated autosize state. | 232 // Informs the guest of an updated autosize state. |
| 253 void UpdateGuestAutoSizeState(bool auto_size_enabled); | 233 void UpdateGuestAutoSizeState(bool auto_size_enabled); |
| 254 | 234 |
| 255 | 235 |
| 256 // IPC message handlers. | 236 // IPC message handlers. |
| 257 // Please keep in alphabetical order. | 237 // Please keep in alphabetical order. |
| 258 void OnAdvanceFocus(int instance_id, bool reverse); | 238 void OnAdvanceFocus(int instance_id, bool reverse); |
| 259 void OnAttachACK(int instance_id, | 239 void OnAttachACK(int instance_id); |
| 260 const BrowserPluginMsg_Attach_ACK_Params& ack_params); | |
| 261 void OnBuffersSwapped(int instance_id, | 240 void OnBuffersSwapped(int instance_id, |
| 262 const FrameMsg_BuffersSwapped_Params& params); | 241 const FrameMsg_BuffersSwapped_Params& params); |
| 263 void OnCompositorFrameSwapped(const IPC::Message& message); | 242 void OnCompositorFrameSwapped(const IPC::Message& message); |
| 264 void OnCopyFromCompositingSurface(int instance_id, | 243 void OnCopyFromCompositingSurface(int instance_id, |
| 265 int request_id, | 244 int request_id, |
| 266 gfx::Rect source_rect, | 245 gfx::Rect source_rect, |
| 267 gfx::Size dest_size); | 246 gfx::Size dest_size); |
| 268 void OnGuestContentWindowReady(int instance_id, | 247 void OnGuestContentWindowReady(int instance_id, |
| 269 int content_window_routing_id); | 248 int content_window_routing_id); |
| 270 void OnGuestGone(int instance_id); | 249 void OnGuestGone(int instance_id); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 290 bool paint_ack_received_; | 269 bool paint_ack_received_; |
| 291 gfx::Rect plugin_rect_; | 270 gfx::Rect plugin_rect_; |
| 292 float last_device_scale_factor_; | 271 float last_device_scale_factor_; |
| 293 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 272 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 294 SkBitmap* sad_guest_; | 273 SkBitmap* sad_guest_; |
| 295 bool guest_crashed_; | 274 bool guest_crashed_; |
| 296 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; | 275 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; |
| 297 bool is_auto_size_state_dirty_; | 276 bool is_auto_size_state_dirty_; |
| 298 // Maximum size constraint for autosize. | 277 // Maximum size constraint for autosize. |
| 299 gfx::Size max_auto_size_; | 278 gfx::Size max_auto_size_; |
| 300 std::string storage_partition_id_; | |
| 301 bool persist_storage_; | |
| 302 bool valid_partition_id_; | |
| 303 int content_window_routing_id_; | 279 int content_window_routing_id_; |
| 304 bool plugin_focused_; | 280 bool plugin_focused_; |
| 305 // Tracks the visibility of the browser plugin regardless of the whole | 281 // Tracks the visibility of the browser plugin regardless of the whole |
| 306 // embedder RenderView's visibility. | 282 // embedder RenderView's visibility. |
| 307 bool visible_; | 283 bool visible_; |
| 308 | 284 |
| 309 const bool auto_navigate_; | 285 const bool auto_navigate_; |
| 310 std::string html_string_; | 286 std::string html_string_; |
| 311 | 287 |
| 312 WebCursor cursor_; | 288 WebCursor cursor_; |
| 313 | 289 |
| 314 gfx::Size last_view_size_; | 290 gfx::Size last_view_size_; |
| 315 bool before_first_navigation_; | |
| 316 bool mouse_locked_; | 291 bool mouse_locked_; |
| 317 | 292 |
| 318 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 293 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
| 319 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 294 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
| 320 // avoid accessing the RenderViewImpl. | 295 // avoid accessing the RenderViewImpl. |
| 321 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 296 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
| 322 | 297 |
| 323 // Used for HW compositing. | 298 // Used for HW compositing. |
| 324 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 299 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
| 325 | 300 |
| 326 // Used to identify the plugin to WebBindings. | 301 // Used to identify the plugin to WebBindings. |
| 327 scoped_ptr<struct _NPP> npp_; | 302 scoped_ptr<struct _NPP> npp_; |
| 328 | 303 |
| 329 // URL for the embedder frame. | 304 // URL for the embedder frame. |
| 330 const GURL embedder_frame_url_; | 305 const GURL embedder_frame_url_; |
| 331 | 306 |
| 332 std::vector<EditCommand> edit_commands_; | 307 std::vector<EditCommand> edit_commands_; |
| 333 | 308 |
| 334 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 309 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
| 335 // get called after BrowserPlugin has been destroyed. | 310 // get called after BrowserPlugin has been destroyed. |
| 336 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 311 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
| 337 | 312 |
| 338 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 313 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 339 }; | 314 }; |
| 340 | 315 |
| 341 } // namespace content | 316 } // namespace content |
| 342 | 317 |
| 343 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 318 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |