Add support for native chromium popups on sandboxed renderers.
- Allow `api::Window` instances to be created from existing `api::WebContents`. - Override `WebContentsCreated` and `AddNewContents` to wrap renderer-created `content::WebContents` into `api::WebContents`. - For `content::WebContents` that should be displayed in new windows, pass the wrapped `api::WebContents` object to window manager.
This commit is contained in:
		
					parent
					
						
							
								0b3b29938f
							
						
					
				
			
			
				commit
				
					
						06cc9a44fe
					
				
			
		
					 6 changed files with 123 additions and 15 deletions
				
			
		|  | @ -3,6 +3,7 @@ | |||
| const {ipcMain} = require('electron') | ||||
| const {EventEmitter} = require('events') | ||||
| const {BrowserWindow} = process.atomBinding('window') | ||||
| const v8Util = process.atomBinding('v8_util') | ||||
| 
 | ||||
| Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype) | ||||
| 
 | ||||
|  | @ -26,6 +27,34 @@ BrowserWindow.prototype._init = function () { | |||
|     ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options) | ||||
|   }) | ||||
| 
 | ||||
|   this.webContents.on('-web-contents-created', (event, webContents, url, | ||||
|                                                 frameName) => { | ||||
|     v8Util.setHiddenValue(webContents, 'url-framename', {url, frameName}) | ||||
|   }) | ||||
|   // Create a new browser window for the native implementation of
 | ||||
|   // "window.open"(sandbox mode only)
 | ||||
|   this.webContents.on('-add-new-contents', (event, webContents, disposition, | ||||
|                                             userGesture, left, top, width, | ||||
|                                             height) => { | ||||
|     let urlFrameName = v8Util.getHiddenValue(webContents, 'url-framename') | ||||
|     if ((disposition !== 'foreground-tab' && disposition !== 'new-window') || | ||||
|         !urlFrameName) { | ||||
|       return | ||||
|     } | ||||
| 
 | ||||
|     let {url, frameName} = urlFrameName | ||||
|     v8Util.deleteHiddenValue(webContents, 'url-framename') | ||||
|     const options = { | ||||
|       show: true, | ||||
|       x: left, | ||||
|       y: top, | ||||
|       width: width || 800, | ||||
|       height: height || 600, | ||||
|       webContents: webContents | ||||
|     } | ||||
|     ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options) | ||||
|   }) | ||||
| 
 | ||||
|   // window.resizeTo(...)
 | ||||
|   // window.moveTo(...)
 | ||||
|   this.webContents.on('move', (event, size) => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Thiago de Arruda
				Thiago de Arruda