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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Returns whether the given RenderviewHost is a BrowserPlugin guest. | 99 // Returns whether the given RenderviewHost is a BrowserPlugin guest. |
100 static bool IsGuest(RenderViewHostImpl* render_view_host); | 100 static bool IsGuest(RenderViewHostImpl* render_view_host); |
101 | 101 |
102 // Returns a WeakPtr to this BrowserPluginGuest. | 102 // Returns a WeakPtr to this BrowserPluginGuest. |
103 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); | 103 base::WeakPtr<BrowserPluginGuest> AsWeakPtr(); |
104 | 104 |
105 // Sets the lock state of the pointer. Returns true if |allowed| is true and | 105 // Sets the lock state of the pointer. Returns true if |allowed| is true and |
106 // the mouse has been successfully locked. | 106 // the mouse has been successfully locked. |
107 bool LockMouse(bool allowed); | 107 bool LockMouse(bool allowed); |
108 | 108 |
109 // Called when the embedder WebContents is destroyed to give the | |
110 // BrowserPluginGuest an opportunity to clean up after itself. | |
111 void EmbedderDestroyed(); | |
112 | |
113 // Called when the embedder WebContents changes visibility. | 109 // Called when the embedder WebContents changes visibility. |
114 void EmbedderVisibilityChanged(bool visible); | 110 void EmbedderVisibilityChanged(bool visible); |
115 | 111 |
116 // Destroys the guest WebContents and all its associated state, including | 112 // Destroys the guest WebContents and all its associated state, including |
117 // this BrowserPluginGuest, and its new unattached windows. | 113 // this BrowserPluginGuest, and its new unattached windows. |
118 void Destroy(); | 114 void Destroy(); |
119 | 115 |
120 // Returns the identifier that uniquely identifies a browser plugin guest | 116 // Returns the identifier that uniquely identifies a browser plugin guest |
121 // within an embedder. | 117 // within an embedder. |
122 int instance_id() const { return instance_id_; } | 118 int instance_id() const { return instance_id_; } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // |message|. | 188 // |message|. |
193 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 189 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
194 gfx::Rect ToGuestRect(const gfx::Rect& rect); | 190 gfx::Rect ToGuestRect(const gfx::Rect& rect); |
195 | 191 |
196 void DragSourceEndedAt(int client_x, int client_y, int screen_x, | 192 void DragSourceEndedAt(int client_x, int client_y, int screen_x, |
197 int screen_y, blink::WebDragOperation operation); | 193 int screen_y, blink::WebDragOperation operation); |
198 | 194 |
199 // Called when the drag started by this guest ends at an OS-level. | 195 // Called when the drag started by this guest ends at an OS-level. |
200 void EndSystemDrag(); | 196 void EndSystemDrag(); |
201 | 197 |
202 // |this| takes ownership of |delegate|. | 198 void set_delegate(BrowserPluginGuestDelegate* delegate) { |
203 void SetDelegate(BrowserPluginGuestDelegate* delegate); | 199 DCHECK(!delegate_); |
| 200 delegate_ = delegate; |
| 201 } |
204 | 202 |
205 void RespondToPermissionRequest(int request_id, | 203 void RespondToPermissionRequest(int request_id, |
206 bool should_allow, | 204 bool should_allow, |
207 const std::string& user_input); | 205 const std::string& user_input); |
208 | 206 |
209 // Overrides factory for testing. Default (NULL) value indicates regular | 207 // Overrides factory for testing. Default (NULL) value indicates regular |
210 // (non-test) environment. | 208 // (non-test) environment. |
211 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { | 209 static void set_factory_for_testing(BrowserPluginHostFactory* factory) { |
212 BrowserPluginGuest::factory_ = factory; | 210 BrowserPluginGuest::factory_ = factory; |
213 } | 211 } |
214 | 212 |
215 void SetZoom(double zoom_factor); | 213 void SetZoom(double zoom_factor); |
216 | 214 |
217 void PointerLockPermissionResponse(bool allow); | 215 void PointerLockPermissionResponse(bool allow); |
218 | 216 |
219 private: | 217 private: |
220 class EmbedderWebContentsObserver; | 218 class EmbedderWebContentsObserver; |
221 friend class TestBrowserPluginGuest; | 219 friend class TestBrowserPluginGuest; |
222 | 220 |
223 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 221 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and |
224 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 222 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. |
225 BrowserPluginGuest(int instance_id, | 223 BrowserPluginGuest(int instance_id, |
226 bool has_render_view, | 224 bool has_render_view, |
227 WebContentsImpl* web_contents); | 225 WebContentsImpl* web_contents); |
228 | 226 |
229 void WillDestroy(WebContents* web_contents); | 227 void WillDestroy(); |
230 | 228 |
231 bool InAutoSizeBounds(const gfx::Size& size) const; | 229 bool InAutoSizeBounds(const gfx::Size& size) const; |
232 | 230 |
233 // Message handlers for messages from embedder. | 231 // Message handlers for messages from embedder. |
234 | 232 |
235 void OnCompositorFrameSwappedACK( | 233 void OnCompositorFrameSwappedACK( |
236 int instance_id, | 234 int instance_id, |
237 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 235 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
238 void OnCopyFromCompositingSurfaceAck(int instance_id, | 236 void OnCopyFromCompositingSurfaceAck(int instance_id, |
239 int request_id, | 237 int request_id, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 | 391 |
394 // Text input type states. | 392 // Text input type states. |
395 ui::TextInputType last_text_input_type_; | 393 ui::TextInputType last_text_input_type_; |
396 ui::TextInputMode last_input_mode_; | 394 ui::TextInputMode last_input_mode_; |
397 bool last_can_compose_inline_; | 395 bool last_can_compose_inline_; |
398 | 396 |
399 // This is a queue of messages that are destined to be sent to the embedder | 397 // This is a queue of messages that are destined to be sent to the embedder |
400 // once the guest is attached to a particular embedder. | 398 // once the guest is attached to a particular embedder. |
401 std::queue<IPC::Message*> pending_messages_; | 399 std::queue<IPC::Message*> pending_messages_; |
402 | 400 |
403 scoped_ptr<BrowserPluginGuestDelegate> delegate_; | 401 BrowserPluginGuestDelegate* delegate_; |
404 | 402 |
405 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 403 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
406 // permission. | 404 // permission. |
407 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 405 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
408 | 406 |
409 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 407 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
410 }; | 408 }; |
411 | 409 |
412 } // namespace content | 410 } // namespace content |
413 | 411 |
414 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 412 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |