| 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 represents the browser side of browser <--> renderer | 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer |
| 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of | 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of |
| 7 // browser <--> guest renderer communication. The 'guest' renderer is a | 7 // browser <--> guest renderer communication. The 'guest' renderer is a |
| 8 // <browser> tag. | 8 // <browser> tag. |
| 9 // | 9 // |
| 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a | 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 #include <map> | 32 #include <map> |
| 33 | 33 |
| 34 #include "base/compiler_specific.h" | 34 #include "base/compiler_specific.h" |
| 35 #include "base/id_map.h" | 35 #include "base/id_map.h" |
| 36 #include "base/time.h" | 36 #include "base/time.h" |
| 37 #include "content/public/browser/notification_observer.h" | 37 #include "content/public/browser/notification_observer.h" |
| 38 #include "content/public/browser/notification_registrar.h" | 38 #include "content/public/browser/notification_registrar.h" |
| 39 #include "content/public/browser/web_contents_delegate.h" | 39 #include "content/public/browser/web_contents_delegate.h" |
| 40 #include "content/public/browser/web_contents_observer.h" | 40 #include "content/public/browser/web_contents_observer.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | |
| 43 #include "ui/gfx/rect.h" | 43 #include "ui/gfx/rect.h" |
| 44 #include "ui/surface/transport_dib.h" | 44 #include "ui/surface/transport_dib.h" |
| 45 | 45 |
| 46 struct BrowserPluginHostMsg_AutoSize_Params; | 46 struct BrowserPluginHostMsg_AutoSize_Params; |
| 47 struct BrowserPluginHostMsg_CreateGuest_Params; | 47 struct BrowserPluginHostMsg_CreateGuest_Params; |
| 48 struct BrowserPluginHostMsg_ResizeGuest_Params; | 48 struct BrowserPluginHostMsg_ResizeGuest_Params; |
| 49 struct ViewHostMsg_UpdateRect_Params; | 49 struct ViewHostMsg_UpdateRect_Params; |
| 50 class WebCursor; | 50 class WebCursor; |
| 51 struct WebDropData; | 51 struct WebDropData; |
| 52 | 52 |
| 53 namespace WebKit { | 53 namespace WebKit { |
| 54 class WebInputEvent; | 54 class WebInputEvent; |
| 55 } | 55 } |
| 56 | 56 |
| 57 namespace content { | 57 namespace content { |
| 58 | 58 |
| 59 class BrowserPluginHostFactory; | 59 class BrowserPluginHostFactory; |
| 60 class BrowserPluginEmbedder; | 60 class BrowserPluginEmbedder; |
| 61 class RenderProcessHost; | 61 class RenderProcessHost; |
| 62 struct MediaStreamRequest; |
| 62 | 63 |
| 63 // A browser plugin guest provides functionality for WebContents to operate in | 64 // A browser plugin guest provides functionality for WebContents to operate in |
| 64 // the guest role and implements guest specific overrides for ViewHostMsg_* | 65 // the guest role and implements guest specific overrides for ViewHostMsg_* |
| 65 // messages. | 66 // messages. |
| 66 // | 67 // |
| 67 // BrowserPluginEmbedder is responsible for creating and destroying a guest. | 68 // BrowserPluginEmbedder is responsible for creating and destroying a guest. |
| 68 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, | 69 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, |
| 69 public WebContentsDelegate, | 70 public WebContentsDelegate, |
| 70 public WebContentsObserver { | 71 public WebContentsObserver { |
| 71 public: | 72 public: |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 | 132 |
| 132 // WebContentsDelegate implementation. | 133 // WebContentsDelegate implementation. |
| 133 virtual bool CanDownload(RenderViewHost* render_view_host, | 134 virtual bool CanDownload(RenderViewHost* render_view_host, |
| 134 int request_id, | 135 int request_id, |
| 135 const std::string& request_method) OVERRIDE; | 136 const std::string& request_method) OVERRIDE; |
| 136 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 137 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
| 137 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | 138 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; |
| 138 virtual void RunFileChooser(WebContents* web_contents, | 139 virtual void RunFileChooser(WebContents* web_contents, |
| 139 const FileChooserParams& params) OVERRIDE; | 140 const FileChooserParams& params) OVERRIDE; |
| 140 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | 141 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
| 142 virtual void RequestMediaAccessPermission( |
| 143 WebContents* web_contents, |
| 144 const content::MediaStreamRequest* request, |
| 145 const content::MediaResponseCallback& callback) OVERRIDE; |
| 141 | 146 |
| 142 void UpdateRect(RenderViewHost* render_view_host, | 147 void UpdateRect(RenderViewHost* render_view_host, |
| 143 const ViewHostMsg_UpdateRect_Params& params); | 148 const ViewHostMsg_UpdateRect_Params& params); |
| 144 void UpdateRectACK( | 149 void UpdateRectACK( |
| 145 int message_id, | 150 int message_id, |
| 146 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, | 151 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, |
| 147 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); | 152 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); |
| 148 // Overrides default ShowWidget message so we show them on the correct | 153 // Overrides default ShowWidget message so we show them on the correct |
| 149 // coordinates. | 154 // coordinates. |
| 150 void ShowWidget(RenderViewHost* render_view_host, | 155 void ShowWidget(RenderViewHost* render_view_host, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // Exposes the protected web_contents() from WebContentsObserver. | 205 // Exposes the protected web_contents() from WebContentsObserver. |
| 201 WebContents* GetWebContents(); | 206 WebContents* GetWebContents(); |
| 202 | 207 |
| 203 // Kill the guest process. | 208 // Kill the guest process. |
| 204 void Terminate(); | 209 void Terminate(); |
| 205 | 210 |
| 206 // Grab the new damage buffer from the embedder, and resize the guest's | 211 // Grab the new damage buffer from the embedder, and resize the guest's |
| 207 // web contents. | 212 // web contents. |
| 208 void Resize(RenderViewHost* embedder_rvh, | 213 void Resize(RenderViewHost* embedder_rvh, |
| 209 const BrowserPluginHostMsg_ResizeGuest_Params& params); | 214 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 215 // Allows or denies a media access request, after the embedder has had a |
| 216 // chance to decide. |
| 217 void AllowMediaAccess(WebContents* embedder_web_contents, |
| 218 int request_id, |
| 219 bool should_allow); |
| 210 | 220 |
| 211 // Overridden in tests. | 221 // Overridden in tests. |
| 212 // Handles input event routed through the embedder (which is initiated in the | 222 // Handles input event routed through the embedder (which is initiated in the |
| 213 // browser plugin (renderer side of the embedder)). | 223 // browser plugin (renderer side of the embedder)). |
| 214 virtual void HandleInputEvent(RenderViewHost* render_view_host, | 224 virtual void HandleInputEvent(RenderViewHost* render_view_host, |
| 215 const gfx::Rect& guest_window_rect, | 225 const gfx::Rect& guest_window_rect, |
| 216 const gfx::Rect& guest_screen_rect, | 226 const gfx::Rect& guest_screen_rect, |
| 217 const WebKit::WebInputEvent& event, | 227 const WebKit::WebInputEvent& event, |
| 218 IPC::Message* reply_message); | 228 IPC::Message* reply_message); |
| 219 virtual bool ViewTakeFocus(bool reverse); | 229 virtual bool ViewTakeFocus(bool reverse); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 238 virtual void SetCompositingBufferData(int gpu_process_id, | 248 virtual void SetCompositingBufferData(int gpu_process_id, |
| 239 uint32 client_id, | 249 uint32 client_id, |
| 240 uint32 context_id, | 250 uint32 context_id, |
| 241 uint32 texture_id_0, | 251 uint32 texture_id_0, |
| 242 uint32 texture_id_1, | 252 uint32 texture_id_1, |
| 243 uint32 sync_point); | 253 uint32 sync_point); |
| 244 | 254 |
| 245 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 255 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
| 246 | 256 |
| 247 private: | 257 private: |
| 258 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback> |
| 259 MediaStreamRequestAndCallbackPair; |
| 260 typedef std::map<int, MediaStreamRequestAndCallbackPair> |
| 261 MediaStreamRequestsMap; |
| 262 |
| 248 friend class TestBrowserPluginGuest; | 263 friend class TestBrowserPluginGuest; |
| 249 | 264 |
| 250 BrowserPluginGuest(int instance_id, | 265 BrowserPluginGuest(int instance_id, |
| 251 WebContentsImpl* web_contents, | 266 WebContentsImpl* web_contents, |
| 252 const BrowserPluginHostMsg_CreateGuest_Params& params); | 267 const BrowserPluginHostMsg_CreateGuest_Params& params); |
| 253 | 268 |
| 254 // Returns the identifier that uniquely identifies a browser plugin guest | 269 // Returns the identifier that uniquely identifies a browser plugin guest |
| 255 // within an embedder. | 270 // within an embedder. |
| 256 int instance_id() const { return instance_id_; } | 271 int instance_id() const { return instance_id_; } |
| 257 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } | 272 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 gfx::Rect guest_window_rect_; | 311 gfx::Rect guest_window_rect_; |
| 297 gfx::Rect guest_screen_rect_; | 312 gfx::Rect guest_screen_rect_; |
| 298 IDMap<RenderViewHost> pending_updates_; | 313 IDMap<RenderViewHost> pending_updates_; |
| 299 int pending_update_counter_; | 314 int pending_update_counter_; |
| 300 base::TimeDelta guest_hang_timeout_; | 315 base::TimeDelta guest_hang_timeout_; |
| 301 bool focused_; | 316 bool focused_; |
| 302 bool visible_; | 317 bool visible_; |
| 303 bool auto_size_enabled_; | 318 bool auto_size_enabled_; |
| 304 gfx::Size max_auto_size_; | 319 gfx::Size max_auto_size_; |
| 305 gfx::Size min_auto_size_; | 320 gfx::Size min_auto_size_; |
| 321 // A counter to generate unique request id for a media access request. |
| 322 // We only need the ids to be unique for a given BrowserPluginGuest. |
| 323 int current_media_access_request_id_; |
| 324 // A map to store WebContents's media request object and callback. |
| 325 // We need to store these because we need a roundtrip to the embedder to know |
| 326 // if we allow or disallow the request. The key of the map is unique only for |
| 327 // a given BrowserPluginGuest. |
| 328 MediaStreamRequestsMap media_requests_map_; |
| 306 | 329 |
| 307 // Hardware Accelerated Surface Params | 330 // Hardware Accelerated Surface Params |
| 308 gfx::GLSurfaceHandle surface_handle_; | 331 gfx::GLSurfaceHandle surface_handle_; |
| 309 | 332 |
| 310 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 333 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 311 }; | 334 }; |
| 312 | 335 |
| 313 } // namespace content | 336 } // namespace content |
| 314 | 337 |
| 315 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 338 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |