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

Unified Diff: chrome/renderer/resources/extensions/web_view_permission_api.js

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/renderer/resources/extensions/web_view_permission_api.js
diff --git a/chrome/renderer/resources/extensions/web_view_permission_api.js b/chrome/renderer/resources/extensions/web_view_permission_api.js
new file mode 100644
index 0000000000000000000000000000000000000000..b0048443935400d6484a8b44e47d634dff8717dd
--- /dev/null
+++ b/chrome/renderer/resources/extensions/web_view_permission_api.js
@@ -0,0 +1,42 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Shim extension to provide permission request API for <webview> tag.
+// See web_view.js for details.
+//
+// We want to control the permission API feature in <webview> separately from
+// the <webview> feature itself. <webview> will be migrated to 'stable' channel
+// but we want keep permission API in <webview> only available in DEV channel.
+
+var WebView = require('webview').WebView;
+
+/**
+ * @private
+ */
+WebView.prototype.maybeSetupPermissionEvent_ = function() {
+ this.setupEvent_('permissionrequest',
+ ['reason'],
+ this.preparePremissionEvent_.bind(this));
+};
+
+/**
+ * @param {Event} webViewEvt The event to be dispatched to <webview>.
+ * @param {!Object} detail The event details, originated from <object>.
+ * @private
+ */
+WebView.prototype.preparePremissionEvent_ = function(webViewEvt, detail) {
+ if (detail.reason == 'media' && detail.request_id !== undefined) {
+ // TODO(lazyboy): Also fill in webViewEvt.url and webViewEvt.details (see
Fady Samuel 2012/12/05 22:14:32 Do it now?
lazyboy 2012/12/06 00:05:52 I'm not sure about the values, making the url gues
+ // webview specs).
+ var objectNode = this.objectNode_;
+ var requestId = detail.request_id;
+ webViewEvt.allow = function() {
+ objectNode.setMediaPermission(requestId, true);
+ };
+ webViewEvt.deny = function() {
+ objectNode.setMediaPermission(requestId, false);
+ };
+ }
+};
+

Powered by Google App Engine
This is Rietveld 408576698