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

Unified 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: Add todo for auto deny when no listeners attached. 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_guest.h
diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h
index 662a884920e55cc823fd90aaedb9d54d6e52d361..c5a3f5125eba490dd289ba6167b479b8b865db53 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -38,8 +38,8 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h"
#include "ui/gfx/rect.h"
#include "ui/surface/transport_dib.h"
@@ -59,6 +59,7 @@ namespace content {
class BrowserPluginHostFactory;
class BrowserPluginEmbedder;
class RenderProcessHost;
+struct MediaStreamRequest;
// A browser plugin guest provides functionality for WebContents to operate in
// the guest role and implements guest specific overrides for ViewHostMsg_*
@@ -138,6 +139,10 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
virtual void RunFileChooser(WebContents* web_contents,
const FileChooserParams& params) OVERRIDE;
virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
+ virtual void RequestMediaAccessPermission(
+ WebContents* web_contents,
+ const content::MediaStreamRequest* request,
+ const content::MediaResponseCallback& callback) OVERRIDE;
void UpdateRect(RenderViewHost* render_view_host,
const ViewHostMsg_UpdateRect_Params& params);
@@ -207,6 +212,11 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
// web contents.
void Resize(RenderViewHost* embedder_rvh,
const BrowserPluginHostMsg_ResizeGuest_Params& params);
+ // Allows or denies a media access request, after the embedder has had a
+ // chance to decide.
+ void AllowMediaAccess(WebContents* embedder_web_contents,
+ int request_id,
+ bool should_allow);
// Overridden in tests.
// Handles input event routed through the embedder (which is initiated in the
@@ -245,6 +255,11 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
private:
+ typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
+ MediaStreamRequestAndCallbackPair;
+ typedef std::map<int, MediaStreamRequestAndCallbackPair>
+ MediaStreamRequestsMap;
+
friend class TestBrowserPluginGuest;
BrowserPluginGuest(int instance_id,
@@ -303,6 +318,14 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
bool auto_size_enabled_;
gfx::Size max_auto_size_;
gfx::Size min_auto_size_;
+ // A counter to generate unique request id for a media access request.
+ // We only need the ids to be unique for a given BrowserPluginGuest.
+ int current_media_access_request_id_;
+ // A map to store WebContents's media request object and callback.
+ // We need to store these because we need a roundtrip to the embedder to know
+ // if we allow or disallow the request. The key of the map is unique only for
+ // a given BrowserPluginGuest.
+ MediaStreamRequestsMap media_requests_map_;
// Hardware Accelerated Surface Params
gfx::GLSurfaceHandle surface_handle_;

Powered by Google App Engine
This is Rietveld 408576698