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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // it is not visible anywhere and has no embedder WebContents assigned. | 90 // it is not visible anywhere and has no embedder WebContents assigned. |
91 // A BrowserPluginGuest is said to be "attached" if it has an embedder. | 91 // A BrowserPluginGuest is said to be "attached" if it has an embedder. |
92 // A BrowserPluginGuest can also create a new unattached guest via | 92 // A BrowserPluginGuest can also create a new unattached guest via |
93 // CreateNewWindow. The newly created guest will live in the same partition, | 93 // CreateNewWindow. The newly created guest will live in the same partition, |
94 // which means it can share storage and can script this guest. | 94 // which means it can share storage and can script this guest. |
95 class CONTENT_EXPORT BrowserPluginGuest | 95 class CONTENT_EXPORT BrowserPluginGuest |
96 : public JavaScriptDialogManager, | 96 : public JavaScriptDialogManager, |
97 public WebContentsDelegate, | 97 public WebContentsDelegate, |
98 public WebContentsObserver { | 98 public WebContentsObserver { |
99 public: | 99 public: |
100 typedef base::Callback<void(bool)> GeolocationCallback; | |
101 virtual ~BrowserPluginGuest(); | 100 virtual ~BrowserPluginGuest(); |
102 | 101 |
103 // The WebContents passed into the factory method here has not been | 102 // The WebContents passed into the factory method here has not been |
104 // initialized yet and so it does not yet hold a SiteInstance. | 103 // initialized yet and so it does not yet hold a SiteInstance. |
105 // BrowserPluginGuest must be constructed and installed into a WebContents | 104 // BrowserPluginGuest must be constructed and installed into a WebContents |
106 // prior to its initialization because WebContents needs to determine what | 105 // prior to its initialization because WebContents needs to determine what |
107 // type of WebContentsView to construct on initialization. The content | 106 // type of WebContentsView to construct on initialization. The content |
108 // embedder needs to be aware of |guest_site_instance| on the guest's | 107 // embedder needs to be aware of |guest_site_instance| on the guest's |
109 // construction and so we pass it in here. | 108 // construction and so we pass it in here. |
110 static BrowserPluginGuest* Create( | 109 static BrowserPluginGuest* Create( |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| | 281 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| |
283 // and initializes the guest with the provided |params|. Attaching a guest | 282 // and initializes the guest with the provided |params|. Attaching a guest |
284 // to an embedder implies that this guest's lifetime is no longer managed | 283 // to an embedder implies that this guest's lifetime is no longer managed |
285 // by its opener, and it can begin loading resources. |extra_params| are | 284 // by its opener, and it can begin loading resources. |extra_params| are |
286 // parameters passed into BrowserPlugin from JavaScript to be forwarded to | 285 // parameters passed into BrowserPlugin from JavaScript to be forwarded to |
287 // the content embedder. | 286 // the content embedder. |
288 void Attach(WebContentsImpl* embedder_web_contents, | 287 void Attach(WebContentsImpl* embedder_web_contents, |
289 BrowserPluginHostMsg_Attach_Params params, | 288 BrowserPluginHostMsg_Attach_Params params, |
290 const base::DictionaryValue& extra_params); | 289 const base::DictionaryValue& extra_params); |
291 | 290 |
292 // Requests geolocation permission through Embedder JavaScript API. | |
293 void AskEmbedderForGeolocationPermission(int bridge_id, | |
294 const GURL& requesting_frame, | |
295 bool user_gesture, | |
296 const GeolocationCallback& callback); | |
297 // Cancels pending geolocation request. | |
298 void CancelGeolocationRequest(int bridge_id); | |
299 | |
300 // Returns whether BrowserPluginGuest is interested in receiving the given | 291 // Returns whether BrowserPluginGuest is interested in receiving the given |
301 // |message|. | 292 // |message|. |
302 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 293 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
303 gfx::Rect ToGuestRect(const gfx::Rect& rect); | 294 gfx::Rect ToGuestRect(const gfx::Rect& rect); |
304 | 295 |
305 void DragSourceEndedAt(int client_x, int client_y, int screen_x, | 296 void DragSourceEndedAt(int client_x, int client_y, int screen_x, |
306 int screen_y, blink::WebDragOperation operation); | 297 int screen_y, blink::WebDragOperation operation); |
307 | 298 |
308 // Called when the drag started by this guest ends at an OS-level. | 299 // Called when the drag started by this guest ends at an OS-level. |
309 void EndSystemDrag(); | 300 void EndSystemDrag(); |
(...skipping 11 matching lines...) Expand all Loading... |
321 BrowserPluginGuest::factory_ = factory; | 312 BrowserPluginGuest::factory_ = factory; |
322 } | 313 } |
323 | 314 |
324 void SetZoom(double zoom_factor); | 315 void SetZoom(double zoom_factor); |
325 | 316 |
326 private: | 317 private: |
327 class EmbedderWebContentsObserver; | 318 class EmbedderWebContentsObserver; |
328 friend class TestBrowserPluginGuest; | 319 friend class TestBrowserPluginGuest; |
329 | 320 |
330 class DownloadRequest; | 321 class DownloadRequest; |
331 class GeolocationRequest; | |
332 class JavaScriptDialogRequest; | 322 class JavaScriptDialogRequest; |
333 // MediaRequest because of naming conflicts with MediaStreamRequest. | 323 // MediaRequest because of naming conflicts with MediaStreamRequest. |
334 class MediaRequest; | 324 class MediaRequest; |
335 class NewWindowRequest; | 325 class NewWindowRequest; |
336 class PermissionRequest; | 326 class PermissionRequest; |
337 class PointerLockRequest; | 327 class PointerLockRequest; |
338 | 328 |
339 // Tracks the name, and target URL of the new window and whether or not it has | 329 // Tracks the name, and target URL of the new window and whether or not it has |
340 // changed since the WebContents has been created and before the new window | 330 // changed since the WebContents has been created and before the new window |
341 // has been attached to a BrowserPlugin. Once the first navigation commits, we | 331 // has been attached to a BrowserPlugin. Once the first navigation commits, we |
(...skipping 17 matching lines...) Expand all Loading... |
359 | 349 |
360 // Destroy unattached new windows that have been opened by this | 350 // Destroy unattached new windows that have been opened by this |
361 // BrowserPluginGuest. | 351 // BrowserPluginGuest. |
362 void DestroyUnattachedWindows(); | 352 void DestroyUnattachedWindows(); |
363 | 353 |
364 void LoadURLWithParams(const GURL& url, | 354 void LoadURLWithParams(const GURL& url, |
365 const Referrer& referrer, | 355 const Referrer& referrer, |
366 PageTransition transition_type, | 356 PageTransition transition_type, |
367 WebContents* web_contents); | 357 WebContents* web_contents); |
368 | 358 |
369 // Bridge IDs correspond to a geolocation request. This method will remove | |
370 // the bookkeeping for a particular geolocation request associated with the | |
371 // provided |bridge_id|. It returns the request ID of the geolocation request. | |
372 int RemoveBridgeID(int bridge_id); | |
373 | |
374 // Returns the |request_id| generated for the |request| provided. | 359 // Returns the |request_id| generated for the |request| provided. |
375 int RequestPermission( | 360 void RequestPermission( |
376 BrowserPluginPermissionType permission_type, | 361 BrowserPluginPermissionType permission_type, |
377 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, | 362 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, |
378 const base::DictionaryValue& request_info); | 363 const base::DictionaryValue& request_info); |
379 | 364 |
380 // Creates a new guest window, and BrowserPluginGuest that is owned by this | 365 // Creates a new guest window, and BrowserPluginGuest that is owned by this |
381 // BrowserPluginGuest. | 366 // BrowserPluginGuest. |
382 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params); | 367 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params); |
383 | 368 |
384 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } | 369 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } |
385 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 370 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 const std::string& name); | 505 const std::string& name); |
521 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 506 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
522 | 507 |
523 // Requests download permission through embedder JavaScript API after | 508 // Requests download permission through embedder JavaScript API after |
524 // retrieving url information from IO thread. | 509 // retrieving url information from IO thread. |
525 void DidRetrieveDownloadURLFromRequestId( | 510 void DidRetrieveDownloadURLFromRequestId( |
526 const std::string& request_method, | 511 const std::string& request_method, |
527 const base::Callback<void(bool)>& callback, | 512 const base::Callback<void(bool)>& callback, |
528 const std::string& url); | 513 const std::string& url); |
529 | 514 |
530 // Embedder sets permission to allow or deny geolocation request. | |
531 void SetGeolocationPermission( | |
532 GeolocationCallback callback, int bridge_id, bool allowed); | |
533 | |
534 // Forwards all messages from the |pending_messages_| queue to the embedder. | 515 // Forwards all messages from the |pending_messages_| queue to the embedder. |
535 void SendQueuedMessages(); | 516 void SendQueuedMessages(); |
536 | 517 |
537 // Static factory instance (always NULL for non-test). | 518 // Static factory instance (always NULL for non-test). |
538 static BrowserPluginHostFactory* factory_; | 519 static BrowserPluginHostFactory* factory_; |
539 | 520 |
540 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 521 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
541 WebContentsImpl* embedder_web_contents_; | 522 WebContentsImpl* embedder_web_contents_; |
542 | 523 |
543 std::map<int, int> bridge_id_to_request_id_map_; | |
544 | |
545 // An identifier that uniquely identifies a browser plugin guest within an | 524 // An identifier that uniquely identifies a browser plugin guest within an |
546 // embedder. | 525 // embedder. |
547 int instance_id_; | 526 int instance_id_; |
548 scoped_ptr<base::SharedMemory> damage_buffer_; | 527 scoped_ptr<base::SharedMemory> damage_buffer_; |
549 // An identifier that uniquely identifies a damage buffer. | 528 // An identifier that uniquely identifies a damage buffer. |
550 uint32 damage_buffer_sequence_id_; | 529 uint32 damage_buffer_sequence_id_; |
551 size_t damage_buffer_size_; | 530 size_t damage_buffer_size_; |
552 gfx::Size damage_view_size_; | 531 gfx::Size damage_view_size_; |
553 float damage_buffer_scale_factor_; | 532 float damage_buffer_scale_factor_; |
554 float guest_device_scale_factor_; | 533 float guest_device_scale_factor_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 593 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
615 // permission. | 594 // permission. |
616 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 595 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
617 | 596 |
618 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 597 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
619 }; | 598 }; |
620 | 599 |
621 } // namespace content | 600 } // namespace content |
622 | 601 |
623 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 602 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |