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