Chromium Code Reviews| 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. |
|
Charlie Reis
2012/12/07 19:16:25
nit: Let's be consistent: 'stable' / 'dev'
lazyboy
2012/12/07 22:50:44
Done.
|
| + |
| +var WebView = require('webview').WebView; |
| + |
| +/** |
| + * @private |
| + */ |
| +WebView.prototype.maybeSetupPermissionEvent_ = function() { |
| + this.setupEvent_('permissionrequest', |
| + ['reason'], |
| + this.preparePremissionEvent_.bind(this)); |
|
Charlie Reis
2012/12/07 19:16:25
Typo: Premission
lazyboy
2012/12/07 22:50:44
Done.
|
| +}; |
| + |
| +/** |
| + * @param {Event} webViewEvt The event to be dispatched to <webview>. |
| + * @param {!Object} detail The event details, originated from <object>. |
|
Charlie Reis
2012/12/07 19:16:25
I don't know JavaScript coding style very well. W
lazyboy
2012/12/07 22:50:44
!Object == non-nullable Object (@param of every no
|
| + * @private |
| + */ |
| +WebView.prototype.preparePremissionEvent_ = function(webViewEvt, detail) { |
| + if (detail.reason == 'media' && detail.request_id !== undefined) { |
|
Charlie Reis
2012/12/07 19:16:25
From your links, it sounds like we should change t
lazyboy
2012/12/07 22:50:44
Done.
|
| + // TODO(lazyboy): Also fill in webViewEvt.url and webViewEvt.details (see |
| + // webview specs). |
|
Charlie Reis
2012/12/07 19:16:25
Can you add a bug number (141197) here? (Is it tr
lazyboy
2012/12/07 22:50:44
For 'details', we need to decide what they would b
|
| + var objectNode = this.objectNode_; |
| + var requestId = detail.request_id; |
| + webViewEvt.allow = function() { |
| + objectNode.setMediaPermission(requestId, true); |
| + }; |
| + webViewEvt.deny = function() { |
| + objectNode.setMediaPermission(requestId, false); |
| + }; |
| + } |
| +}; |
| + |