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

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

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Handle multiple listeners based on our discussion, requires 2 webkit changes. Created 8 years 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 represents the browser side of browser <--> renderer 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer
6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of
7 // browser <--> guest renderer communication. The 'guest' renderer is a 7 // browser <--> guest renderer communication. The 'guest' renderer is a
8 // <browser> tag. 8 // <browser> tag.
9 // 9 //
10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
(...skipping 20 matching lines...) Expand all
31 31
32 #include <map> 32 #include <map>
33 33
34 #include "base/compiler_specific.h" 34 #include "base/compiler_specific.h"
35 #include "base/id_map.h" 35 #include "base/id_map.h"
36 #include "base/time.h" 36 #include "base/time.h"
37 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
38 #include "content/public/browser/notification_registrar.h" 38 #include "content/public/browser/notification_registrar.h"
39 #include "content/public/browser/web_contents_delegate.h" 39 #include "content/public/browser/web_contents_delegate.h"
40 #include "content/public/browser/web_contents_observer.h" 40 #include "content/public/browser/web_contents_observer.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
43 #include "ui/gfx/rect.h" 43 #include "ui/gfx/rect.h"
44 #include "ui/surface/transport_dib.h" 44 #include "ui/surface/transport_dib.h"
45 45
46 struct BrowserPluginHostMsg_AutoSize_Params; 46 struct BrowserPluginHostMsg_AutoSize_Params;
47 struct BrowserPluginHostMsg_CreateGuest_Params; 47 struct BrowserPluginHostMsg_CreateGuest_Params;
48 struct BrowserPluginHostMsg_ResizeGuest_Params; 48 struct BrowserPluginHostMsg_ResizeGuest_Params;
49 struct ViewHostMsg_UpdateRect_Params; 49 struct ViewHostMsg_UpdateRect_Params;
50 class WebCursor; 50 class WebCursor;
51 struct WebDropData; 51 struct WebDropData;
52 52
53 namespace WebKit { 53 namespace WebKit {
54 class WebInputEvent; 54 class WebInputEvent;
55 } 55 }
56 56
57 namespace content { 57 namespace content {
58 58
59 class BrowserPluginHostFactory; 59 class BrowserPluginHostFactory;
60 class BrowserPluginEmbedder; 60 class BrowserPluginEmbedder;
61 class RenderProcessHost; 61 class RenderProcessHost;
62 struct MediaStreamRequest;
62 63
63 // A browser plugin guest provides functionality for WebContents to operate in 64 // A browser plugin guest provides functionality for WebContents to operate in
64 // the guest role and implements guest specific overrides for ViewHostMsg_* 65 // the guest role and implements guest specific overrides for ViewHostMsg_*
65 // messages. 66 // messages.
66 // 67 //
67 // BrowserPluginEmbedder is responsible for creating and destroying a guest. 68 // BrowserPluginEmbedder is responsible for creating and destroying a guest.
68 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, 69 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
69 public WebContentsDelegate, 70 public WebContentsDelegate,
70 public WebContentsObserver { 71 public WebContentsObserver {
71 public: 72 public:
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // WebContentsDelegate implementation. 133 // WebContentsDelegate implementation.
133 virtual bool CanDownload(RenderViewHost* render_view_host, 134 virtual bool CanDownload(RenderViewHost* render_view_host,
134 int request_id, 135 int request_id,
135 const std::string& request_method) OVERRIDE; 136 const std::string& request_method) OVERRIDE;
136 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 137 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
137 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 138 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
138 virtual void RendererResponsive(WebContents* source) OVERRIDE; 139 virtual void RendererResponsive(WebContents* source) OVERRIDE;
139 virtual void RunFileChooser(WebContents* web_contents, 140 virtual void RunFileChooser(WebContents* web_contents,
140 const FileChooserParams& params) OVERRIDE; 141 const FileChooserParams& params) OVERRIDE;
141 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; 142 virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
143 virtual void RequestMediaAccessPermission(
144 WebContents* web_contents,
145 const content::MediaStreamRequest* request,
146 const content::MediaResponseCallback& callback) OVERRIDE;
142 147
143 void UpdateRect(RenderViewHost* render_view_host, 148 void UpdateRect(RenderViewHost* render_view_host,
144 const ViewHostMsg_UpdateRect_Params& params); 149 const ViewHostMsg_UpdateRect_Params& params);
145 void UpdateRectACK( 150 void UpdateRectACK(
146 int message_id, 151 int message_id,
147 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params, 152 const BrowserPluginHostMsg_AutoSize_Params& auto_size_params,
148 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params); 153 const BrowserPluginHostMsg_ResizeGuest_Params& resize_guest_params);
149 // Overrides default ShowWidget message so we show them on the correct 154 // Overrides default ShowWidget message so we show them on the correct
150 // coordinates. 155 // coordinates.
151 void ShowWidget(RenderViewHost* render_view_host, 156 void ShowWidget(RenderViewHost* render_view_host,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // Exposes the protected web_contents() from WebContentsObserver. 206 // Exposes the protected web_contents() from WebContentsObserver.
202 WebContents* GetWebContents(); 207 WebContents* GetWebContents();
203 208
204 // Kill the guest process. 209 // Kill the guest process.
205 void Terminate(); 210 void Terminate();
206 211
207 // Grab the new damage buffer from the embedder, and resize the guest's 212 // Grab the new damage buffer from the embedder, and resize the guest's
208 // web contents. 213 // web contents.
209 void Resize(RenderViewHost* embedder_rvh, 214 void Resize(RenderViewHost* embedder_rvh,
210 const BrowserPluginHostMsg_ResizeGuest_Params& params); 215 const BrowserPluginHostMsg_ResizeGuest_Params& params);
216 // Allows or denies a media access request, after the embedder has had a
217 // chance to decide.
218 void AllowMediaAccess(WebContents* embedder_web_contents,
219 int request_id,
220 bool should_allow);
211 221
212 // Overridden in tests. 222 // Overridden in tests.
213 // Handles input event routed through the embedder (which is initiated in the 223 // Handles input event routed through the embedder (which is initiated in the
214 // browser plugin (renderer side of the embedder)). 224 // browser plugin (renderer side of the embedder)).
215 virtual void HandleInputEvent(RenderViewHost* render_view_host, 225 virtual void HandleInputEvent(RenderViewHost* render_view_host,
216 const gfx::Rect& guest_window_rect, 226 const gfx::Rect& guest_window_rect,
217 const gfx::Rect& guest_screen_rect, 227 const gfx::Rect& guest_screen_rect,
218 const WebKit::WebInputEvent& event); 228 const WebKit::WebInputEvent& event);
219 virtual bool ViewTakeFocus(bool reverse); 229 virtual bool ViewTakeFocus(bool reverse);
220 // If possible, navigate the guest to |relative_index| entries away from the 230 // If possible, navigate the guest to |relative_index| entries away from the
(...skipping 17 matching lines...) Expand all
238 virtual void SetCompositingBufferData(int gpu_process_id, 248 virtual void SetCompositingBufferData(int gpu_process_id,
239 uint32 client_id, 249 uint32 client_id,
240 uint32 context_id, 250 uint32 context_id,
241 uint32 texture_id_0, 251 uint32 texture_id_0,
242 uint32 texture_id_1, 252 uint32 texture_id_1,
243 uint32 sync_point); 253 uint32 sync_point);
244 254
245 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; 255 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
246 256
247 private: 257 private:
258 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
259 MediaStreamRequestAndCallbackPair;
260 typedef std::map<int, MediaStreamRequestAndCallbackPair>
261 MediaStreamRequestsMap;
262
248 friend class TestBrowserPluginGuest; 263 friend class TestBrowserPluginGuest;
249 264
250 BrowserPluginGuest(int instance_id, 265 BrowserPluginGuest(int instance_id,
251 WebContentsImpl* web_contents, 266 WebContentsImpl* web_contents,
252 const BrowserPluginHostMsg_CreateGuest_Params& params); 267 const BrowserPluginHostMsg_CreateGuest_Params& params);
253 268
254 // Returns the identifier that uniquely identifies a browser plugin guest 269 // Returns the identifier that uniquely identifies a browser plugin guest
255 // within an embedder. 270 // within an embedder.
256 int instance_id() const { return instance_id_; } 271 int instance_id() const { return instance_id_; }
257 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } 272 TransportDIB* damage_buffer() const { return damage_buffer_.get(); }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 gfx::Rect guest_window_rect_; 310 gfx::Rect guest_window_rect_;
296 gfx::Rect guest_screen_rect_; 311 gfx::Rect guest_screen_rect_;
297 IDMap<RenderViewHost> pending_updates_; 312 IDMap<RenderViewHost> pending_updates_;
298 int pending_update_counter_; 313 int pending_update_counter_;
299 base::TimeDelta guest_hang_timeout_; 314 base::TimeDelta guest_hang_timeout_;
300 bool focused_; 315 bool focused_;
301 bool visible_; 316 bool visible_;
302 bool auto_size_enabled_; 317 bool auto_size_enabled_;
303 gfx::Size max_auto_size_; 318 gfx::Size max_auto_size_;
304 gfx::Size min_auto_size_; 319 gfx::Size min_auto_size_;
320 // A counter to generate unique request id for a media access request.
321 // We only need the ids to be unique for a given BrowserPluginGuest.
322 int current_media_access_request_id_;
323 // A map to store WebContents's media request object and callback.
324 // We need to store these because we need a roundtrip to the embedder to know
325 // if we allow or disallow the request. The key of the map is unique only for
326 // a given BrowserPluginGuest.
327 MediaStreamRequestsMap media_requests_map_;
305 328
306 // Hardware Accelerated Surface Params 329 // Hardware Accelerated Surface Params
307 gfx::GLSurfaceHandle surface_handle_; 330 gfx::GLSurfaceHandle surface_handle_;
308 331
309 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 332 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
310 }; 333 };
311 334
312 } // namespace content 335 } // namespace content
313 336
314 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 337 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698