| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 82 | 82 | 
| 83   // The WebContents passed into the factory method here has not been | 83   // The WebContents passed into the factory method here has not been | 
| 84   // initialized yet and so it does not yet hold a SiteInstance. | 84   // initialized yet and so it does not yet hold a SiteInstance. | 
| 85   // BrowserPluginGuest must be constructed and installed into a WebContents | 85   // BrowserPluginGuest must be constructed and installed into a WebContents | 
| 86   // prior to its initialization because WebContents needs to determine what | 86   // prior to its initialization because WebContents needs to determine what | 
| 87   // type of WebContentsView to construct on initialization. The content | 87   // type of WebContentsView to construct on initialization. The content | 
| 88   // embedder needs to be aware of |guest_site_instance| on the guest's | 88   // embedder needs to be aware of |guest_site_instance| on the guest's | 
| 89   // construction and so we pass it in here. | 89   // construction and so we pass it in here. | 
| 90   static BrowserPluginGuest* Create( | 90   static BrowserPluginGuest* Create( | 
| 91       int instance_id, | 91       int instance_id, | 
| 92       SiteInstance* guest_site_instance, |  | 
| 93       WebContentsImpl* web_contents, | 92       WebContentsImpl* web_contents, | 
| 94       scoped_ptr<base::DictionaryValue> extra_params, | 93       BrowserPluginGuestDelegate* delegate); | 
| 95       BrowserPluginGuest* opener); |  | 
| 96 | 94 | 
| 97   // Returns whether the given WebContents is a BrowserPlugin guest. | 95   // Returns whether the given WebContents is a BrowserPlugin guest. | 
| 98   static bool IsGuest(WebContentsImpl* web_contents); | 96   static bool IsGuest(WebContentsImpl* web_contents); | 
| 99 | 97 | 
| 100   // Returns whether the given RenderviewHost is a BrowserPlugin guest. | 98   // Returns whether the given RenderviewHost is a BrowserPlugin guest. | 
| 101   static bool IsGuest(RenderViewHostImpl* render_view_host); | 99   static bool IsGuest(RenderViewHostImpl* render_view_host); | 
| 102 | 100 | 
| 103   // Returns a WeakPtr to this BrowserPluginGuest. | 101   // Returns a WeakPtr to this BrowserPluginGuest. | 
| 104   base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); | 102   base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); | 
| 105 | 103 | 
| 106   // Sets the lock state of the pointer. Returns true if |allowed| is true and | 104   // Sets the lock state of the pointer. Returns true if |allowed| is true and | 
| 107   // the mouse has been successfully locked. | 105   // the mouse has been successfully locked. | 
| 108   bool LockMouse(bool allowed); | 106   bool LockMouse(bool allowed); | 
| 109 | 107 | 
| 110   // Called when the embedder WebContents changes visibility. | 108   // Called when the embedder WebContents changes visibility. | 
| 111   void EmbedderVisibilityChanged(bool visible); | 109   void EmbedderVisibilityChanged(bool visible); | 
| 112 | 110 | 
| 113   // Destroys the guest WebContents and all its associated state, including | 111   // Destroys the guest WebContents and all its associated state, including | 
| 114   // this BrowserPluginGuest, and its new unattached windows. | 112   // this BrowserPluginGuest, and its new unattached windows. | 
| 115   void Destroy(); | 113   void Destroy(); | 
| 116 | 114 | 
|  | 115   // Creates a new guest WebContentsImpl with the provided |params| with |this| | 
|  | 116   // as the |opener|. | 
|  | 117   WebContentsImpl* CreateNewGuestWindow( | 
|  | 118       const WebContents::CreateParams& params); | 
|  | 119 | 
| 117   // Returns the identifier that uniquely identifies a browser plugin guest | 120   // Returns the identifier that uniquely identifies a browser plugin guest | 
| 118   // within an embedder. | 121   // within an embedder. | 
| 119   int instance_id() const { return instance_id_; } | 122   int instance_id() const { return instance_id_; } | 
| 120 | 123 | 
| 121   bool OnMessageReceivedFromEmbedder(const IPC::Message& message); | 124   bool OnMessageReceivedFromEmbedder(const IPC::Message& message); | 
| 122 | 125 | 
| 123   WebContentsImpl* embedder_web_contents() const { | 126   WebContentsImpl* embedder_web_contents() const { | 
| 124     return embedder_web_contents_; | 127     return embedder_web_contents_; | 
| 125   } | 128   } | 
| 126 | 129 | 
| 127   // Returns the embedder's RenderWidgetHostView if it is available. | 130   // Returns the embedder's RenderWidgetHostView if it is available. | 
| 128   // Returns NULL otherwise. | 131   // Returns NULL otherwise. | 
| 129   RenderWidgetHostView* GetEmbedderRenderWidgetHostView(); | 132   RenderWidgetHostView* GetEmbedderRenderWidgetHostView(); | 
| 130 | 133 | 
| 131   bool focused() const { return focused_; } | 134   bool focused() const { return focused_; } | 
| 132   bool visible() const { return guest_visible_; } | 135   bool visible() const { return guest_visible_; } | 
| 133   bool is_in_destruction() { return is_in_destruction_; } | 136   bool is_in_destruction() { return is_in_destruction_; } | 
| 134 | 137 | 
| 135   // Returns the BrowserPluginGuest that created this guest, if any. |  | 
| 136   BrowserPluginGuest* GetOpener() const; |  | 
| 137 |  | 
| 138   void UpdateVisibility(); | 138   void UpdateVisibility(); | 
| 139 | 139 | 
| 140   void CopyFromCompositingSurface( | 140   void CopyFromCompositingSurface( | 
| 141       gfx::Rect src_subrect, | 141       gfx::Rect src_subrect, | 
| 142       gfx::Size dst_size, | 142       gfx::Size dst_size, | 
| 143       const base::Callback<void(bool, const SkBitmap&)>& callback); | 143       const base::Callback<void(bool, const SkBitmap&)>& callback); | 
| 144 | 144 | 
| 145   BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; | 145   BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; | 
| 146 | 146 | 
| 147   // WebContentsObserver implementation. | 147   // WebContentsObserver implementation. | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 183   // |message|. | 183   // |message|. | 
| 184   static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 184   static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 
| 185   gfx::Rect ToGuestRect(const gfx::Rect& rect); | 185   gfx::Rect ToGuestRect(const gfx::Rect& rect); | 
| 186 | 186 | 
| 187   void DragSourceEndedAt(int client_x, int client_y, int screen_x, | 187   void DragSourceEndedAt(int client_x, int client_y, int screen_x, | 
| 188       int screen_y, blink::WebDragOperation operation); | 188       int screen_y, blink::WebDragOperation operation); | 
| 189 | 189 | 
| 190   // Called when the drag started by this guest ends at an OS-level. | 190   // Called when the drag started by this guest ends at an OS-level. | 
| 191   void EndSystemDrag(); | 191   void EndSystemDrag(); | 
| 192 | 192 | 
| 193   void set_delegate(BrowserPluginGuestDelegate* delegate) { |  | 
| 194     DCHECK(!delegate_); |  | 
| 195     delegate_ = delegate; |  | 
| 196   } |  | 
| 197 |  | 
| 198   void RespondToPermissionRequest(int request_id, | 193   void RespondToPermissionRequest(int request_id, | 
| 199                                   bool should_allow, | 194                                   bool should_allow, | 
| 200                                   const std::string& user_input); | 195                                   const std::string& user_input); | 
| 201 | 196 | 
| 202   void PointerLockPermissionResponse(bool allow); | 197   void PointerLockPermissionResponse(bool allow); | 
| 203 | 198 | 
| 204  private: | 199  private: | 
| 205   class EmbedderWebContentsObserver; | 200   class EmbedderWebContentsObserver; | 
| 206 | 201 | 
| 207   // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 202   // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 
| 208   // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 203   // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 
| 209   BrowserPluginGuest(int instance_id, | 204   BrowserPluginGuest(int instance_id, | 
| 210                      bool has_render_view, | 205                      bool has_render_view, | 
| 211                      WebContentsImpl* web_contents); | 206                      WebContentsImpl* web_contents, | 
|  | 207                      BrowserPluginGuestDelegate* delegate); | 
| 212 | 208 | 
| 213   void WillDestroy(); | 209   void WillDestroy(); | 
| 214 | 210 | 
| 215   void Initialize(const BrowserPluginHostMsg_Attach_Params& params, | 211   void Initialize(const BrowserPluginHostMsg_Attach_Params& params, | 
| 216                   WebContentsImpl* embedder_web_contents, | 212                   WebContentsImpl* embedder_web_contents, | 
| 217                   const base::DictionaryValue& extra_params); | 213                   const base::DictionaryValue& extra_params); | 
| 218 | 214 | 
| 219   bool InAutoSizeBounds(const gfx::Size& size) const; | 215   bool InAutoSizeBounds(const gfx::Size& size) const; | 
| 220 | 216 | 
| 221   // Message handlers for messages from embedder. | 217   // Message handlers for messages from embedder. | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 331   void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 327   void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 
| 332 | 328 | 
| 333   // Forwards all messages from the |pending_messages_| queue to the embedder. | 329   // Forwards all messages from the |pending_messages_| queue to the embedder. | 
| 334   void SendQueuedMessages(); | 330   void SendQueuedMessages(); | 
| 335 | 331 | 
| 336   scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 332   scoped_ptr<EmbedderWebContentsObserver> embedder_web_contents_observer_; | 
| 337   WebContentsImpl* embedder_web_contents_; | 333   WebContentsImpl* embedder_web_contents_; | 
| 338 | 334 | 
| 339   // An identifier that uniquely identifies a browser plugin guest within an | 335   // An identifier that uniquely identifies a browser plugin guest within an | 
| 340   // embedder. | 336   // embedder. | 
| 341   int instance_id_; | 337   const int instance_id_; | 
| 342   float guest_device_scale_factor_; | 338   float guest_device_scale_factor_; | 
| 343   gfx::Rect guest_window_rect_; | 339   gfx::Rect guest_window_rect_; | 
| 344   gfx::Rect guest_screen_rect_; | 340   gfx::Rect guest_screen_rect_; | 
| 345   bool focused_; | 341   bool focused_; | 
| 346   bool mouse_locked_; | 342   bool mouse_locked_; | 
| 347   bool pending_lock_request_; | 343   bool pending_lock_request_; | 
| 348   bool guest_visible_; | 344   bool guest_visible_; | 
| 349   bool guest_opaque_; | 345   bool guest_opaque_; | 
| 350   bool embedder_visible_; | 346   bool embedder_visible_; | 
| 351   std::string name_; | 347   std::string name_; | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 377 | 373 | 
| 378   // Text input type states. | 374   // Text input type states. | 
| 379   ui::TextInputType last_text_input_type_; | 375   ui::TextInputType last_text_input_type_; | 
| 380   ui::TextInputMode last_input_mode_; | 376   ui::TextInputMode last_input_mode_; | 
| 381   bool last_can_compose_inline_; | 377   bool last_can_compose_inline_; | 
| 382 | 378 | 
| 383   // This is a queue of messages that are destined to be sent to the embedder | 379   // This is a queue of messages that are destined to be sent to the embedder | 
| 384   // once the guest is attached to a particular embedder. | 380   // once the guest is attached to a particular embedder. | 
| 385   std::deque<linked_ptr<IPC::Message> > pending_messages_; | 381   std::deque<linked_ptr<IPC::Message> > pending_messages_; | 
| 386 | 382 | 
| 387   BrowserPluginGuestDelegate* delegate_; | 383   BrowserPluginGuestDelegate* const delegate_; | 
| 388 | 384 | 
| 389   // Weak pointer used to ask GeolocationPermissionContext about geolocation | 385   // Weak pointer used to ask GeolocationPermissionContext about geolocation | 
| 390   // permission. | 386   // permission. | 
| 391   base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 387   base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 
| 392 | 388 | 
| 393   DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 389   DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 
| 394 }; | 390 }; | 
| 395 | 391 | 
| 396 }  // namespace content | 392 }  // namespace content | 
| 397 | 393 | 
| 398 #endif  // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 394 #endif  // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 
| OLD | NEW | 
|---|