| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // A browser plugin guest provides functionality for WebContents to operate in | 72 // A browser plugin guest provides functionality for WebContents to operate in |
| 73 // the guest role and implements guest-specific overrides for ViewHostMsg_* | 73 // the guest role and implements guest-specific overrides for ViewHostMsg_* |
| 74 // messages. | 74 // messages. |
| 75 // | 75 // |
| 76 // When a guest is initially created, it is in an unattached state. That is, | 76 // When a guest is initially created, it is in an unattached state. That is, |
| 77 // it is not visible anywhere and has no embedder WebContents assigned. | 77 // it is not visible anywhere and has no embedder WebContents assigned. |
| 78 // A BrowserPluginGuest is said to be "attached" if it has an embedder. | 78 // A BrowserPluginGuest is said to be "attached" if it has an embedder. |
| 79 // A BrowserPluginGuest can also create a new unattached guest via | 79 // A BrowserPluginGuest can also create a new unattached guest via |
| 80 // CreateNewWindow. The newly created guest will live in the same partition, | 80 // CreateNewWindow. The newly created guest will live in the same partition, |
| 81 // which means it can share storage and can script this guest. | 81 // which means it can share storage and can script this guest. |
| 82 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, | 82 class CONTENT_EXPORT BrowserPluginGuest |
| 83 public WebContentsDelegate, | 83 : public NotificationObserver, |
| 84 public WebContentsObserver { | 84 public WebContentsDelegate, |
| 85 public WebContentsObserver, |
| 86 public base::SupportsWeakPtr<BrowserPluginGuest> { |
| 85 public: | 87 public: |
| 86 typedef base::Callback<void(bool)> GeolocationCallback; | 88 typedef base::Callback<void(bool)> GeolocationCallback; |
| 87 virtual ~BrowserPluginGuest(); | 89 virtual ~BrowserPluginGuest(); |
| 88 | 90 |
| 89 static BrowserPluginGuest* Create( | 91 static BrowserPluginGuest* Create( |
| 90 int instance_id, | 92 int instance_id, |
| 91 WebContentsImpl* web_contents); | 93 WebContentsImpl* web_contents); |
| 92 | 94 |
| 93 // Destroys the guest WebContents and all its associated state, including | 95 // Destroys the guest WebContents and all its associated state, including |
| 94 // this BrowserPluginGuest, and its new unattached windows. | 96 // this BrowserPluginGuest, and its new unattached windows. |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // BrowserPluginGuest is already destroyed. | 233 // BrowserPluginGuest is already destroyed. |
| 232 static void AcknowledgeBufferPresent(int route_id, | 234 static void AcknowledgeBufferPresent(int route_id, |
| 233 int gpu_host_id, | 235 int gpu_host_id, |
| 234 const std::string& mailbox_name, | 236 const std::string& mailbox_name, |
| 235 uint32 sync_point); | 237 uint32 sync_point); |
| 236 | 238 |
| 237 // Returns whether BrowserPluginGuest is interested in receiving the given | 239 // Returns whether BrowserPluginGuest is interested in receiving the given |
| 238 // |message|. | 240 // |message|. |
| 239 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 241 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
| 240 | 242 |
| 243 void DragSourceEndedAt(int client_x, int client_y, int screen_x, |
| 244 int screen_y, WebKit::WebDragOperation operation); |
| 245 |
| 246 void DragSourceMovedTo(int client_x, int client_y, |
| 247 int screen_x, int screen_y); |
| 248 |
| 249 // Called when the drag started by this guest ends at an OS-level. |
| 250 void EndSystemDrag(); |
| 251 |
| 241 private: | 252 private: |
| 242 typedef std::pair<MediaStreamRequest, MediaResponseCallback> | 253 typedef std::pair<MediaStreamRequest, MediaResponseCallback> |
| 243 MediaStreamRequestAndCallbackPair; | 254 MediaStreamRequestAndCallbackPair; |
| 244 typedef std::map<int, MediaStreamRequestAndCallbackPair> | 255 typedef std::map<int, MediaStreamRequestAndCallbackPair> |
| 245 MediaStreamRequestsMap; | 256 MediaStreamRequestsMap; |
| 246 | 257 |
| 247 class EmbedderRenderViewHostObserver; | 258 class EmbedderRenderViewHostObserver; |
| 248 friend class TestBrowserPluginGuest; | 259 friend class TestBrowserPluginGuest; |
| 249 | 260 |
| 250 BrowserPluginGuest(int instance_id, | 261 BrowserPluginGuest(int instance_id, |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 void OnUnlockMouse(); | 367 void OnUnlockMouse(); |
| 357 void OnUnlockMouseAck(int instance_id); | 368 void OnUnlockMouseAck(int instance_id); |
| 358 void OnUpdateRectACK( | 369 void OnUpdateRectACK( |
| 359 int instance_id, | 370 int instance_id, |
| 360 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, | 371 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, |
| 361 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); | 372 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); |
| 362 | 373 |
| 363 | 374 |
| 364 // Message handlers for messages from guest. | 375 // Message handlers for messages from guest. |
| 365 | 376 |
| 377 void OnDragStopped(); |
| 366 void OnHandleInputEventAck( | 378 void OnHandleInputEventAck( |
| 367 WebKit::WebInputEvent::Type event_type, | 379 WebKit::WebInputEvent::Type event_type, |
| 368 InputEventAckState ack_result); | 380 InputEventAckState ack_result); |
| 369 void OnHasTouchEventHandlers(bool accept); | 381 void OnHasTouchEventHandlers(bool accept); |
| 370 void OnSetCursor(const WebCursor& cursor); | 382 void OnSetCursor(const WebCursor& cursor); |
| 371 // On MacOSX popups are painted by the browser process. We handle them here | 383 // On MacOSX popups are painted by the browser process. We handle them here |
| 372 // so that they are positioned correctly. | 384 // so that they are positioned correctly. |
| 373 #if defined(OS_MACOSX) | 385 #if defined(OS_MACOSX) |
| 374 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); | 386 void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); |
| 375 #endif | 387 #endif |
| 376 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); | 388 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); |
| 377 // Overriden in tests. | 389 // Overriden in tests. |
| 378 virtual void OnTakeFocus(bool reverse); | 390 virtual void OnTakeFocus(bool reverse); |
| 379 void OnUpdateDragCursor(WebKit::WebDragOperation operation); | |
| 380 void OnUpdateFrameName(int frame_id, | 391 void OnUpdateFrameName(int frame_id, |
| 381 bool is_top_level, | 392 bool is_top_level, |
| 382 const std::string& name); | 393 const std::string& name); |
| 383 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 394 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
| 384 | 395 |
| 385 // Helpers for |OnRespondPermission|. | 396 // Helpers for |OnRespondPermission|. |
| 386 void OnRespondPermissionDownload(int request_id, bool should_allow); | 397 void OnRespondPermissionDownload(int request_id, bool should_allow); |
| 387 void OnRespondPermissionGeolocation(int request_id, bool should_allow); | 398 void OnRespondPermissionGeolocation(int request_id, bool should_allow); |
| 388 void OnRespondPermissionMedia(int request_id, bool should_allow); | 399 void OnRespondPermissionMedia(int request_id, bool should_allow); |
| 389 void OnRespondPermissionNewWindow(int request_id, bool should_allow); | 400 void OnRespondPermissionNewWindow(int request_id, bool should_allow); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 461 |
| 451 typedef std::map<int, base::Callback<void(bool)> > DownloadRequestMap; | 462 typedef std::map<int, base::Callback<void(bool)> > DownloadRequestMap; |
| 452 DownloadRequestMap download_request_callback_map_; | 463 DownloadRequestMap download_request_callback_map_; |
| 453 | 464 |
| 454 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 465 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 455 }; | 466 }; |
| 456 | 467 |
| 457 } // namespace content | 468 } // namespace content |
| 458 | 469 |
| 459 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 470 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |