| 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. It has a | 9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a |
| 10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The | 10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 namespace WebKit { | 52 namespace WebKit { |
| 53 class WebInputEvent; | 53 class WebInputEvent; |
| 54 } | 54 } |
| 55 | 55 |
| 56 namespace content { | 56 namespace content { |
| 57 | 57 |
| 58 class BrowserPluginHostFactory; | 58 class BrowserPluginHostFactory; |
| 59 class BrowserPluginEmbedder; | 59 class BrowserPluginEmbedder; |
| 60 class RenderProcessHost; | 60 class RenderProcessHost; |
| 61 struct MediaStreamRequest; |
| 61 | 62 |
| 62 // A browser plugin guest provides functionality for WebContents to operate in | 63 // A browser plugin guest provides functionality for WebContents to operate in |
| 63 // the guest role and implements guest specific overrides for ViewHostMsg_* | 64 // the guest role and implements guest specific overrides for ViewHostMsg_* |
| 64 // messages. | 65 // messages. |
| 65 // | 66 // |
| 66 // BrowserPluginEmbedder is responsible for creating and destroying a guest. | 67 // BrowserPluginEmbedder is responsible for creating and destroying a guest. |
| 67 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, | 68 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, |
| 68 public WebContentsDelegate, | 69 public WebContentsDelegate, |
| 69 public WebContentsObserver { | 70 public WebContentsObserver { |
| 70 public: | 71 public: |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // WebContentsDelegate implementation. | 141 // WebContentsDelegate implementation. |
| 141 virtual bool CanDownload(RenderViewHost* render_view_host, | 142 virtual bool CanDownload(RenderViewHost* render_view_host, |
| 142 int request_id, | 143 int request_id, |
| 143 const std::string& request_method) OVERRIDE; | 144 const std::string& request_method) OVERRIDE; |
| 144 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 145 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
| 145 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | 146 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; |
| 146 virtual void RendererResponsive(WebContents* source) OVERRIDE; | 147 virtual void RendererResponsive(WebContents* source) OVERRIDE; |
| 147 virtual void RunFileChooser(WebContents* web_contents, | 148 virtual void RunFileChooser(WebContents* web_contents, |
| 148 const FileChooserParams& params) OVERRIDE; | 149 const FileChooserParams& params) OVERRIDE; |
| 149 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | 150 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
| 151 virtual void RequestMediaAccessPermission( |
| 152 WebContents* web_contents, |
| 153 const content::MediaStreamRequest& request, |
| 154 const content::MediaResponseCallback& callback) OVERRIDE; |
| 150 | 155 |
| 151 // Exposes the protected web_contents() from WebContentsObserver. | 156 // Exposes the protected web_contents() from WebContentsObserver. |
| 152 WebContents* GetWebContents(); | 157 WebContents* GetWebContents(); |
| 153 | 158 |
| 154 // Kill the guest process. | 159 // Kill the guest process. |
| 155 void Terminate(); | 160 void Terminate(); |
| 156 | 161 |
| 157 // Overridden in tests. | 162 // Overridden in tests. |
| 158 virtual void SetDamageBuffer( | 163 virtual void SetDamageBuffer( |
| 159 const BrowserPluginHostMsg_ResizeGuest_Params& params); | 164 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 171 int instance_id() const { return instance_id_; } | 176 int instance_id() const { return instance_id_; } |
| 172 | 177 |
| 173 // Allow the embedder to call this for unhandled messages when | 178 // Allow the embedder to call this for unhandled messages when |
| 174 // BrowserPluginGuest is already destroyed. | 179 // BrowserPluginGuest is already destroyed. |
| 175 static void AcknowledgeBufferPresent(int route_id, | 180 static void AcknowledgeBufferPresent(int route_id, |
| 176 int gpu_host_id, | 181 int gpu_host_id, |
| 177 const std::string& mailbox_name, | 182 const std::string& mailbox_name, |
| 178 uint32 sync_point); | 183 uint32 sync_point); |
| 179 | 184 |
| 180 private: | 185 private: |
| 186 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback> |
| 187 MediaStreamRequestAndCallbackPair; |
| 188 typedef std::map<int, MediaStreamRequestAndCallbackPair> |
| 189 MediaStreamRequestsMap; |
| 190 |
| 181 friend class TestBrowserPluginGuest; | 191 friend class TestBrowserPluginGuest; |
| 182 | 192 |
| 183 BrowserPluginGuest(int instance_id, | 193 BrowserPluginGuest(int instance_id, |
| 184 WebContentsImpl* web_contents, | 194 WebContentsImpl* web_contents, |
| 185 const BrowserPluginHostMsg_CreateGuest_Params& params); | 195 const BrowserPluginHostMsg_CreateGuest_Params& params); |
| 186 | 196 |
| 187 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } | 197 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } |
| 188 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 198 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
| 189 float damage_buffer_scale_factor() const { | 199 float damage_buffer_scale_factor() const { |
| 190 return damage_buffer_scale_factor_; | 200 return damage_buffer_scale_factor_; |
| 191 } | 201 } |
| 192 // Returns the damage buffer corresponding to the handle in resize |params|. | 202 // Returns the damage buffer corresponding to the handle in resize |params|. |
| 193 base::SharedMemory* GetDamageBufferFromEmbedder( | 203 base::SharedMemory* GetDamageBufferFromEmbedder( |
| 194 const BrowserPluginHostMsg_ResizeGuest_Params& params); | 204 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 195 | 205 |
| 196 // Called when a redirect notification occurs. | 206 // Called when a redirect notification occurs. |
| 197 void LoadRedirect(const GURL& old_url, | 207 void LoadRedirect(const GURL& old_url, |
| 198 const GURL& new_url, | 208 const GURL& new_url, |
| 199 bool is_top_level); | 209 bool is_top_level); |
| 200 | 210 |
| 201 bool InAutoSizeBounds(const gfx::Size& size) const; | 211 bool InAutoSizeBounds(const gfx::Size& size) const; |
| 202 | 212 |
| 203 // Message handlers for messsages from embedder. | 213 // Message handlers for messsages from embedder. |
| 204 | 214 |
| 215 // Allows or denies a permission request access, after the embedder has had a |
| 216 // chance to decide. |
| 217 void OnAllowPermission(int instance_id, |
| 218 const std::string& permission_type, |
| 219 int request_id, |
| 220 bool should_allow); |
| 205 // Handles drag events from the embedder. | 221 // Handles drag events from the embedder. |
| 206 // When dragging, the drag events go to the embedder first, and if the drag | 222 // When dragging, the drag events go to the embedder first, and if the drag |
| 207 // happens on the browser plugin, then the plugin sends a corresponding | 223 // happens on the browser plugin, then the plugin sends a corresponding |
| 208 // drag-message to the guest. This routes the drag-message to the guest | 224 // drag-message to the guest. This routes the drag-message to the guest |
| 209 // renderer. | 225 // renderer. |
| 210 void OnDragStatusUpdate(int instance_id, | 226 void OnDragStatusUpdate(int instance_id, |
| 211 WebKit::WebDragStatus drag_status, | 227 WebKit::WebDragStatus drag_status, |
| 212 const WebDropData& drop_data, | 228 const WebDropData& drop_data, |
| 213 WebKit::WebDragOperationsMask drag_mask, | 229 WebKit::WebDragOperationsMask drag_mask, |
| 214 const gfx::Point& location); | 230 const gfx::Point& location); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 gfx::Rect guest_window_rect_; | 326 gfx::Rect guest_window_rect_; |
| 311 gfx::Rect guest_screen_rect_; | 327 gfx::Rect guest_screen_rect_; |
| 312 base::TimeDelta guest_hang_timeout_; | 328 base::TimeDelta guest_hang_timeout_; |
| 313 bool focused_; | 329 bool focused_; |
| 314 bool visible_; | 330 bool visible_; |
| 315 std::string name_; | 331 std::string name_; |
| 316 bool auto_size_enabled_; | 332 bool auto_size_enabled_; |
| 317 gfx::Size max_auto_size_; | 333 gfx::Size max_auto_size_; |
| 318 gfx::Size min_auto_size_; | 334 gfx::Size min_auto_size_; |
| 319 | 335 |
| 336 // A counter to generate unique request id for a media access request. |
| 337 // We only need the ids to be unique for a given BrowserPluginGuest. |
| 338 int current_media_access_request_id_; |
| 339 // A map to store WebContents's media request object and callback. |
| 340 // We need to store these because we need a roundtrip to the embedder to know |
| 341 // if we allow or disallow the request. The key of the map is unique only for |
| 342 // a given BrowserPluginGuest. |
| 343 MediaStreamRequestsMap media_requests_map_; |
| 344 |
| 320 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 345 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 321 }; | 346 }; |
| 322 | 347 |
| 323 } // namespace content | 348 } // namespace content |
| 324 | 349 |
| 325 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 350 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |