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