feat: add will-redirect (#13866)
* feat: add will-redirect to allow people to prevent 30X redirects * spec: add tests for the will-redirect event * refactor: implement will-redirect using NavigationThrottle instead of PostTask This avoids a potential race condition and immediately cancels the navigation * docs: add docs for did-redirect-navigation * refactor: move AtomNavigationThrottle out of net folder * refactor: update header guard for atom_navigation_throttle.h * refactor: fix chromium style errors in the GN build * refactor: update throttle impl to NOTREACHED and std::make_unqique
This commit is contained in:
		
					parent
					
						
							
								6ad8583a8b
							
						
					
				
			
			
				commit
				
					
						7065093869
					
				
			
		
					 10 changed files with 222 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -265,6 +265,22 @@ ipcMain.on('close-on-will-navigate', (event, id) => {
 | 
			
		|||
  })
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
ipcMain.on('close-on-will-redirect', (event, id) => {
 | 
			
		||||
  const contents = event.sender
 | 
			
		||||
  const window = BrowserWindow.fromId(id)
 | 
			
		||||
  window.webContents.once('will-redirect', (event, input) => {
 | 
			
		||||
    window.close()
 | 
			
		||||
    contents.send('closed-on-will-redirect')
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
ipcMain.on('prevent-will-redirect', (event, id) => {
 | 
			
		||||
  const window = BrowserWindow.fromId(id)
 | 
			
		||||
  window.webContents.once('will-redirect', (event) => {
 | 
			
		||||
    event.preventDefault()
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
ipcMain.on('create-window-with-options-cycle', (event) => {
 | 
			
		||||
  // This can't be done over remote since cycles are already
 | 
			
		||||
  // nulled out at the IPC layer
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue