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 // Allow the embedder to call this for unhandled messages when | 291 // Allow the embedder to call this for unhandled messages when |
301 // BrowserPluginGuest is already destroyed. | 292 // BrowserPluginGuest is already destroyed. |
302 static void AcknowledgeBufferPresent(int route_id, | 293 static void AcknowledgeBufferPresent(int route_id, |
303 int gpu_host_id, | 294 int gpu_host_id, |
304 const gpu::Mailbox& mailbox, | 295 const gpu::Mailbox& mailbox, |
305 uint32 sync_point); | 296 uint32 sync_point); |
306 | 297 |
307 // Returns whether BrowserPluginGuest is interested in receiving the given | 298 // Returns whether BrowserPluginGuest is interested in receiving the given |
308 // |message|. | 299 // |message|. |
309 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 300 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
(...skipping 18 matching lines...) Expand all Loading... |
328 BrowserPluginGuest::factory_ = factory; | 319 BrowserPluginGuest::factory_ = factory; |
329 } | 320 } |
330 | 321 |
331 void SetZoom(double zoom_factor); | 322 void SetZoom(double zoom_factor); |
332 | 323 |
333 private: | 324 private: |
334 class EmbedderWebContentsObserver; | 325 class EmbedderWebContentsObserver; |
335 friend class TestBrowserPluginGuest; | 326 friend class TestBrowserPluginGuest; |
336 | 327 |
337 class DownloadRequest; | 328 class DownloadRequest; |
338 class GeolocationRequest; | |
339 class JavaScriptDialogRequest; | 329 class JavaScriptDialogRequest; |
340 // MediaRequest because of naming conflicts with MediaStreamRequest. | 330 // MediaRequest because of naming conflicts with MediaStreamRequest. |
341 class MediaRequest; | 331 class MediaRequest; |
342 class NewWindowRequest; | 332 class NewWindowRequest; |
343 class PermissionRequest; | 333 class PermissionRequest; |
344 class PointerLockRequest; | 334 class PointerLockRequest; |
345 | 335 |
346 // Tracks the name, and target URL of the new window and whether or not it has | 336 // Tracks the name, and target URL of the new window and whether or not it has |
347 // changed since the WebContents has been created and before the new window | 337 // changed since the WebContents has been created and before the new window |
348 // has been attached to a BrowserPlugin. Once the first navigation commits, we | 338 // has been attached to a BrowserPlugin. Once the first navigation commits, we |
(...skipping 17 matching lines...) Expand all Loading... |
366 | 356 |
367 // Destroy unattached new windows that have been opened by this | 357 // Destroy unattached new windows that have been opened by this |
368 // BrowserPluginGuest. | 358 // BrowserPluginGuest. |
369 void DestroyUnattachedWindows(); | 359 void DestroyUnattachedWindows(); |
370 | 360 |
371 void LoadURLWithParams(const GURL& url, | 361 void LoadURLWithParams(const GURL& url, |
372 const Referrer& referrer, | 362 const Referrer& referrer, |
373 PageTransition transition_type, | 363 PageTransition transition_type, |
374 WebContents* web_contents); | 364 WebContents* web_contents); |
375 | 365 |
376 // Bridge IDs correspond to a geolocation request. This method will remove | |
377 // the bookkeeping for a particular geolocation request associated with the | |
378 // provided |bridge_id|. It returns the request ID of the geolocation request. | |
379 int RemoveBridgeID(int bridge_id); | |
380 | |
381 // Returns the |request_id| generated for the |request| provided. | 366 // Returns the |request_id| generated for the |request| provided. |
382 int RequestPermission( | 367 int RequestPermission( |
383 BrowserPluginPermissionType permission_type, | 368 BrowserPluginPermissionType permission_type, |
384 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, | 369 scoped_refptr<BrowserPluginGuest::PermissionRequest> request, |
385 const base::DictionaryValue& request_info); | 370 const base::DictionaryValue& request_info); |
386 | 371 |
387 // Creates a new guest window, and BrowserPluginGuest that is owned by this | 372 // Creates a new guest window, and BrowserPluginGuest that is owned by this |
388 // BrowserPluginGuest. | 373 // BrowserPluginGuest. |
389 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params); | 374 BrowserPluginGuest* CreateNewGuestWindow(const OpenURLParams& params); |
390 | 375 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 const std::string& name); | 515 const std::string& name); |
531 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 516 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
532 | 517 |
533 // Requests download permission through embedder JavaScript API after | 518 // Requests download permission through embedder JavaScript API after |
534 // retrieving url information from IO thread. | 519 // retrieving url information from IO thread. |
535 void DidRetrieveDownloadURLFromRequestId( | 520 void DidRetrieveDownloadURLFromRequestId( |
536 const std::string& request_method, | 521 const std::string& request_method, |
537 const base::Callback<void(bool)>& callback, | 522 const base::Callback<void(bool)>& callback, |
538 const std::string& url); | 523 const std::string& url); |
539 | 524 |
540 // Embedder sets permission to allow or deny geolocation request. | |
541 void SetGeolocationPermission( | |
542 GeolocationCallback callback, int bridge_id, bool allowed); | |
543 | |
544 // Forwards all messages from the |pending_messages_| queue to the embedder. | 525 // Forwards all messages from the |pending_messages_| queue to the embedder. |
545 void SendQueuedMessages(); | 526 void SendQueuedMessages(); |
546 | 527 |
547 // Static factory instance (always NULL for non-test). | 528 // Static factory instance (always NULL for non-test). |
548 static BrowserPluginHostFactory* factory_; | 529 static BrowserPluginHostFactory* factory_; |
549 | 530 |
550 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 531 scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; |
551 WebContentsImpl* embedder_web_contents_; | 532 WebContentsImpl* embedder_web_contents_; |
552 | 533 |
553 std::map<int, int> bridge_id_to_request_id_map_; | |
554 | |
555 // An identifier that uniquely identifies a browser plugin guest within an | 534 // An identifier that uniquely identifies a browser plugin guest within an |
556 // embedder. | 535 // embedder. |
557 int instance_id_; | 536 int instance_id_; |
558 scoped_ptr<base::SharedMemory> damage_buffer_; | 537 scoped_ptr<base::SharedMemory> damage_buffer_; |
559 // An identifier that uniquely identifies a damage buffer. | 538 // An identifier that uniquely identifies a damage buffer. |
560 uint32 damage_buffer_sequence_id_; | 539 uint32 damage_buffer_sequence_id_; |
561 size_t damage_buffer_size_; | 540 size_t damage_buffer_size_; |
562 gfx::Size damage_view_size_; | 541 gfx::Size damage_view_size_; |
563 float damage_buffer_scale_factor_; | 542 float damage_buffer_scale_factor_; |
564 float guest_device_scale_factor_; | 543 float guest_device_scale_factor_; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 603 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
625 // permission. | 604 // permission. |
626 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 605 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
627 | 606 |
628 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 607 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
629 }; | 608 }; |
630 | 609 |
631 } // namespace content | 610 } // namespace content |
632 | 611 |
633 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 612 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |