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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 161 |
162 // If a new window is created with target="_blank" and rel="noreferrer", then | 162 // If a new window is created with target="_blank" and rel="noreferrer", then |
163 // this method is called, indicating that the new WebContents is ready to be | 163 // this method is called, indicating that the new WebContents is ready to be |
164 // attached. | 164 // attached. |
165 virtual void AddNewContents(WebContents* source, | 165 virtual void AddNewContents(WebContents* source, |
166 WebContents* new_contents, | 166 WebContents* new_contents, |
167 WindowOpenDisposition disposition, | 167 WindowOpenDisposition disposition, |
168 const gfx::Rect& initial_pos, | 168 const gfx::Rect& initial_pos, |
169 bool user_gesture, | 169 bool user_gesture, |
170 bool* was_blocked) OVERRIDE; | 170 bool* was_blocked) OVERRIDE; |
171 virtual bool CanDownload(RenderViewHost* render_view_host, | 171 virtual void CanDownload(RenderViewHost* render_view_host, |
172 int request_id, | 172 int request_id, |
173 const std::string& request_method) OVERRIDE; | 173 const std::string& request_method, |
| 174 const base::Callback<void(bool)>& callback) OVERRIDE; |
174 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; | 175 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; |
175 virtual void WebContentsCreated(WebContents* source_contents, | 176 virtual void WebContentsCreated(WebContents* source_contents, |
176 int64 source_frame_id, | 177 int64 source_frame_id, |
177 const string16& frame_name, | 178 const string16& frame_name, |
178 const GURL& target_url, | 179 const GURL& target_url, |
179 WebContents* new_contents) OVERRIDE; | 180 WebContents* new_contents) OVERRIDE; |
180 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; | 181 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; |
181 virtual void RendererResponsive(WebContents* source) OVERRIDE; | 182 virtual void RendererResponsive(WebContents* source) OVERRIDE; |
182 virtual void RunFileChooser(WebContents* web_contents, | 183 virtual void RunFileChooser(WebContents* web_contents, |
183 const FileChooserParams& params) OVERRIDE; | 184 const FileChooserParams& params) OVERRIDE; |
(...skipping 24 matching lines...) Expand all Loading... |
208 // Returns whether the guest is attached to an embedder. | 209 // Returns whether the guest is attached to an embedder. |
209 bool attached() const { return !!embedder_web_contents_; } | 210 bool attached() const { return !!embedder_web_contents_; } |
210 | 211 |
211 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| | 212 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| |
212 // and initializes the guest with the provided |params|. Attaching a guest | 213 // and initializes the guest with the provided |params|. Attaching a guest |
213 // to an embedder implies that this guest's lifetime is no longer managed | 214 // to an embedder implies that this guest's lifetime is no longer managed |
214 // by its opener, and it can begin loading resources. | 215 // by its opener, and it can begin loading resources. |
215 void Attach(WebContentsImpl* embedder_web_contents, | 216 void Attach(WebContentsImpl* embedder_web_contents, |
216 BrowserPluginHostMsg_CreateGuest_Params params); | 217 BrowserPluginHostMsg_CreateGuest_Params params); |
217 | 218 |
218 // Requests geolocation permission through embedder js api. | 219 // Requests geolocation permission through Embedder JavaScript API. |
219 void AskEmbedderForGeolocationPermission(int bridge_id, | 220 void AskEmbedderForGeolocationPermission(int bridge_id, |
220 const GURL& requesting_frame, | 221 const GURL& requesting_frame, |
221 const GeolocationCallback& callback); | 222 const GeolocationCallback& callback); |
222 // Cancels pending geolocation request. | 223 // Cancels pending geolocation request. |
223 void CancelGeolocationRequest(int bridge_id); | 224 void CancelGeolocationRequest(int bridge_id); |
224 // Embedder sets permission to allow or deny geolocation request. | 225 // Embedder sets permission to allow or deny geolocation request. |
225 void SetGeolocationPermission(int request_id, bool allowed); | 226 void SetGeolocationPermission(int request_id, bool allowed); |
226 | 227 |
| 228 |
227 // Allow the embedder to call this for unhandled messages when | 229 // Allow the embedder to call this for unhandled messages when |
228 // BrowserPluginGuest is already destroyed. | 230 // BrowserPluginGuest is already destroyed. |
229 static void AcknowledgeBufferPresent(int route_id, | 231 static void AcknowledgeBufferPresent(int route_id, |
230 int gpu_host_id, | 232 int gpu_host_id, |
231 const std::string& mailbox_name, | 233 const std::string& mailbox_name, |
232 uint32 sync_point); | 234 uint32 sync_point); |
233 | 235 |
234 // Returns whether BrowserPluginGuest is interested in receiving the given | 236 // Returns whether BrowserPluginGuest is interested in receiving the given |
235 // |message|. | 237 // |message|. |
236 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); | 238 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); | 374 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); |
373 // Overriden in tests. | 375 // Overriden in tests. |
374 virtual void OnTakeFocus(bool reverse); | 376 virtual void OnTakeFocus(bool reverse); |
375 void OnUpdateDragCursor(WebKit::WebDragOperation operation); | 377 void OnUpdateDragCursor(WebKit::WebDragOperation operation); |
376 void OnUpdateFrameName(int frame_id, | 378 void OnUpdateFrameName(int frame_id, |
377 bool is_top_level, | 379 bool is_top_level, |
378 const std::string& name); | 380 const std::string& name); |
379 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); | 381 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); |
380 | 382 |
381 // Helpers for |OnRespondPermission|. | 383 // Helpers for |OnRespondPermission|. |
| 384 void OnRespondPermissionDownload(int request_id, bool should_allow); |
382 void OnRespondPermissionGeolocation(int request_id, bool should_allow); | 385 void OnRespondPermissionGeolocation(int request_id, bool should_allow); |
383 void OnRespondPermissionMedia(int request_id, bool should_allow); | 386 void OnRespondPermissionMedia(int request_id, bool should_allow); |
384 void OnRespondPermissionNewWindow(int request_id, bool should_allow); | 387 void OnRespondPermissionNewWindow(int request_id, bool should_allow); |
385 | 388 |
| 389 // Requests download permission through embedder JavaScript API after |
| 390 // retrieving url information from IO thread. |
| 391 void DidRetrieveDownloadURLFromRequestId(const std::string& request_method, |
| 392 int permission_request_id, |
| 393 const std::string& url); |
| 394 |
386 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 395 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
387 // permission. | 396 // permission. |
388 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 397 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
389 | 398 |
390 // Static factory instance (always NULL for non-test). | 399 // Static factory instance (always NULL for non-test). |
391 static BrowserPluginHostFactory* factory_; | 400 static BrowserPluginHostFactory* factory_; |
392 | 401 |
393 NotificationRegistrar notification_registrar_; | 402 NotificationRegistrar notification_registrar_; |
394 scoped_ptr<EmbedderRenderViewHostObserver> embedder_rvh_observer_; | 403 scoped_ptr<EmbedderRenderViewHostObserver> embedder_rvh_observer_; |
395 WebContentsImpl* embedder_web_contents_; | 404 WebContentsImpl* embedder_web_contents_; |
(...skipping 29 matching lines...) Expand all Loading... |
425 int next_permission_request_id_; | 434 int next_permission_request_id_; |
426 // A map to store WebContents's media request object and callback. | 435 // A map to store WebContents's media request object and callback. |
427 // We need to store these because we need a roundtrip to the embedder to know | 436 // We need to store these because we need a roundtrip to the embedder to know |
428 // if we allow or disallow the request. The key of the map is unique only for | 437 // if we allow or disallow the request. The key of the map is unique only for |
429 // a given BrowserPluginGuest. | 438 // a given BrowserPluginGuest. |
430 MediaStreamRequestsMap media_requests_map_; | 439 MediaStreamRequestsMap media_requests_map_; |
431 // A map from request ID to instance ID for use by the New Window API. | 440 // A map from request ID to instance ID for use by the New Window API. |
432 typedef std::map<int, int> NewWindowRequestMap; | 441 typedef std::map<int, int> NewWindowRequestMap; |
433 NewWindowRequestMap new_window_request_map_; | 442 NewWindowRequestMap new_window_request_map_; |
434 | 443 |
| 444 typedef std::map<int, base::Callback<void(bool)> > DownloadRequestMap; |
| 445 DownloadRequestMap download_request_callback_map_; |
| 446 |
435 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 447 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
436 }; | 448 }; |
437 | 449 |
438 } // namespace content | 450 } // namespace content |
439 | 451 |
440 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 452 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |