| 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/browser_plugin/browser_plugin_bindings.h" | 13 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
| 14 #include "content/renderer/mouse_lock_dispatcher.h" | 14 #include "content/renderer/mouse_lock_dispatcher.h" |
| 15 #include "content/renderer/render_view_impl.h" | 15 #include "content/renderer/render_view_impl.h" |
| 16 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 16 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 17 #include "third_party/WebKit/public/web/WebDragStatus.h" | 17 #include "third_party/WebKit/public/web/WebDragStatus.h" |
| 18 #include "third_party/WebKit/public/web/WebWidget.h" | 18 #include "third_party/WebKit/public/web/WebWidget.h" |
| 19 | 19 |
| 20 struct BrowserPluginHostMsg_AutoSize_Params; |
| 20 struct BrowserPluginHostMsg_ResizeGuest_Params; | 21 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 21 struct BrowserPluginMsg_UpdateRect_Params; | 22 struct BrowserPluginMsg_UpdateRect_Params; |
| 22 struct FrameMsg_BuffersSwapped_Params; | 23 struct FrameMsg_BuffersSwapped_Params; |
| 23 | 24 |
| 24 namespace content { | 25 namespace content { |
| 25 | 26 |
| 26 class ChildFrameCompositingHelper; | 27 class ChildFrameCompositingHelper; |
| 27 class BrowserPluginManager; | 28 class BrowserPluginManager; |
| 28 class MockBrowserPlugin; | 29 class MockBrowserPlugin; |
| 29 | 30 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 50 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. | 51 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. |
| 51 std::string GetDOMAttributeValue(const std::string& attribute_name) const; | 52 std::string GetDOMAttributeValue(const std::string& attribute_name) const; |
| 52 // Checks if the attribute |attribute_name| exists in the DOM. | 53 // Checks if the attribute |attribute_name| exists in the DOM. |
| 53 bool HasDOMAttribute(const std::string& attribute_name) const; | 54 bool HasDOMAttribute(const std::string& attribute_name) const; |
| 54 | 55 |
| 55 // Get the allowtransparency attribute value. | 56 // Get the allowtransparency attribute value. |
| 56 bool GetAllowTransparencyAttribute() const; | 57 bool GetAllowTransparencyAttribute() const; |
| 57 // Parse the allowtransparency attribute and adjust transparency of | 58 // Parse the allowtransparency attribute and adjust transparency of |
| 58 // BrowserPlugin accordingly. | 59 // BrowserPlugin accordingly. |
| 59 void ParseAllowTransparencyAttribute(); | 60 void ParseAllowTransparencyAttribute(); |
| 61 // Get the autosize attribute value. |
| 62 bool GetAutoSizeAttribute() const; |
| 63 // Parses the autosize attribute value. |
| 64 void ParseAutoSizeAttribute(); |
| 65 // Get the maxheight attribute value. |
| 66 int GetMaxHeightAttribute() const; |
| 67 // Get the maxwidth attribute value. |
| 68 int GetMaxWidthAttribute() const; |
| 69 // Get the minheight attribute value. |
| 70 int GetMinHeightAttribute() const; |
| 71 // Get the minwidth attribute value. |
| 72 int GetMinWidthAttribute() const; |
| 73 // Parse the minwidth, maxwidth, minheight, and maxheight attribute values. |
| 74 void ParseSizeContraintsChanged(); |
| 75 |
| 76 bool InAutoSizeBounds(const gfx::Size& size) const; |
| 60 | 77 |
| 61 // Get the guest's DOMWindow proxy. | 78 // Get the guest's DOMWindow proxy. |
| 62 NPObject* GetContentWindow() const; | 79 NPObject* GetContentWindow() const; |
| 63 | 80 |
| 64 // Returns whether the guest process has crashed. | 81 // Returns whether the guest process has crashed. |
| 65 bool guest_crashed() const { return guest_crashed_; } | 82 bool guest_crashed() const { return guest_crashed_; } |
| 66 // Returns whether this BrowserPlugin has allocated an instance ID. | 83 // Returns whether this BrowserPlugin has allocated an instance ID. |
| 67 bool HasGuestInstanceID() const; | 84 bool HasGuestInstanceID() const; |
| 68 | 85 |
| 69 // Informs the guest of an updated focus state. | 86 // Informs the guest of an updated focus state. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 BrowserPlugin(RenderViewImpl* render_view, | 185 BrowserPlugin(RenderViewImpl* render_view, |
| 169 blink::WebFrame* frame, | 186 blink::WebFrame* frame, |
| 170 bool auto_navigate); | 187 bool auto_navigate); |
| 171 | 188 |
| 172 virtual ~BrowserPlugin(); | 189 virtual ~BrowserPlugin(); |
| 173 | 190 |
| 174 int width() const { return plugin_rect_.width(); } | 191 int width() const { return plugin_rect_.width(); } |
| 175 int height() const { return plugin_rect_.height(); } | 192 int height() const { return plugin_rect_.height(); } |
| 176 gfx::Size plugin_size() const { return plugin_rect_.size(); } | 193 gfx::Size plugin_size() const { return plugin_rect_.size(); } |
| 177 gfx::Rect plugin_rect() const { return plugin_rect_; } | 194 gfx::Rect plugin_rect() const { return plugin_rect_; } |
| 195 // Gets the Max Height value used for auto size. |
| 196 int GetAdjustedMaxHeight() const; |
| 197 // Gets the Max Width value used for auto size. |
| 198 int GetAdjustedMaxWidth() const; |
| 199 // Gets the Min Height value used for auto size. |
| 200 int GetAdjustedMinHeight() const; |
| 201 // Gets the Min Width value used for auto size. |
| 202 int GetAdjustedMinWidth() const; |
| 178 | 203 |
| 179 // Virtual to allow for mocking in tests. | 204 // Virtual to allow for mocking in tests. |
| 180 virtual float GetDeviceScaleFactor() const; | 205 virtual float GetDeviceScaleFactor() const; |
| 181 | 206 |
| 182 void ShowSadGraphic(); | 207 void ShowSadGraphic(); |
| 183 | 208 |
| 209 // Triggers the event-listeners for |event_name|. Note that the function |
| 210 // frees all the values in |props|. |
| 211 void TriggerEvent(const std::string& event_name, |
| 212 std::map<std::string, base::Value*>* props); |
| 213 |
| 184 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state. | 214 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state. |
| 185 void PopulateResizeGuestParameters( | 215 void PopulateResizeGuestParameters( |
| 186 BrowserPluginHostMsg_ResizeGuest_Params* params, | 216 BrowserPluginHostMsg_ResizeGuest_Params* params, |
| 187 const gfx::Size& view_size, | 217 const gfx::Size& view_size, |
| 188 bool needs_repaint); | 218 bool needs_repaint); |
| 189 | 219 |
| 190 // Populates ResizeGuest parameters based on the current | 220 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. |
| 221 void PopulateAutoSizeParameters( |
| 222 BrowserPluginHostMsg_AutoSize_Params* params, bool auto_size_enabled); |
| 223 |
| 224 // Populates both AutoSize and ResizeGuest parameters based on the current |
| 191 // autosize state. | 225 // autosize state. |
| 192 void GetSizeParams( | 226 void GetSizeParams( |
| 227 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
| 193 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, | 228 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params, |
| 194 bool needs_repaint); | 229 bool needs_repaint); |
| 195 | 230 |
| 231 // Informs the guest of an updated autosize state. |
| 232 void UpdateGuestAutoSizeState(bool auto_size_enabled); |
| 233 |
| 234 |
| 196 // IPC message handlers. | 235 // IPC message handlers. |
| 197 // Please keep in alphabetical order. | 236 // Please keep in alphabetical order. |
| 198 void OnAdvanceFocus(int instance_id, bool reverse); | 237 void OnAdvanceFocus(int instance_id, bool reverse); |
| 199 void OnAttachACK(int instance_id); | 238 void OnAttachACK(int instance_id); |
| 200 void OnBuffersSwapped(int instance_id, | 239 void OnBuffersSwapped(int instance_id, |
| 201 const FrameMsg_BuffersSwapped_Params& params); | 240 const FrameMsg_BuffersSwapped_Params& params); |
| 202 void OnCompositorFrameSwapped(const IPC::Message& message); | 241 void OnCompositorFrameSwapped(const IPC::Message& message); |
| 203 void OnCopyFromCompositingSurface(int instance_id, | 242 void OnCopyFromCompositingSurface(int instance_id, |
| 204 int request_id, | 243 int request_id, |
| 205 gfx::Rect source_rect, | 244 gfx::Rect source_rect, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 225 // then we will attempt to access a NULL pointer. | 264 // then we will attempt to access a NULL pointer. |
| 226 const int render_view_routing_id_; | 265 const int render_view_routing_id_; |
| 227 blink::WebPluginContainer* container_; | 266 blink::WebPluginContainer* container_; |
| 228 scoped_ptr<BrowserPluginBindings> bindings_; | 267 scoped_ptr<BrowserPluginBindings> bindings_; |
| 229 bool paint_ack_received_; | 268 bool paint_ack_received_; |
| 230 gfx::Rect plugin_rect_; | 269 gfx::Rect plugin_rect_; |
| 231 float last_device_scale_factor_; | 270 float last_device_scale_factor_; |
| 232 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 271 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 233 SkBitmap* sad_guest_; | 272 SkBitmap* sad_guest_; |
| 234 bool guest_crashed_; | 273 bool guest_crashed_; |
| 274 bool is_auto_size_state_dirty_; |
| 275 // Maximum size constraint for autosize. |
| 276 gfx::Size max_auto_size_; |
| 235 int content_window_routing_id_; | 277 int content_window_routing_id_; |
| 236 bool plugin_focused_; | 278 bool plugin_focused_; |
| 237 // Tracks the visibility of the browser plugin regardless of the whole | 279 // Tracks the visibility of the browser plugin regardless of the whole |
| 238 // embedder RenderView's visibility. | 280 // embedder RenderView's visibility. |
| 239 bool visible_; | 281 bool visible_; |
| 240 | 282 |
| 241 const bool auto_navigate_; | 283 const bool auto_navigate_; |
| 242 std::string html_string_; | 284 std::string html_string_; |
| 243 | 285 |
| 244 WebCursor cursor_; | 286 WebCursor cursor_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 262 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 304 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
| 263 // get called after BrowserPlugin has been destroyed. | 305 // get called after BrowserPlugin has been destroyed. |
| 264 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 306 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
| 265 | 307 |
| 266 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 308 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 267 }; | 309 }; |
| 268 | 310 |
| 269 } // namespace content | 311 } // namespace content |
| 270 | 312 |
| 271 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 313 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |