]> khamidou — GitHub mirrors - electron.git/commitdiff
Add allowpopups attribute for webview
authorCheng Zhao <zcbenz@gmail.com>
Tue, 22 Sep 2015 12:11:05 +0000 (20:11 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 22 Sep 2015 12:11:05 +0000 (20:11 +0800)
atom/browser/lib/guest-view-manager.coffee
atom/browser/lib/guest-window-manager.coffee
atom/renderer/lib/web-view/web-view-attributes.coffee
atom/renderer/lib/web-view/web-view-constants.coffee

index 1c05b65b2dc0dc459d125be90db9d62fd56907c1..455e969812f7d4c77f9781a6f9855ac560c0ba70 100644 (file)
@@ -84,6 +84,8 @@ createGuest = (embedder, params) ->
     if params.allowtransparency?
       @setAllowTransparency params.allowtransparency
 
+    guest.allowPopups = params.allowpopups
+
   # Dispatch events to embedder.
   for event in supportedWebViewEvents
     do (event) ->
index 861b0d10aa316c64980c83c9aad7d0cfdef80e97..add366eca8127fde881244cc71d7d85155da3c49 100644 (file)
@@ -41,7 +41,7 @@ createGuest = (embedder, url, frameName, options) ->
 ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) ->
   [url, frameName, options] = args
   event.sender.emit 'new-window', event, url, frameName, 'new-window'
-  if event.sender.isGuest() or event.defaultPrevented
+  if (event.sender.isGuest() and not event.sender.allowPopups) or event.defaultPrevented
     event.returnValue = null
   else
     event.returnValue = createGuest event.sender, args...
index acca826a9e3d255f5bae19de6c33cd6a1b518113..e980e6c96bfc0de820fecc9695d7a4ab052c2d67 100644 (file)
@@ -216,6 +216,7 @@ WebViewImpl::setupWebViewAttributes = ->
   @attributes[webViewConstants.ATTRIBUTE_NODEINTEGRATION] = new BooleanAttribute(webViewConstants.ATTRIBUTE_NODEINTEGRATION, this)
   @attributes[webViewConstants.ATTRIBUTE_PLUGINS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_PLUGINS, this)
   @attributes[webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY] = new BooleanAttribute(webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY, this)
+  @attributes[webViewConstants.ATTRIBUTE_ALLOWPOPUPS] = new BooleanAttribute(webViewConstants.ATTRIBUTE_ALLOWPOPUPS, this)
   @attributes[webViewConstants.ATTRIBUTE_PRELOAD] = new PreloadAttribute(this)
 
   autosizeAttributes = [
index deb678e6a1e86873e137fad0cd28fc2fbced3d64..bfb9376fa7ea0ba9ecab823c48efe3e6125fea76 100644 (file)
@@ -13,6 +13,7 @@ module.exports =
   ATTRIBUTE_NODEINTEGRATION: 'nodeintegration'
   ATTRIBUTE_PLUGINS: 'plugins'
   ATTRIBUTE_DISABLEWEBSECURITY: 'disablewebsecurity'
+  ATTRIBUTE_ALLOWPOPUPS: 'allowpopups'
   ATTRIBUTE_PRELOAD: 'preload'
   ATTRIBUTE_USERAGENT: 'useragent'