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: Address comments from fsamuel@ 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 // Allow the embedder to call this for unhandled messages when 179 // Allow the embedder to call this for unhandled messages when
174 // BrowserPluginGuest is already destroyed. 180 // BrowserPluginGuest is already destroyed.
175 static void AcknowledgeBufferPresent(int route_id, 181 static void AcknowledgeBufferPresent(int route_id,
176 int gpu_host_id, 182 int gpu_host_id,
177 const std::string& mailbox_name, 183 const std::string& mailbox_name,
178 uint32 sync_point); 184 uint32 sync_point);
179 185
180 private: 186 private:
187 typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
188 MediaStreamRequestAndCallbackPair;
189 typedef std::map<int, MediaStreamRequestAndCallbackPair>
190 MediaStreamRequestsMap;
191
181 friend class TestBrowserPluginGuest; 192 friend class TestBrowserPluginGuest;
182 193
183 BrowserPluginGuest(int instance_id, 194 BrowserPluginGuest(int instance_id,
184 WebContentsImpl* web_contents, 195 WebContentsImpl* web_contents,
185 const BrowserPluginHostMsg_CreateGuest_Params& params); 196 const BrowserPluginHostMsg_CreateGuest_Params& params);
186 197
187 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } 198 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); }
188 const gfx::Size& damage_view_size() const { return damage_view_size_; } 199 const gfx::Size& damage_view_size() const { return damage_view_size_; }
189 float damage_buffer_scale_factor() const { 200 float damage_buffer_scale_factor() const {
190 return damage_buffer_scale_factor_; 201 return damage_buffer_scale_factor_;
191 } 202 }
192 // Returns the damage buffer corresponding to the handle in resize |params|. 203 // Returns the damage buffer corresponding to the handle in resize |params|.
193 base::SharedMemory* GetDamageBufferFromEmbedder( 204 base::SharedMemory* GetDamageBufferFromEmbedder(
194 const BrowserPluginHostMsg_ResizeGuest_Params& params); 205 const BrowserPluginHostMsg_ResizeGuest_Params& params);
195 206
196 // Called when a redirect notification occurs. 207 // Called when a redirect notification occurs.
197 void LoadRedirect(const GURL& old_url, 208 void LoadRedirect(const GURL& old_url,
198 const GURL& new_url, 209 const GURL& new_url,
199 bool is_top_level); 210 bool is_top_level);
200 211
201 bool InAutoSizeBounds(const gfx::Size& size) const; 212 bool InAutoSizeBounds(const gfx::Size& size) const;
202 213
203 // Message handlers for messsages from embedder. 214 // Message handlers for messsages from embedder.
204 215
216 // Allows or denies a permission request access, after the embedder has had a
217 // chance to decide.
218 void OnAllowPermission(int instance_id,
219 const std::string& permission_type,
220 int request_id,
221 bool should_allow);
205 // Handles drag events from the embedder. 222 // Handles drag events from the embedder.
206 // When dragging, the drag events go to the embedder first, and if the drag 223 // When dragging, the drag events go to the embedder first, and if the drag
207 // happens on the browser plugin, then the plugin sends a corresponding 224 // happens on the browser plugin, then the plugin sends a corresponding
208 // drag-message to the guest. This routes the drag-message to the guest 225 // drag-message to the guest. This routes the drag-message to the guest
209 // renderer. 226 // renderer.
210 void OnDragStatusUpdate(int instance_id, 227 void OnDragStatusUpdate(int instance_id,
211 WebKit::WebDragStatus drag_status, 228 WebKit::WebDragStatus drag_status,
212 const WebDropData& drop_data, 229 const WebDropData& drop_data,
213 WebKit::WebDragOperationsMask drag_mask, 230 WebKit::WebDragOperationsMask drag_mask,
214 const gfx::Point& location); 231 const gfx::Point& location);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 gfx::Rect guest_window_rect_; 327 gfx::Rect guest_window_rect_;
311 gfx::Rect guest_screen_rect_; 328 gfx::Rect guest_screen_rect_;
312 base::TimeDelta guest_hang_timeout_; 329 base::TimeDelta guest_hang_timeout_;
313 bool focused_; 330 bool focused_;
314 bool visible_; 331 bool visible_;
315 std::string name_; 332 std::string name_;
316 bool auto_size_enabled_; 333 bool auto_size_enabled_;
317 gfx::Size max_auto_size_; 334 gfx::Size max_auto_size_;
318 gfx::Size min_auto_size_; 335 gfx::Size min_auto_size_;
319 336
337 // A counter to generate unique request id for a media access request.
338 // We only need the ids to be unique for a given BrowserPluginGuest.
339 int current_media_access_request_id_;
340 // A map to store WebContents's media request object and callback.
341 // We need to store these because we need a roundtrip to the embedder to know
342 // if we allow or disallow the request. The key of the map is unique only for
343 // a given BrowserPluginGuest.
344 MediaStreamRequestsMap media_requests_map_;
345
320 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 346 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
321 }; 347 };
322 348
323 } // namespace content 349 } // namespace content
324 350
325 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 351 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698