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

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: Remove hanging request on garbage collection, yay! Created 7 years, 10 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 namespace WebKit { 52 namespace WebKit {
53 class WebInputEvent; 53 class WebInputEvent;
54 } 54 }
55 55
56 namespace content { 56 namespace content {
57 57
58 class BrowserPluginHostFactory; 58 class BrowserPluginHostFactory;
59 class BrowserPluginEmbedder; 59 class BrowserPluginEmbedder;
60 class RenderProcessHost; 60 class RenderProcessHost;
61 struct MediaStreamRequest;
61 62
62 // A browser plugin guest provides functionality for WebContents to operate in 63 // A browser plugin guest provides functionality for WebContents to operate in
63 // the guest role and implements guest specific overrides for ViewHostMsg_* 64 // the guest role and implements guest specific overrides for ViewHostMsg_*
64 // messages. 65 // messages.
65 // 66 //
66 // BrowserPluginEmbedder is responsible for creating and destroying a guest. 67 // BrowserPluginEmbedder is responsible for creating and destroying a guest.
67 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, 68 class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
68 public WebContentsDelegate, 69 public WebContentsDelegate,
69 public WebContentsObserver { 70 public WebContentsObserver {
70 public: 71 public:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // WebContentsDelegate implementation. 141 // WebContentsDelegate implementation.
141 virtual bool CanDownload(RenderViewHost* render_view_host, 142 virtual bool CanDownload(RenderViewHost* render_view_host,
142 int request_id, 143 int request_id,
143 const std::string& request_method) OVERRIDE; 144 const std::string& request_method) OVERRIDE;
144 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 145 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
145 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 146 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
146 virtual void RendererResponsive(WebContents* source) OVERRIDE; 147 virtual void RendererResponsive(WebContents* source) OVERRIDE;
147 virtual void RunFileChooser(WebContents* web_contents, 148 virtual void RunFileChooser(WebContents* web_contents,
148 const FileChooserParams& params) OVERRIDE; 149 const FileChooserParams& params) OVERRIDE;
149 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; 150 virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
151 virtual void RequestMediaAccessPermission(
152 WebContents* web_contents,
153 const content::MediaStreamRequest& request,
154 const content::MediaResponseCallback& callback) OVERRIDE;
150 155
151 // Exposes the protected web_contents() from WebContentsObserver. 156 // Exposes the protected web_contents() from WebContentsObserver.
152 WebContents* GetWebContents(); 157 WebContents* GetWebContents();
153 158
154 // Kill the guest process. 159 // Kill the guest process.
155 void Terminate(); 160 void Terminate();
156 161
162
157 // Overridden in tests. 163 // Overridden in tests.
158 virtual void SetDamageBuffer( 164 virtual void SetDamageBuffer(
159 const BrowserPluginHostMsg_ResizeGuest_Params& params); 165 const BrowserPluginHostMsg_ResizeGuest_Params& params);
160 166
161 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; 167 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
162 168
163 // Helper to send messages to embedder. Overridden in test implementation 169 // Helper to send messages to embedder. Overridden in test implementation
164 // since we want to intercept certain messages for testing. 170 // since we want to intercept certain messages for testing.
165 virtual void SendMessageToEmbedder(IPC::Message* msg); 171 virtual void SendMessageToEmbedder(IPC::Message* msg);
166 172
167 // Returns the embedder's routing ID. 173 // Returns the embedder's routing ID.
168 int embedder_routing_id() const; 174 int embedder_routing_id() const;
169 // Returns the identifier that uniquely identifies a browser plugin guest 175 // Returns the identifier that uniquely identifies a browser plugin guest
170 // within an embedder. 176 // within an embedder.
171 int instance_id() const { return instance_id_; } 177 int instance_id() const { return instance_id_; }
172 178
173 private: 179 private:
180 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
181 MediaStreamRequestAndCallbackPair;
182 typedef std::map<int, MediaStreamRequestAndCallbackPair>
183 MediaStreamRequestsMap;
184
174 friend class TestBrowserPluginGuest; 185 friend class TestBrowserPluginGuest;
175 186
176 BrowserPluginGuest(int instance_id, 187 BrowserPluginGuest(int instance_id,
177 WebContentsImpl* web_contents, 188 WebContentsImpl* web_contents,
178 const BrowserPluginHostMsg_CreateGuest_Params& params); 189 const BrowserPluginHostMsg_CreateGuest_Params& params);
179 190
180 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } 191 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); }
181 const gfx::Size& damage_view_size() const { return damage_view_size_; } 192 const gfx::Size& damage_view_size() const { return damage_view_size_; }
182 float damage_buffer_scale_factor() const { 193 float damage_buffer_scale_factor() const {
183 return damage_buffer_scale_factor_; 194 return damage_buffer_scale_factor_;
184 } 195 }
185 // Returns the damage buffer corresponding to the handle in resize |params|. 196 // Returns the damage buffer corresponding to the handle in resize |params|.
186 base::SharedMemory* GetDamageBufferFromEmbedder( 197 base::SharedMemory* GetDamageBufferFromEmbedder(
187 const BrowserPluginHostMsg_ResizeGuest_Params& params); 198 const BrowserPluginHostMsg_ResizeGuest_Params& params);
188 199
189 // Called when a redirect notification occurs. 200 // Called when a redirect notification occurs.
190 void LoadRedirect(const GURL& old_url, 201 void LoadRedirect(const GURL& old_url,
191 const GURL& new_url, 202 const GURL& new_url,
192 bool is_top_level); 203 bool is_top_level);
193 204
194 bool InAutoSizeBounds(const gfx::Size& size) const; 205 bool InAutoSizeBounds(const gfx::Size& size) const;
195 206
196 // Message handlers for messsages from embedder. 207 // Message handlers for messsages from embedder.
197 208
209 // Allows or denies a media access request, after the embedder has had a
210 // chance to decide.
211 void OnAllowMediaAccess(int instance_id, int request_id, bool should_allow);
198 // Handles drag events from the embedder. 212 // Handles drag events from the embedder.
199 // When dragging, the drag events go to the embedder first, and if the drag 213 // When dragging, the drag events go to the embedder first, and if the drag
200 // happens on the browser plugin, then the plugin sends a corresponding 214 // happens on the browser plugin, then the plugin sends a corresponding
201 // drag-message to the guest. This routes the drag-message to the guest 215 // drag-message to the guest. This routes the drag-message to the guest
202 // renderer. 216 // renderer.
203 void OnDragStatusUpdate(int instance_id, 217 void OnDragStatusUpdate(int instance_id,
204 WebKit::WebDragStatus drag_status, 218 WebKit::WebDragStatus drag_status,
205 const WebDropData& drop_data, 219 const WebDropData& drop_data,
206 WebKit::WebDragOperationsMask drag_mask, 220 WebKit::WebDragOperationsMask drag_mask,
207 const gfx::Point& location); 221 const gfx::Point& location);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 gfx::Rect guest_window_rect_; 310 gfx::Rect guest_window_rect_;
297 gfx::Rect guest_screen_rect_; 311 gfx::Rect guest_screen_rect_;
298 base::TimeDelta guest_hang_timeout_; 312 base::TimeDelta guest_hang_timeout_;
299 bool focused_; 313 bool focused_;
300 bool visible_; 314 bool visible_;
301 std::string name_; 315 std::string name_;
302 bool auto_size_enabled_; 316 bool auto_size_enabled_;
303 gfx::Size max_auto_size_; 317 gfx::Size max_auto_size_;
304 gfx::Size min_auto_size_; 318 gfx::Size min_auto_size_;
305 319
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_;
328
306 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 329 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
307 }; 330 };
308 331
309 } // namespace content 332 } // namespace content
310 333
311 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 334 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698