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

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: Address comments from fsamuel@ Created 8 years, 2 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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 namespace WebKit { 47 namespace WebKit {
48 class WebInputEvent; 48 class WebInputEvent;
49 } 49 }
50 50
51 namespace content { 51 namespace content {
52 52
53 class BrowserPluginHostFactory; 53 class BrowserPluginHostFactory;
54 class BrowserPluginEmbedder; 54 class BrowserPluginEmbedder;
55 class RenderProcessHost; 55 class RenderProcessHost;
56 struct MediaStreamRequest;
56 57
57 // A browser plugin guest provides functionality for WebContents to operate in 58 // A browser plugin guest provides functionality for WebContents to operate in
58 // the guest role and implements guest specific overrides for ViewHostMsg_* 59 // the guest role and implements guest specific overrides for ViewHostMsg_*
59 // messages. 60 // messages.
60 // 61 //
61 // BrowserPluginEmbedder is responsible for creating and destroying a guest. 62 // BrowserPluginEmbedder is responsible for creating and destroying a guest.
62 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, 63 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
63 public WebContentsDelegate, 64 public WebContentsDelegate,
64 public WebContentsObserver { 65 public WebContentsObserver {
65 public: 66 public:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 PageTransition transition_type, 113 PageTransition transition_type,
113 RenderViewHost* render_view_host) OVERRIDE; 114 RenderViewHost* render_view_host) OVERRIDE;
114 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 115 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
115 116
116 // WebContentsDelegate implementation. 117 // WebContentsDelegate implementation.
117 virtual bool CanDownload(RenderViewHost* render_view_host, 118 virtual bool CanDownload(RenderViewHost* render_view_host,
118 int request_id, 119 int request_id,
119 const std::string& request_method) OVERRIDE; 120 const std::string& request_method) OVERRIDE;
120 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 121 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
121 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 122 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
123 virtual void RequestMediaAccessPermission(
124 WebContents* web_contents,
125 const content::MediaStreamRequest* request,
126 const content::MediaResponseCallback& callback) OVERRIDE;
122 127
123 void UpdateRect(RenderViewHost* render_view_host, 128 void UpdateRect(RenderViewHost* render_view_host,
124 const ViewHostMsg_UpdateRect_Params& params); 129 const ViewHostMsg_UpdateRect_Params& params);
125 void UpdateRectACK(int message_id, const gfx::Size& size); 130 void UpdateRectACK(int message_id, const gfx::Size& size);
126 // Handles input event routed through the embedder (which is initiated in the 131 // Handles input event routed through the embedder (which is initiated in the
127 // browser plugin (renderer side of the embedder)). 132 // browser plugin (renderer side of the embedder)).
128 void HandleInputEvent(RenderViewHost* render_view_host, 133 void HandleInputEvent(RenderViewHost* render_view_host,
129 const gfx::Rect& guest_rect, 134 const gfx::Rect& guest_rect,
130 const WebKit::WebInputEvent& event, 135 const WebKit::WebInputEvent& event,
131 IPC::Message* reply_message); 136 IPC::Message* reply_message);
(...skipping 27 matching lines...) Expand all
159 // See RenderThreadImpl::IdleHandler (executed when hidden) and 164 // See RenderThreadImpl::IdleHandler (executed when hidden) and
160 // RenderThreadImpl::IdleHandlerInForegroundTab (executed when visible). 165 // RenderThreadImpl::IdleHandlerInForegroundTab (executed when visible).
161 void SetVisibility(bool embedder_visible, bool visible); 166 void SetVisibility(bool embedder_visible, bool visible);
162 167
163 // Exposes the protected web_contents() from WebContentsObserver. 168 // Exposes the protected web_contents() from WebContentsObserver.
164 WebContents* GetWebContents(); 169 WebContents* GetWebContents();
165 170
166 // Kill the guest process. 171 // Kill the guest process.
167 void Terminate(); 172 void Terminate();
168 173
174 // Allows or denies media access request.
Charlie Reis 2012/10/17 06:18:45 nit: Allows or denies a media access request, afte
lazyboy 2012/10/17 09:09:53 Done.
175 void AllowMediaAccess(WebContents* embedder_web_contents,
176 int request_id,
177 bool allow);
Charlie Reis 2012/10/17 06:18:45 nit: should_allow
lazyboy 2012/10/17 09:09:53 Done.
178
169 // Overridden in tests. 179 // Overridden in tests.
170 virtual bool ViewTakeFocus(bool reverse); 180 virtual bool ViewTakeFocus(bool reverse);
171 // If possible, navigate the guest to |relative_index| entries away from the 181 // If possible, navigate the guest to |relative_index| entries away from the
172 // current navigation entry. 182 // current navigation entry.
173 virtual void Go(int relative_index); 183 virtual void Go(int relative_index);
174 // Overridden in tests. 184 // Overridden in tests.
175 virtual void SetFocus(bool focused); 185 virtual void SetFocus(bool focused);
176 // Reload the guest. 186 // Reload the guest.
177 virtual void Reload(); 187 virtual void Reload();
178 // Stop loading the guest. 188 // Stop loading the guest.
179 virtual void Stop(); 189 virtual void Stop();
180 // Overridden in tests. 190 // Overridden in tests.
181 virtual void SetDamageBuffer(TransportDIB* damage_buffer, 191 virtual void SetDamageBuffer(TransportDIB* damage_buffer,
182 #if defined(OS_WIN) 192 #if defined(OS_WIN)
183 int damage_buffer_size, 193 int damage_buffer_size,
184 #endif 194 #endif
185 const gfx::Size& damage_view_size, 195 const gfx::Size& damage_view_size,
186 float scale_factor); 196 float scale_factor);
187 197
188 private: 198 private:
199 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
200 MediaStreamRequestAndCallbackPair;
201 typedef std::map<int, MediaStreamRequestAndCallbackPair>
202 MediaStreamRequestsMap;
203
189 friend class TestBrowserPluginGuest; 204 friend class TestBrowserPluginGuest;
190 205
191 BrowserPluginGuest(int instance_id, 206 BrowserPluginGuest(int instance_id,
192 WebContentsImpl* web_contents, 207 WebContentsImpl* web_contents,
193 RenderViewHost* render_view_host); 208 RenderViewHost* render_view_host);
194 209
195 RenderProcessHost* embedder_render_process_host() { 210 RenderProcessHost* embedder_render_process_host() {
196 return embedder_render_process_host_; 211 return embedder_render_process_host_;
197 } 212 }
198 // Returns the identifier that uniquely identifies a browser plugin guest 213 // Returns the identifier that uniquely identifies a browser plugin guest
(...skipping 28 matching lines...) Expand all
227 #endif 242 #endif
228 gfx::Size damage_view_size_; 243 gfx::Size damage_view_size_;
229 float damage_buffer_scale_factor_; 244 float damage_buffer_scale_factor_;
230 scoped_ptr<IPC::Message> pending_input_event_reply_; 245 scoped_ptr<IPC::Message> pending_input_event_reply_;
231 gfx::Rect guest_rect_; 246 gfx::Rect guest_rect_;
232 WebCursor cursor_; 247 WebCursor cursor_;
233 IDMap<RenderViewHost> pending_updates_; 248 IDMap<RenderViewHost> pending_updates_;
234 int pending_update_counter_; 249 int pending_update_counter_;
235 base::TimeDelta guest_hang_timeout_; 250 base::TimeDelta guest_hang_timeout_;
236 bool visible_; 251 bool visible_;
252 // A map to store WebContents's media request object and callback.
253 // We need to store these because we need a roundtrip to the embedder to know
254 // if we allow or disallow the request. The key of the map is unique only for
255 // a given BrowserPluginGuest.
256 MediaStreamRequestsMap media_requests_map_;
237 257
238 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 258 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
239 }; 259 };
240 260
241 } // namespace content 261 } // namespace content
242 262
243 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 263 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698