| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // IPC message handlers. | 173 // IPC message handlers. |
| 189 // Please keep in alphabetical order. | 174 // Please keep in alphabetical order. |
| 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 OnCompositorFrameSwapped(const IPC::Message& message); | 177 void OnCompositorFrameSwapped(const IPC::Message& message); |
| 193 void OnCopyFromCompositingSurface(int instance_id, | 178 void OnCopyFromCompositingSurface(int instance_id, |
| 194 int request_id, | 179 int request_id, |
| 195 gfx::Rect source_rect, | 180 gfx::Rect source_rect, |
| 196 gfx::Size dest_size); | 181 gfx::Size dest_size); |
| 197 void OnGuestGone(int instance_id); | 182 void OnGuestGone(int instance_id); |
| 183 void OnSetContentsOpaque(int instance_id, bool opaque); |
| 198 void OnSetCursor(int instance_id, const WebCursor& cursor); | 184 void OnSetCursor(int instance_id, const WebCursor& cursor); |
| 199 void OnSetMouseLock(int instance_id, bool enable); | 185 void OnSetMouseLock(int instance_id, bool enable); |
| 200 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | 186 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
| 201 | 187 |
| 202 // This indicates whether this BrowserPlugin has been attached to a | 188 // This indicates whether this BrowserPlugin has been attached to a |
| 203 // WebContents. | 189 // WebContents. |
| 204 bool attached_; | 190 bool attached_; |
| 205 bool attach_pending_; | 191 bool attach_pending_; |
| 206 const base::WeakPtr<RenderViewImpl> render_view_; | 192 const base::WeakPtr<RenderViewImpl> render_view_; |
| 207 // We cache the |render_view_|'s routing ID because we need it on destruction. | 193 // We cache the |render_view_|'s routing ID because we need it on destruction. |
| 208 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 194 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
| 209 // then we will attempt to access a NULL pointer. | 195 // then we will attempt to access a NULL pointer. |
| 210 const int render_view_routing_id_; | 196 const int render_view_routing_id_; |
| 211 blink::WebPluginContainer* container_; | 197 blink::WebPluginContainer* container_; |
| 212 scoped_ptr<BrowserPluginBindings> bindings_; | |
| 213 gfx::Rect plugin_rect_; | 198 gfx::Rect plugin_rect_; |
| 214 float last_device_scale_factor_; | 199 float last_device_scale_factor_; |
| 215 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 200 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 216 SkBitmap* sad_guest_; | 201 SkBitmap* sad_guest_; |
| 217 bool guest_crashed_; | 202 bool guest_crashed_; |
| 218 int content_window_routing_id_; | |
| 219 bool plugin_focused_; | 203 bool plugin_focused_; |
| 220 // Tracks the visibility of the browser plugin regardless of the whole | 204 // Tracks the visibility of the browser plugin regardless of the whole |
| 221 // embedder RenderView's visibility. | 205 // embedder RenderView's visibility. |
| 222 bool visible_; | 206 bool visible_; |
| 223 | 207 |
| 224 WebCursor cursor_; | 208 WebCursor cursor_; |
| 225 | 209 |
| 226 gfx::Size last_view_size_; | 210 gfx::Size last_view_size_; |
| 227 bool mouse_locked_; | 211 bool mouse_locked_; |
| 228 | 212 |
| 229 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 213 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
| 230 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 214 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
| 231 // avoid accessing the RenderViewImpl. | 215 // avoid accessing the RenderViewImpl. |
| 232 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 216 const scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
| 233 | 217 |
| 234 // Used for HW compositing. | 218 // Used for HW compositing. |
| 235 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; | 219 scoped_refptr<ChildFrameCompositingHelper> compositing_helper_; |
| 236 | 220 |
| 237 // Used to identify the plugin to WebBindings. | |
| 238 scoped_ptr<struct _NPP> npp_; | |
| 239 | |
| 240 // URL for the embedder frame. | 221 // URL for the embedder frame. |
| 241 int browser_plugin_instance_id_; | 222 int browser_plugin_instance_id_; |
| 242 | 223 |
| 224 // Indicates whether the guest content is opaque. |
| 225 bool contents_opaque_; |
| 226 |
| 243 std::vector<EditCommand> edit_commands_; | 227 std::vector<EditCommand> edit_commands_; |
| 244 | 228 |
| 245 scoped_ptr<BrowserPluginDelegate> delegate_; | 229 scoped_ptr<BrowserPluginDelegate> delegate_; |
| 246 | 230 |
| 247 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 231 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
| 248 // get called after BrowserPlugin has been destroyed. | 232 // get called after BrowserPlugin has been destroyed. |
| 249 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 233 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
| 250 | 234 |
| 251 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 235 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 252 }; | 236 }; |
| 253 | 237 |
| 254 } // namespace content | 238 } // namespace content |
| 255 | 239 |
| 256 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 240 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |