webview: add permission-request event

This commit is contained in:
Robo 2016-01-23 18:59:47 +05:30
commit 85e13333c3
12 changed files with 260 additions and 3 deletions

View file

@ -34,7 +34,8 @@ var WEB_VIEW_EVENTS = {
'page-favicon-updated': ['favicons'],
'enter-html-full-screen': [],
'leave-html-full-screen': [],
'found-in-page': ['result']
'found-in-page': ['result'],
'permission-request': ['permission', 'allow', 'deny']
};
var DEPRECATED_EVENTS = {
@ -64,6 +65,15 @@ module.exports = {
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-" + viewInstanceId, function() {
var eventName = arguments[1];
var args = 3 <= arguments.length ? slice.call(arguments, 2) : [];
if (eventName === 'permission-request') {
var allow = function allow() {
ipcRenderer.send("ATOM_SHELL_GUEST_VIEW_MANAGER_SET_PERMISSION_RESPONSE", viewInstanceId, args[0], true);
};
var deny = function deny() {
ipcRenderer.send("ATOM_SHELL_GUEST_VIEW_MANAGER_SET_PERMISSION_RESPONSE", viewInstanceId, args[0], false);
};
args = args.concat([allow, deny]);
}
return dispatchEvent.apply(null, [webView, eventName, eventName].concat(slice.call(args)));
});
ipcRenderer.on("ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-" + viewInstanceId, function() {

View file

@ -311,6 +311,7 @@ WebViewImpl.prototype.setupWebViewAttributes = function() {
this.attributes[webViewConstants.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_ALLOWPOPUPS, this);
this.attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_BLINKFEATURES] = new BlinkFeaturesAttribute(this);
this.attributes[webViewConstants.ATTRIBUTE_DISABLEWEBNOTIFICATION] = new BooleanAttribute(webViewConstants.ATTRIBUTE_DISABLEWEBNOTIFICATION, this);
autosizeAttributes = [webViewConstants.ATTRIBUTE_MAXHEIGHT, webViewConstants.ATTRIBUTE_MAXWIDTH, webViewConstants.ATTRIBUTE_MINHEIGHT, webViewConstants.ATTRIBUTE_MINWIDTH];
results = [];
for (i = 0, len = autosizeAttributes.length; i < len; i++) {