| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // A BrowserPluginGuest is the browser side of a browser <--> embedder | 5 // A BrowserPluginGuest is the browser side of a browser <--> embedder |
| 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder | 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder |
| 7 // renderer side of browser <--> embedder renderer communication. | 7 // renderer side of browser <--> embedder renderer communication. |
| 8 // | 8 // |
| 9 // BrowserPluginGuest lives on the UI thread of the browser process. Any | 9 // BrowserPluginGuest lives on the UI thread of the browser process. Any |
| 10 // messages about the guest render process that the embedder might be interested | 10 // messages about the guest render process that the embedder might be interested |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "content/public/browser/web_contents_observer.h" | 31 #include "content/public/browser/web_contents_observer.h" |
| 32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 33 #include "third_party/WebKit/public/web/WebDragOperation.h" | 33 #include "third_party/WebKit/public/web/WebDragOperation.h" |
| 34 #include "third_party/WebKit/public/web/WebDragStatus.h" | 34 #include "third_party/WebKit/public/web/WebDragStatus.h" |
| 35 #include "third_party/WebKit/public/web/WebInputEvent.h" | 35 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 36 #include "ui/base/ime/text_input_mode.h" | 36 #include "ui/base/ime/text_input_mode.h" |
| 37 #include "ui/base/ime/text_input_type.h" | 37 #include "ui/base/ime/text_input_type.h" |
| 38 #include "ui/gfx/rect.h" | 38 #include "ui/gfx/rect.h" |
| 39 | 39 |
| 40 class SkBitmap; | 40 class SkBitmap; |
| 41 struct BrowserPluginHostMsg_AutoSize_Params; | |
| 42 struct BrowserPluginHostMsg_Attach_Params; | 41 struct BrowserPluginHostMsg_Attach_Params; |
| 43 struct BrowserPluginHostMsg_ResizeGuest_Params; | 42 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 44 struct FrameHostMsg_CompositorFrameSwappedACK_Params; | 43 struct FrameHostMsg_CompositorFrameSwappedACK_Params; |
| 45 struct FrameHostMsg_ReclaimCompositorResources_Params; | 44 struct FrameHostMsg_ReclaimCompositorResources_Params; |
| 46 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
| 47 struct ViewHostMsg_ShowPopup_Params; | 46 struct ViewHostMsg_ShowPopup_Params; |
| 48 #endif | 47 #endif |
| 49 struct ViewHostMsg_TextInputState_Params; | 48 struct ViewHostMsg_TextInputState_Params; |
| 50 struct ViewHostMsg_UpdateRect_Params; | 49 struct ViewHostMsg_UpdateRect_Params; |
| 51 | 50 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 80 public: | 79 public: |
| 81 virtual ~BrowserPluginGuest(); | 80 virtual ~BrowserPluginGuest(); |
| 82 | 81 |
| 83 // The WebContents passed into the factory method here has not been | 82 // The WebContents passed into the factory method here has not been |
| 84 // initialized yet and so it does not yet hold a SiteInstance. | 83 // initialized yet and so it does not yet hold a SiteInstance. |
| 85 // BrowserPluginGuest must be constructed and installed into a WebContents | 84 // BrowserPluginGuest must be constructed and installed into a WebContents |
| 86 // prior to its initialization because WebContents needs to determine what | 85 // prior to its initialization because WebContents needs to determine what |
| 87 // type of WebContentsView to construct on initialization. The content | 86 // type of WebContentsView to construct on initialization. The content |
| 88 // embedder needs to be aware of |guest_site_instance| on the guest's | 87 // embedder needs to be aware of |guest_site_instance| on the guest's |
| 89 // construction and so we pass it in here. | 88 // construction and so we pass it in here. |
| 90 static BrowserPluginGuest* Create( | 89 static BrowserPluginGuest* Create(WebContentsImpl* web_contents, |
| 91 int instance_id, | 90 BrowserPluginGuestDelegate* delegate); |
| 92 WebContentsImpl* web_contents, | |
| 93 BrowserPluginGuestDelegate* delegate); | |
| 94 | 91 |
| 95 // Returns whether the given WebContents is a BrowserPlugin guest. | 92 // Returns whether the given WebContents is a BrowserPlugin guest. |
| 96 static bool IsGuest(WebContentsImpl* web_contents); | 93 static bool IsGuest(WebContentsImpl* web_contents); |
| 97 | 94 |
| 98 // Returns whether the given RenderviewHost is a BrowserPlugin guest. | 95 // Returns whether the given RenderviewHost is a BrowserPlugin guest. |
| 99 static bool IsGuest(RenderViewHostImpl* render_view_host); | 96 static bool IsGuest(RenderViewHostImpl* render_view_host); |
| 100 | 97 |
| 101 // Returns a WeakPtr to this BrowserPluginGuest. | 98 // Returns a WeakPtr to this BrowserPluginGuest. |
| 102 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); | 99 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); |
| 103 | 100 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 115 // this BrowserPluginGuest, and its new unattached windows. | 112 // this BrowserPluginGuest, and its new unattached windows. |
| 116 void Destroy(); | 113 void Destroy(); |
| 117 | 114 |
| 118 // Creates a new guest WebContentsImpl with the provided |params| with |this| | 115 // Creates a new guest WebContentsImpl with the provided |params| with |this| |
| 119 // as the |opener|. | 116 // as the |opener|. |
| 120 WebContentsImpl* CreateNewGuestWindow( | 117 WebContentsImpl* CreateNewGuestWindow( |
| 121 const WebContents::CreateParams& params); | 118 const WebContents::CreateParams& params); |
| 122 | 119 |
| 123 // Returns the identifier that uniquely identifies a browser plugin guest | 120 // Returns the identifier that uniquely identifies a browser plugin guest |
| 124 // within an embedder. | 121 // within an embedder. |
| 125 int instance_id() const { return instance_id_; } | 122 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } |
| 126 | 123 |
| 127 bool OnMessageReceivedFromEmbedder(const IPC::Message& message); | 124 bool OnMessageReceivedFromEmbedder(const IPC::Message& message); |
| 128 | 125 |
| 129 WebContentsImpl* embedder_web_contents() const { | 126 WebContentsImpl* embedder_web_contents() const { |
| 130 return embedder_web_contents_; | 127 return embedder_web_contents_; |
| 131 } | 128 } |
| 132 | 129 |
| 133 // Returns the embedder's RenderWidgetHostView if it is available. | 130 // Returns the embedder's RenderWidgetHostView if it is available. |
| 134 // Returns NULL otherwise. | 131 // Returns NULL otherwise. |
| 135 RenderWidgetHostView* GetEmbedderRenderWidgetHostView(); | 132 RenderWidgetHostView* GetEmbedderRenderWidgetHostView(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 165 // Helper to send messages to embedder. This methods fills the message with | 162 // Helper to send messages to embedder. This methods fills the message with |
| 166 // the correct routing id. | 163 // the correct routing id. |
| 167 void SendMessageToEmbedder(IPC::Message* msg); | 164 void SendMessageToEmbedder(IPC::Message* msg); |
| 168 | 165 |
| 169 // Returns whether the guest is attached to an embedder. | 166 // Returns whether the guest is attached to an embedder. |
| 170 bool attached() const { return embedder_web_contents_ != NULL; } | 167 bool attached() const { return embedder_web_contents_ != NULL; } |
| 171 | 168 |
| 172 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| | 169 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| |
| 173 // and initializes the guest with the provided |params|. Attaching a guest | 170 // and initializes the guest with the provided |params|. Attaching a guest |
| 174 // to an embedder implies that this guest's lifetime is no longer managed | 171 // to an embedder implies that this guest's lifetime is no longer managed |
| 175 // by its opener, and it can begin loading resources. |extra_params| are | 172 // by its opener, and it can begin loading resources. |
| 176 // parameters passed into BrowserPlugin from JavaScript to be forwarded to | 173 void Attach(int browser_plugin_instance_id, |
| 177 // the content embedder. | 174 WebContentsImpl* embedder_web_contents, |
| 178 void Attach(WebContentsImpl* embedder_web_contents, | 175 const BrowserPluginHostMsg_Attach_Params& params); |
| 179 const BrowserPluginHostMsg_Attach_Params& params, | |
| 180 const base::DictionaryValue& extra_params); | |
| 181 | 176 |
| 182 // Returns whether BrowserPluginGuest is interested in receiving the given | 177 // Returns whether BrowserPluginGuest is interested in receiving the given |
| 183 // |message|. | 178 // |message|. |
| 184 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 179 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
| 185 gfx::Rect ToGuestRect(const gfx::Rect& rect); | 180 gfx::Rect ToGuestRect(const gfx::Rect& rect); |
| 186 | 181 |
| 187 void DragSourceEndedAt(int client_x, int client_y, int screen_x, | 182 void DragSourceEndedAt(int client_x, int client_y, int screen_x, |
| 188 int screen_y, blink::WebDragOperation operation); | 183 int screen_y, blink::WebDragOperation operation); |
| 189 | 184 |
| 190 // Called when the drag started by this guest ends at an OS-level. | 185 // Called when the drag started by this guest ends at an OS-level. |
| 191 void EndSystemDrag(); | 186 void EndSystemDrag(); |
| 192 | 187 |
| 193 void RespondToPermissionRequest(int request_id, | 188 void RespondToPermissionRequest(int request_id, |
| 194 bool should_allow, | 189 bool should_allow, |
| 195 const std::string& user_input); | 190 const std::string& user_input); |
| 196 | 191 |
| 197 void PointerLockPermissionResponse(bool allow); | 192 void PointerLockPermissionResponse(bool allow); |
| 198 | 193 |
| 199 private: | 194 private: |
| 200 class EmbedderWebContentsObserver; | 195 class EmbedderWebContentsObserver; |
| 201 | 196 |
| 202 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 197 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and |
| 203 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 198 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. |
| 204 BrowserPluginGuest(int instance_id, | 199 BrowserPluginGuest(bool has_render_view, |
| 205 bool has_render_view, | |
| 206 WebContentsImpl* web_contents, | 200 WebContentsImpl* web_contents, |
| 207 BrowserPluginGuestDelegate* delegate); | 201 BrowserPluginGuestDelegate* delegate); |
| 208 | 202 |
| 209 void WillDestroy(); | 203 void WillDestroy(); |
| 210 | 204 |
| 211 void Initialize(const BrowserPluginHostMsg_Attach_Params& params, | 205 void Initialize(int browser_plugin_instance_id, |
| 212 WebContentsImpl* embedder_web_contents, | 206 const BrowserPluginHostMsg_Attach_Params& params, |
| 213 const base::DictionaryValue& extra_params); | 207 WebContentsImpl* embedder_web_contents); |
| 214 | 208 |
| 215 bool InAutoSizeBounds(const gfx::Size& size) const; | 209 bool InAutoSizeBounds(const gfx::Size& size) const; |
| 216 | 210 |
| 217 // Message handlers for messages from embedder. | 211 // Message handlers for messages from embedder. |
| 218 | 212 |
| 219 void OnCompositorFrameSwappedACK( | 213 void OnCompositorFrameSwappedACK( |
| 220 int instance_id, | 214 int instance_id, |
| 221 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 215 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
| 222 void OnCopyFromCompositingSurfaceAck(int instance_id, | 216 void OnCopyFromCompositingSurfaceAck(int instance_id, |
| 223 int request_id, | 217 int request_id, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 bool is_top_level, | 315 bool is_top_level, |
| 322 const std::string& name); | 316 const std::string& name); |
| 323 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 317 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
| 324 | 318 |
| 325 // Forwards all messages from the |pending_messages_| queue to the embedder. | 319 // Forwards all messages from the |pending_messages_| queue to the embedder. |
| 326 void SendQueuedMessages(); | 320 void SendQueuedMessages(); |
| 327 | 321 |
| 328 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 322 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
| 329 WebContentsImpl* embedder_web_contents_; | 323 WebContentsImpl* embedder_web_contents_; |
| 330 | 324 |
| 331 // An identifier that uniquely identifies a browser plugin guest within an | 325 // An identifier that uniquely identifies a browser plugin within an embedder. |
| 332 // embedder. | 326 int browser_plugin_instance_id_; |
| 333 const int instance_id_; | |
| 334 float guest_device_scale_factor_; | 327 float guest_device_scale_factor_; |
| 335 gfx::Rect guest_window_rect_; | 328 gfx::Rect guest_window_rect_; |
| 336 gfx::Rect guest_screen_rect_; | 329 gfx::Rect guest_screen_rect_; |
| 337 bool focused_; | 330 bool focused_; |
| 338 bool mouse_locked_; | 331 bool mouse_locked_; |
| 339 bool pending_lock_request_; | 332 bool pending_lock_request_; |
| 340 bool guest_visible_; | 333 bool guest_visible_; |
| 341 bool guest_opaque_; | 334 bool guest_opaque_; |
| 342 bool embedder_visible_; | 335 bool embedder_visible_; |
| 343 | 336 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 369 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
| 377 // permission. | 370 // permission. |
| 378 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 371 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
| 379 | 372 |
| 380 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 373 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 381 }; | 374 }; |
| 382 | 375 |
| 383 } // namespace content | 376 } // namespace content |
| 384 | 377 |
| 385 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 378 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |