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" | |
14 #include "content/renderer/mouse_lock_dispatcher.h" | 13 #include "content/renderer/mouse_lock_dispatcher.h" |
15 #include "content/renderer/render_view_impl.h" | 14 #include "content/renderer/render_view_impl.h" |
16 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 15 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
17 #include "third_party/WebKit/public/web/WebDragStatus.h" | 16 #include "third_party/WebKit/public/web/WebDragStatus.h" |
18 #include "third_party/WebKit/public/web/WebNode.h" | 17 #include "third_party/WebKit/public/web/WebNode.h" |
19 #include "third_party/WebKit/public/web/WebWidget.h" | 18 #include "third_party/WebKit/public/web/WebWidget.h" |
20 | 19 |
21 struct BrowserPluginHostMsg_ResizeGuest_Params; | 20 struct BrowserPluginHostMsg_ResizeGuest_Params; |
22 struct BrowserPluginMsg_UpdateRect_Params; | |
23 struct FrameMsg_BuffersSwapped_Params; | 21 struct FrameMsg_BuffersSwapped_Params; |
24 | 22 |
25 namespace content { | 23 namespace content { |
26 | 24 |
27 class BrowserPluginDelegate; | 25 class BrowserPluginDelegate; |
28 class ChildFrameCompositingHelper; | 26 class ChildFrameCompositingHelper; |
29 class BrowserPluginManager; | 27 class BrowserPluginManager; |
30 class MockBrowserPlugin; | 28 class MockBrowserPlugin; |
31 | 29 |
32 class CONTENT_EXPORT BrowserPlugin : | 30 class CONTENT_EXPORT BrowserPlugin : |
(...skipping 10 matching lines...) Expand all Loading... |
43 BrowserPluginManager* browser_plugin_manager() const { | 41 BrowserPluginManager* browser_plugin_manager() const { |
44 return browser_plugin_manager_.get(); | 42 return browser_plugin_manager_.get(); |
45 } | 43 } |
46 | 44 |
47 bool OnMessageReceived(const IPC::Message& msg); | 45 bool OnMessageReceived(const IPC::Message& msg); |
48 | 46 |
49 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value | 47 // Update Browser Plugin's DOM Node attribute |attribute_name| with the value |
50 // |attribute_value|. | 48 // |attribute_value|. |
51 void UpdateDOMAttribute(const std::string& attribute_name, | 49 void UpdateDOMAttribute(const std::string& attribute_name, |
52 const std::string& attribute_value); | 50 const std::string& attribute_value); |
53 // Remove the DOM Node attribute with the name |attribute_name|. | |
54 void RemoveDOMAttribute(const std::string& attribute_name); | |
55 // Get Browser Plugin's DOM Node attribute |attribute_name|'s value. | |
56 std::string GetDOMAttributeValue(const std::string& attribute_name) const; | |
57 // Checks if the attribute |attribute_name| exists in the DOM. | |
58 bool HasDOMAttribute(const std::string& attribute_name) const; | |
59 | |
60 // Get the allowtransparency attribute value. | |
61 bool GetAllowTransparencyAttribute() const; | |
62 // Parse the allowtransparency attribute and adjust transparency of | |
63 // BrowserPlugin accordingly. | |
64 void ParseAllowTransparencyAttribute(); | |
65 | 51 |
66 // Returns whether the guest process has crashed. | 52 // Returns whether the guest process has crashed. |
67 bool guest_crashed() const { return guest_crashed_; } | 53 bool guest_crashed() const { return guest_crashed_; } |
68 | 54 |
69 // Informs the guest of an updated focus state. | 55 // Informs the guest of an updated focus state. |
70 void UpdateGuestFocusState(); | 56 void UpdateGuestFocusState(); |
| 57 |
71 // Indicates whether the guest should be focused. | 58 // Indicates whether the guest should be focused. |
72 bool ShouldGuestBeFocused() const; | 59 bool ShouldGuestBeFocused() const; |
73 | 60 |
74 // Embedder's device scale factor changed, we need to update the guest | 61 // Embedder's device scale factor changed, we need to update the guest |
75 // renderer. | 62 // renderer. |
76 void UpdateDeviceScaleFactor(); | 63 void UpdateDeviceScaleFactor(); |
77 | 64 |
78 // A request to enable hardware compositing. | 65 // A request to enable hardware compositing. |
79 void EnableCompositing(bool enable); | 66 void EnableCompositing(bool enable); |
80 | 67 |
81 // Provided that a guest instance ID has been allocated, this method attaches | 68 // Provided that a guest instance ID has been allocated, this method attaches |
82 // this BrowserPlugin instance to that guest. | 69 // this BrowserPlugin instance to that guest. |
83 void Attach(); | 70 void Attach(); |
84 | 71 |
85 // Notify the plugin about a compositor commit so that frame ACKs could be | 72 // Notify the plugin about a compositor commit so that frame ACKs could be |
86 // sent, if needed. | 73 // sent, if needed. |
87 void DidCommitCompositorFrame(); | 74 void DidCommitCompositorFrame(); |
88 | 75 |
89 // Returns whether a message should be forwarded to BrowserPlugin. | 76 // Returns whether a message should be forwarded to BrowserPlugin. |
90 static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); | 77 static bool ShouldForwardToBrowserPlugin(const IPC::Message& message); |
91 | 78 |
92 // blink::WebPlugin implementation. | 79 // blink::WebPlugin implementation. |
93 virtual blink::WebPluginContainer* container() const OVERRIDE; | 80 virtual blink::WebPluginContainer* container() const OVERRIDE; |
94 virtual bool initialize(blink::WebPluginContainer* container) OVERRIDE; | 81 virtual bool initialize(blink::WebPluginContainer* container) OVERRIDE; |
95 virtual void destroy() OVERRIDE; | 82 virtual void destroy() OVERRIDE; |
96 virtual NPObject* scriptableObject() OVERRIDE; | |
97 virtual struct _NPP* pluginNPP() OVERRIDE; | |
98 virtual bool supportsKeyboardFocus() const OVERRIDE; | 83 virtual bool supportsKeyboardFocus() const OVERRIDE; |
99 virtual bool supportsEditCommands() const OVERRIDE; | 84 virtual bool supportsEditCommands() const OVERRIDE; |
100 virtual bool supportsInputMethod() const OVERRIDE; | 85 virtual bool supportsInputMethod() const OVERRIDE; |
101 virtual bool canProcessDrag() const OVERRIDE; | 86 virtual bool canProcessDrag() const OVERRIDE; |
102 virtual void paint( | 87 virtual void paint( |
103 blink::WebCanvas* canvas, | 88 blink::WebCanvas* canvas, |
104 const blink::WebRect& rect) OVERRIDE; | 89 const blink::WebRect& rect) OVERRIDE; |
105 virtual void updateGeometry( | 90 virtual void updateGeometry( |
106 const blink::WebRect& frame_rect, | 91 const blink::WebRect& frame_rect, |
107 const blink::WebRect& clip_rect, | 92 const blink::WebRect& clip_rect, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 void OnAdvanceFocus(int instance_id, bool reverse); | 175 void OnAdvanceFocus(int instance_id, bool reverse); |
191 void OnAttachACK(int browser_plugin_instance_id); | 176 void OnAttachACK(int browser_plugin_instance_id); |
192 void OnBuffersSwapped(int instance_id, | 177 void OnBuffersSwapped(int instance_id, |
193 const FrameMsg_BuffersSwapped_Params& params); | 178 const FrameMsg_BuffersSwapped_Params& params); |
194 void OnCompositorFrameSwapped(const IPC::Message& message); | 179 void OnCompositorFrameSwapped(const IPC::Message& message); |
195 void OnCopyFromCompositingSurface(int instance_id, | 180 void OnCopyFromCompositingSurface(int instance_id, |
196 int request_id, | 181 int request_id, |
197 gfx::Rect source_rect, | 182 gfx::Rect source_rect, |
198 gfx::Size dest_size); | 183 gfx::Size dest_size); |
199 void OnGuestGone(int instance_id); | 184 void OnGuestGone(int instance_id); |
| 185 void OnSetContentsOpaque(int instance_id, bool opaque); |
200 void OnSetCursor(int instance_id, const WebCursor& cursor); | 186 void OnSetCursor(int instance_id, const WebCursor& cursor); |
201 void OnSetMouseLock(int instance_id, bool enable); | 187 void OnSetMouseLock(int instance_id, bool enable); |
202 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | 188 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
203 | 189 |
204 // This indicates whether this BrowserPlugin has been attached to a | 190 // This indicates whether this BrowserPlugin has been attached to a |
205 // WebContents. | 191 // WebContents. |
206 bool attached_; | 192 bool attached_; |
207 bool attach_pending_; | 193 bool attach_pending_; |
208 const base::WeakPtr<RenderViewImpl> render_view_; | 194 const base::WeakPtr<RenderViewImpl> render_view_; |
209 // We cache the |render_view_|'s routing ID because we need it on destruction. | 195 // We cache the |render_view_|'s routing ID because we need it on destruction. |
210 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 196 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
211 // then we will attempt to access a NULL pointer. | 197 // then we will attempt to access a NULL pointer. |
212 const int render_view_routing_id_; | 198 const int render_view_routing_id_; |
213 blink::WebPluginContainer* container_; | 199 blink::WebPluginContainer* container_; |
214 scoped_ptr<BrowserPluginBindings> bindings_; | |
215 gfx::Rect plugin_rect_; | 200 gfx::Rect plugin_rect_; |
216 float last_device_scale_factor_; | 201 float last_device_scale_factor_; |
217 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 202 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
218 SkBitmap* sad_guest_; | 203 SkBitmap* sad_guest_; |
219 bool guest_crashed_; | 204 bool guest_crashed_; |
220 int content_window_routing_id_; | |
221 bool plugin_focused_; | 205 bool plugin_focused_; |
222 // Tracks the visibility of the browser plugin regardless of the whole | 206 // Tracks the visibility of the browser plugin regardless of the whole |
223 // embedder RenderView's visibility. | 207 // embedder RenderView's visibility. |
224 bool visible_; | 208 bool visible_; |
225 | 209 |
226 WebCursor cursor_; | 210 WebCursor cursor_; |
227 | 211 |
228 gfx::Size last_view_size_; | 212 gfx::Size last_view_size_; |
229 bool mouse_locked_; | 213 bool mouse_locked_; |
230 | 214 |
231 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 215 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
232 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 216 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
233 // avoid accessing the RenderViewImpl. | 217 // avoid accessing the RenderViewImpl. |
234 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 218 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
235 | 219 |
236 // Used for HW compositing. | 220 // Used for HW compositing. |
237 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 221 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
238 | 222 |
239 // Used to identify the plugin to WebBindings. | |
240 scoped_ptr<struct _NPP> npp_; | |
241 | |
242 // URL for the embedder frame. | 223 // URL for the embedder frame. |
243 int browser_plugin_instance_id_; | 224 int browser_plugin_instance_id_; |
244 | 225 |
| 226 // Indicates whether the guest content is opaque. |
| 227 bool contents_opaque_; |
| 228 |
245 std::vector<EditCommand> edit_commands_; | 229 std::vector<EditCommand> edit_commands_; |
246 | 230 |
247 scoped_ptr<BrowserPluginDelegate> delegate_; | 231 scoped_ptr<BrowserPluginDelegate> delegate_; |
248 | 232 |
249 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 233 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
250 // get called after BrowserPlugin has been destroyed. | 234 // get called after BrowserPlugin has been destroyed. |
251 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 235 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
252 | 236 |
253 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 237 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
254 }; | 238 }; |
255 | 239 |
256 } // namespace content | 240 } // namespace content |
257 | 241 |
258 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 242 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |