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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 namespace blink { | 52 namespace blink { |
53 class WebInputEvent; | 53 class WebInputEvent; |
54 } | 54 } |
55 | 55 |
56 namespace gfx { | 56 namespace gfx { |
57 class Range; | 57 class Range; |
58 } | 58 } |
59 | 59 |
60 namespace content { | 60 namespace content { |
61 | 61 |
| 62 class BrowserPluginGuestManager; |
62 class BrowserPluginHostFactory; | 63 class BrowserPluginHostFactory; |
63 class RenderWidgetHostView; | 64 class RenderWidgetHostView; |
64 class SiteInstance; | 65 class SiteInstance; |
65 class WebCursor; | 66 class WebCursor; |
66 struct DropData; | 67 struct DropData; |
67 struct MediaStreamRequest; | 68 struct MediaStreamRequest; |
68 | 69 |
69 // A browser plugin guest provides functionality for WebContents to operate in | 70 // A browser plugin guest provides functionality for WebContents to operate in |
70 // the guest role and implements guest-specific overrides for ViewHostMsg_* | 71 // the guest role and implements guest-specific overrides for ViewHostMsg_* |
71 // messages. | 72 // messages. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 130 } |
130 | 131 |
131 // Returns the embedder's RenderWidgetHostView if it is available. | 132 // Returns the embedder's RenderWidgetHostView if it is available. |
132 // Returns NULL otherwise. | 133 // Returns NULL otherwise. |
133 RenderWidgetHostView* GetEmbedderRenderWidgetHostView(); | 134 RenderWidgetHostView* GetEmbedderRenderWidgetHostView(); |
134 | 135 |
135 bool focused() const { return focused_; } | 136 bool focused() const { return focused_; } |
136 bool visible() const { return guest_visible_; } | 137 bool visible() const { return guest_visible_; } |
137 bool is_in_destruction() { return is_in_destruction_; } | 138 bool is_in_destruction() { return is_in_destruction_; } |
138 | 139 |
139 BrowserPluginGuest* opener() const { return opener_.get(); } | 140 // Returns the BrowserPluginGuest that created this guest, if any. |
| 141 BrowserPluginGuest* GetOpener() const; |
140 | 142 |
141 // Returns whether the mouse pointer was unlocked. | 143 // Returns whether the mouse pointer was unlocked. |
142 bool UnlockMouseIfNecessary(const NativeWebKeyboardEvent& event); | 144 bool UnlockMouseIfNecessary(const NativeWebKeyboardEvent& event); |
143 | 145 |
144 void UpdateVisibility(); | 146 void UpdateVisibility(); |
145 | 147 |
146 void CopyFromCompositingSurface( | 148 void CopyFromCompositingSurface( |
147 gfx::Rect src_subrect, | 149 gfx::Rect src_subrect, |
148 gfx::Size dst_size, | 150 gfx::Size dst_size, |
149 const base::Callback<void(bool, const SkBitmap&)>& callback); | 151 const base::Callback<void(bool, const SkBitmap&)>& callback); |
150 | 152 |
| 153 BrowserPluginGuestManager* GetBrowserPluginGuestManager() const; |
| 154 |
151 // WebContentsObserver implementation. | 155 // WebContentsObserver implementation. |
152 virtual void DidCommitProvisionalLoadForFrame( | 156 virtual void DidCommitProvisionalLoadForFrame( |
153 int64 frame_id, | 157 int64 frame_id, |
154 const base::string16& frame_unique_name, | 158 const base::string16& frame_unique_name, |
155 bool is_main_frame, | 159 bool is_main_frame, |
156 const GURL& url, | 160 const GURL& url, |
157 PageTransition transition_type, | 161 PageTransition transition_type, |
158 RenderViewHost* render_view_host) OVERRIDE; | 162 RenderViewHost* render_view_host) OVERRIDE; |
159 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; | 163 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; |
160 | 164 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; | 217 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; |
214 virtual void RequestMediaAccessPermission( | 218 virtual void RequestMediaAccessPermission( |
215 WebContents* web_contents, | 219 WebContents* web_contents, |
216 const MediaStreamRequest& request, | 220 const MediaStreamRequest& request, |
217 const MediaResponseCallback& callback) OVERRIDE; | 221 const MediaResponseCallback& callback) OVERRIDE; |
218 virtual bool PreHandleGestureEvent( | 222 virtual bool PreHandleGestureEvent( |
219 content::WebContents* source, | 223 content::WebContents* source, |
220 const blink::WebGestureEvent& event) OVERRIDE; | 224 const blink::WebGestureEvent& event) OVERRIDE; |
221 | 225 |
222 // Exposes the protected web_contents() from WebContentsObserver. | 226 // Exposes the protected web_contents() from WebContentsObserver. |
223 WebContentsImpl* GetWebContents(); | 227 WebContentsImpl* GetWebContents() const; |
224 | 228 |
225 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 229 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
226 | 230 |
227 // Helper to send messages to embedder. This methods fills the message with | 231 // Helper to send messages to embedder. This methods fills the message with |
228 // the correct routing id. | 232 // the correct routing id. |
229 // Overridden in test implementation since we want to intercept certain | 233 // Overridden in test implementation since we want to intercept certain |
230 // messages for testing. | 234 // messages for testing. |
231 virtual void SendMessageToEmbedder(IPC::Message* msg); | 235 virtual void SendMessageToEmbedder(IPC::Message* msg); |
232 | 236 |
233 // Returns whether the guest is attached to an embedder. | 237 // Returns whether the guest is attached to an embedder. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 NewWindowInfo(const GURL& url, const std::string& name) : | 294 NewWindowInfo(const GURL& url, const std::string& name) : |
291 changed(false), | 295 changed(false), |
292 url(url), | 296 url(url), |
293 name(name) {} | 297 name(name) {} |
294 }; | 298 }; |
295 | 299 |
296 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 300 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and |
297 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 301 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. |
298 BrowserPluginGuest(int instance_id, | 302 BrowserPluginGuest(int instance_id, |
299 bool has_render_view, | 303 bool has_render_view, |
300 WebContentsImpl* web_contents, | 304 WebContentsImpl* web_contents); |
301 BrowserPluginGuest* opener); | |
302 | 305 |
303 // Destroy unattached new windows that have been opened by this | 306 // Destroy unattached new windows that have been opened by this |
304 // BrowserPluginGuest. | 307 // BrowserPluginGuest. |
305 void DestroyUnattachedWindows(); | 308 void DestroyUnattachedWindows(); |
306 | 309 |
307 void LoadURLWithParams(const GURL& url, | 310 void LoadURLWithParams(const GURL& url, |
308 const Referrer& referrer, | 311 const Referrer& referrer, |
309 PageTransition transition_type, | 312 PageTransition transition_type, |
310 WebContents* web_contents); | 313 WebContents* web_contents); |
311 | 314 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 484 |
482 // Each copy-request is identified by a unique number. The unique number is | 485 // Each copy-request is identified by a unique number. The unique number is |
483 // used to keep track of the right callback. | 486 // used to keep track of the right callback. |
484 int copy_request_id_; | 487 int copy_request_id_; |
485 typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback; | 488 typedef base::Callback<void(bool, const SkBitmap&)> CopyRequestCallback; |
486 typedef std::map<int, const CopyRequestCallback> CopyRequestMap; | 489 typedef std::map<int, const CopyRequestCallback> CopyRequestMap; |
487 CopyRequestMap copy_request_callbacks_; | 490 CopyRequestMap copy_request_callbacks_; |
488 | 491 |
489 typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap; | 492 typedef std::map<BrowserPluginGuest*, NewWindowInfo> PendingWindowMap; |
490 PendingWindowMap pending_new_windows_; | 493 PendingWindowMap pending_new_windows_; |
491 base::WeakPtr<BrowserPluginGuest> opener_; | |
492 // A counter to generate a unique request id for a permission request. | 494 // A counter to generate a unique request id for a permission request. |
493 // We only need the ids to be unique for a given BrowserPluginGuest. | 495 // We only need the ids to be unique for a given BrowserPluginGuest. |
494 int next_permission_request_id_; | 496 int next_permission_request_id_; |
495 | 497 |
496 // A map to store relevant info for a request keyed by the request's id. | 498 // A map to store relevant info for a request keyed by the request's id. |
497 typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap; | 499 typedef std::map<int, scoped_refptr<PermissionRequest> > RequestMap; |
498 RequestMap permission_request_map_; | 500 RequestMap permission_request_map_; |
499 | 501 |
500 // Indicates that this BrowserPluginGuest has associated renderer-side state. | 502 // Indicates that this BrowserPluginGuest has associated renderer-side state. |
501 // This is used to determine whether or not to create a new RenderView when | 503 // This is used to determine whether or not to create a new RenderView when |
(...skipping 25 matching lines...) Expand all Loading... |
527 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 529 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
528 // permission. | 530 // permission. |
529 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 531 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
530 | 532 |
531 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 533 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
532 }; | 534 }; |
533 | 535 |
534 } // namespace content | 536 } // namespace content |
535 | 537 |
536 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 538 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |