Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.h

Issue 13037003: permissionrequest API for guest Download. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync @tott Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 165
166 // If a new window is created with target="_blank" and rel="noreferrer", then 166 // If a new window is created with target="_blank" and rel="noreferrer", then
167 // this method is called, indicating that the new WebContents is ready to be 167 // this method is called, indicating that the new WebContents is ready to be
168 // attached. 168 // attached.
169 virtual void AddNewContents(WebContents* source, 169 virtual void AddNewContents(WebContents* source,
170 WebContents* new_contents, 170 WebContents* new_contents,
171 WindowOpenDisposition disposition, 171 WindowOpenDisposition disposition,
172 const gfx::Rect& initial_pos, 172 const gfx::Rect& initial_pos,
173 bool user_gesture, 173 bool user_gesture,
174 bool* was_blocked) OVERRIDE; 174 bool* was_blocked) OVERRIDE;
175 virtual bool CanDownload(RenderViewHost* render_view_host, 175 virtual void CanDownload(RenderViewHost* render_view_host,
176 int request_id, 176 int request_id,
177 const std::string& request_method) OVERRIDE; 177 const std::string& request_method,
178 const base::Callback<void(bool)>& callback) OVERRIDE;
178 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 179 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
179 virtual void WebContentsCreated(WebContents* source_contents, 180 virtual void WebContentsCreated(WebContents* source_contents,
180 int64 source_frame_id, 181 int64 source_frame_id,
181 const string16& frame_name, 182 const string16& frame_name,
182 const GURL& target_url, 183 const GURL& target_url,
183 WebContents* new_contents) OVERRIDE; 184 WebContents* new_contents) OVERRIDE;
184 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 185 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
185 virtual void RendererResponsive(WebContents* source) OVERRIDE; 186 virtual void RendererResponsive(WebContents* source) OVERRIDE;
186 virtual void RunFileChooser(WebContents* web_contents, 187 virtual void RunFileChooser(WebContents* web_contents,
187 const FileChooserParams& params) OVERRIDE; 188 const FileChooserParams& params) OVERRIDE;
(...skipping 24 matching lines...) Expand all
212 // Returns whether the guest is attached to an embedder. 213 // Returns whether the guest is attached to an embedder.
213 bool attached() const { return !!embedder_web_contents_; } 214 bool attached() const { return !!embedder_web_contents_; }
214 215
215 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents| 216 // Attaches this BrowserPluginGuest to the provided |embedder_web_contents|
216 // and initializes the guest with the provided |params|. Attaching a guest 217 // and initializes the guest with the provided |params|. Attaching a guest
217 // to an embedder implies that this guest's lifetime is no longer managed 218 // to an embedder implies that this guest's lifetime is no longer managed
218 // by its opener, and it can begin loading resources. 219 // by its opener, and it can begin loading resources.
219 void Attach(WebContentsImpl* embedder_web_contents, 220 void Attach(WebContentsImpl* embedder_web_contents,
220 BrowserPluginHostMsg_CreateGuest_Params params); 221 BrowserPluginHostMsg_CreateGuest_Params params);
221 222
222 // Requests geolocation permission through embedder js api. 223 // Requests geolocation permission through Embedder JavaScript API.
223 void AskEmbedderForGeolocationPermission(int bridge_id, 224 void AskEmbedderForGeolocationPermission(int bridge_id,
224 const GURL& requesting_frame, 225 const GURL& requesting_frame,
225 const GeolocationCallback& callback); 226 const GeolocationCallback& callback);
226 // Cancels pending geolocation request. 227 // Cancels pending geolocation request.
227 void CancelGeolocationRequest(int bridge_id); 228 void CancelGeolocationRequest(int bridge_id);
228 // Embedder sets permission to allow or deny geolocation request. 229 // Embedder sets permission to allow or deny geolocation request.
229 void SetGeolocationPermission(int request_id, bool allowed); 230 void SetGeolocationPermission(int request_id, bool allowed);
230 231
232
231 // Allow the embedder to call this for unhandled messages when 233 // Allow the embedder to call this for unhandled messages when
232 // BrowserPluginGuest is already destroyed. 234 // BrowserPluginGuest is already destroyed.
233 static void AcknowledgeBufferPresent(int route_id, 235 static void AcknowledgeBufferPresent(int route_id,
234 int gpu_host_id, 236 int gpu_host_id,
235 const std::string& mailbox_name, 237 const std::string& mailbox_name,
236 uint32 sync_point); 238 uint32 sync_point);
237 239
238 // Returns whether BrowserPluginGuest is interested in receiving the given 240 // Returns whether BrowserPluginGuest is interested in receiving the given
239 // |message|. 241 // |message|.
240 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message); 242 static bool ShouldForwardToBrowserPluginGuest(const IPC::Message& message);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 void OnShowWidget(int route_id, const gfx::Rect& initial_pos); 383 void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
382 // Overriden in tests. 384 // Overriden in tests.
383 virtual void OnTakeFocus(bool reverse); 385 virtual void OnTakeFocus(bool reverse);
384 void OnUpdateDragCursor(WebKit::WebDragOperation operation); 386 void OnUpdateDragCursor(WebKit::WebDragOperation operation);
385 void OnUpdateFrameName(int frame_id, 387 void OnUpdateFrameName(int frame_id,
386 bool is_top_level, 388 bool is_top_level,
387 const std::string& name); 389 const std::string& name);
388 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params); 390 void OnUpdateRect(const ViewHostMsg_UpdateRect_Params& params);
389 391
390 // Helpers for |OnRespondPermission|. 392 // Helpers for |OnRespondPermission|.
393 void OnRespondPermissionDownload(int request_id, bool should_allow);
391 void OnRespondPermissionGeolocation(int request_id, bool should_allow); 394 void OnRespondPermissionGeolocation(int request_id, bool should_allow);
392 void OnRespondPermissionMedia(int request_id, bool should_allow); 395 void OnRespondPermissionMedia(int request_id, bool should_allow);
393 void OnRespondPermissionNewWindow(int request_id, bool should_allow); 396 void OnRespondPermissionNewWindow(int request_id, bool should_allow);
394 397
398 // Requests download permission through embedder JavaScript API after
399 // retrieving url information from IO thread.
400 void DidRetrieveDownloadURLFromRequestId(const std::string& request_method,
401 int permission_request_id,
402 const std::string& url);
403
395 // Weak pointer used to ask GeolocationPermissionContext about geolocation 404 // Weak pointer used to ask GeolocationPermissionContext about geolocation
396 // permission. 405 // permission.
397 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; 406 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
398 407
399 // Static factory instance (always NULL for non-test). 408 // Static factory instance (always NULL for non-test).
400 static BrowserPluginHostFactory* factory_; 409 static BrowserPluginHostFactory* factory_;
401 410
402 NotificationRegistrar notification_registrar_; 411 NotificationRegistrar notification_registrar_;
403 scoped_ptr<EmbedderRenderViewHostObserver> embedder_rvh_observer_; 412 scoped_ptr<EmbedderRenderViewHostObserver> embedder_rvh_observer_;
404 WebContentsImpl* embedder_web_contents_; 413 WebContentsImpl* embedder_web_contents_;
(...skipping 29 matching lines...) Expand all
434 int next_permission_request_id_; 443 int next_permission_request_id_;
435 // A map to store WebContents's media request object and callback. 444 // A map to store WebContents's media request object and callback.
436 // We need to store these because we need a roundtrip to the embedder to know 445 // We need to store these because we need a roundtrip to the embedder to know
437 // if we allow or disallow the request. The key of the map is unique only for 446 // if we allow or disallow the request. The key of the map is unique only for
438 // a given BrowserPluginGuest. 447 // a given BrowserPluginGuest.
439 MediaStreamRequestsMap media_requests_map_; 448 MediaStreamRequestsMap media_requests_map_;
440 // A map from request ID to instance ID for use by the New Window API. 449 // A map from request ID to instance ID for use by the New Window API.
441 typedef std::map<int, int> NewWindowRequestMap; 450 typedef std::map<int, int> NewWindowRequestMap;
442 NewWindowRequestMap new_window_request_map_; 451 NewWindowRequestMap new_window_request_map_;
443 452
453 typedef std::map<int, base::Callback<void(bool)> > DownloadRequestMap;
454 DownloadRequestMap download_request_callback_map_;
455
444 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 456 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
445 }; 457 };
446 458
447 } // namespace content 459 } // namespace content
448 460
449 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 461 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698