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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view_media_access/media_access_guest.html

Issue 11093080: <webview>: First stab at implementing media permission request for guests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nit fix 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: chrome/test/data/extensions/platform_apps/web_view_media_access/media_access_guest.html
diff --git a/chrome/test/data/extensions/platform_apps/web_view_media_access/media_access_guest.html b/chrome/test/data/extensions/platform_apps/web_view_media_access/media_access_guest.html
new file mode 100644
index 0000000000000000000000000000000000000000..da7b636d577ffa81d6b505b39d5de6cf9398211c
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/web_view_media_access/media_access_guest.html
@@ -0,0 +1,50 @@
+<html>
+ <head>
+ <script type="text/javascript">
+ // A guest that requests for media access.
+ // Notifies the embedder about the result of the request (success/fail)
+ // via post message. Note that the embedder has to initiate a postMessage
+ // first so that guest has a reference to the embedder's window.
+
+ // The window reference of the embedder to send post message reply.
+ var embedderWindowChannel = null;
+ var hasDeferredCall = false;
+ var deferredParams;
+
+ var notifyEmbedder = function(msg) {
+ if (!embedderWindowChannel) {
+ hasDeferredCall = false;
+ deferredParams = msg;
+ return;
+ }
+ embedderWindowChannel.postMessage(msg, '*');
+ };
+
+ var onUserMediaSuccess = function(stream) {
+ // Should not happen.
+ notifyEmbedder('access-granted');
+ };
+ var onUserMediaFailure = function(err) {
+ notifyEmbedder('access-denied');
+ };
+ var requestAudioMedia = function() {
+ navigator.webkitGetUserMedia(
+ {audio: true}, onUserMediaSuccess, onUserMediaFailure);
+ };
+ var onPostMessageReceived = function(e) {
+ embedderWindowChannel = e.source;
+
+ if (hasDeferredCall) {
+ notifyEmbedder(deferredParams);
+ }
+ };
+ window.addEventListener('message', onPostMessageReceived, false);
+ </script>
+ </head>
+ <body>
+ <div>This is guest that requests audio media.</div>
+ <script>
+ requestAudioMedia();
Fady Samuel 2012/12/05 22:14:32 This code might perhaps be a bit simpler if we del
lazyboy 2012/12/06 00:05:52 Done, thanks.
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698