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

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: Address comments from creis@ 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 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 1d343b19e9812fd3b320e0b43382c3ecc188ef62..32fa8dfed02fa4ba90a05967c8bd6b8be15c2176 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.h
+++ b/content/browser/browser_plugin/browser_plugin_guest.h
@@ -58,6 +58,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_*
@@ -147,6 +148,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;
// Exposes the protected web_contents() from WebContentsObserver.
WebContents* GetWebContents();
@@ -154,6 +159,7 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
// Kill the guest process.
void Terminate();
+
// Overridden in tests.
virtual void SetDamageBuffer(
const BrowserPluginHostMsg_ResizeGuest_Params& params);
@@ -178,6 +184,11 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
uint32 sync_point);
private:
+ typedef std::pair<content::MediaStreamRequest, content::MediaResponseCallback>
+ MediaStreamRequestAndCallbackPair;
+ typedef std::map<int, MediaStreamRequestAndCallbackPair>
+ MediaStreamRequestsMap;
+
friend class TestBrowserPluginGuest;
BrowserPluginGuest(int instance_id,
@@ -202,6 +213,12 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
// Message handlers for messsages from embedder.
+ // Allows or denies a permission request access, after the embedder has had a
+ // chance to decide.
+ void OnAllowPermission(int instance_id,
+ const std::string& permission_type,
+ int request_id,
+ bool should_allow);
// Handles drag events from the embedder.
// When dragging, the drag events go to the embedder first, and if the drag
// happens on the browser plugin, then the plugin sends a corresponding
@@ -317,6 +334,15 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
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_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
};

Powered by Google App Engine
This is Rietveld 408576698