Chromium Code Reviews| Index: chrome/renderer/resources/extensions/web_view.js |
| diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js |
| index 1617e5c4108ed464472bd9812dba6365dcb925f7..fa6baa5e6019a4e13ddb537be1e60d766e48b811 100644 |
| --- a/chrome/renderer/resources/extensions/web_view.js |
| +++ b/chrome/renderer/resources/extensions/web_view.js |
| @@ -120,6 +120,9 @@ function WebView(node) { |
| for (var eventName in WEB_VIEW_EVENTS) { |
| this.setupEvent_(eventName, WEB_VIEW_EVENTS[eventName]); |
| } |
| + this.setupEvent_('permissionrequest', |
| + ['reason'], |
|
Charlie Reis
2012/11/20 01:54:00
The API called for 'type', but if that's not avail
lazyboy
2012/11/20 02:55:20
This should be easy to change later (before m25 cu
|
| + this.preparePremissionEvent_.bind(this)); |
| } |
| /** |
| @@ -133,7 +136,7 @@ WebView.prototype.handleMutation_ = function(mutation) { |
| /** |
| * @private |
| */ |
| -WebView.prototype.setupEvent_ = function(eventname, attribs) { |
| +WebView.prototype.setupEvent_ = function(eventname, attribs, opt_prepareEvent) { |
|
Charlie Reis
2012/11/20 01:54:00
I'm not familiar with our JS style guide rules. A
lazyboy
2012/11/20 02:55:20
I don't know about chromium js style guide. Google
Charlie Reis
2012/12/07 19:16:25
Ok. Make sure you get a chrome/ reviewer to appro
|
| var node = this.node_; |
| this.objectNode_.addEventListener('-internal-' + eventname, function(e) { |
| var evt = new Event(eventname); |
| @@ -141,6 +144,30 @@ WebView.prototype.setupEvent_ = function(eventname, attribs) { |
| attribs.forEach(function(attribName) { |
| evt[attribName] = detail[attribName]; |
| }); |
| + if (opt_prepareEvent) { |
| + opt_prepareEvent(evt, detail); |
| + } |
| node.dispatchEvent(evt); |
| }); |
| -} |
| +}; |
| + |
| +/** |
| + * @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 |
| + // webview specs). |
|
Charlie Reis
2012/11/20 01:54:00
Are we still happy with the spec, or should it be
lazyboy
2012/11/20 02:55:20
Details can be made useful, probably noting that w
|
| + var objectNode = this.objectNode_; |
| + var requestId = detail.request_id; |
| + webViewEvt.allow = function() { |
| + objectNode.setMediaPermission(requestId, true /* allow */); |
|
Charlie Reis
2012/11/20 01:54:00
nit: Don't need the /* allow */, since it's clear
lazyboy
2012/11/20 02:55:20
Done.
|
| + }; |
| + webViewEvt.deny = function() { |
| + objectNode.setMediaPermission(requestId, false /* allow */); |
| + }; |
| + } |
| +}; |
| + |