mirror of
				https://github.com/kovidgoyal/calibre.git
				synced 2025-11-03 19:17:02 -05:00 
			
		
		
		
	DRYer
This commit is contained in:
		
							parent
							
								
									4669ca7d8b
								
							
						
					
					
						commit
						8c2aa4182c
					
				@ -341,12 +341,13 @@ class WebPage(QWebEnginePage):
 | 
				
			|||||||
        prints('%s:%s: %s' % (source_id, linenumber, msg))
 | 
					        prints('%s:%s: %s' % (source_id, linenumber, msg))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def acceptNavigationRequest(self, url, req_type, is_main_frame):
 | 
					    def acceptNavigationRequest(self, url, req_type, is_main_frame):
 | 
				
			||||||
        if req_type == QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload:
 | 
					        if req_type in (QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload, QWebEngineUrlRequestInfo.NavigationType.NavigationTypeBackForward):
 | 
				
			||||||
            return True
 | 
					            return True
 | 
				
			||||||
        if url.scheme() in (FAKE_PROTOCOL, 'data'):
 | 
					        if url.scheme() in (FAKE_PROTOCOL, 'data'):
 | 
				
			||||||
            return True
 | 
					            return True
 | 
				
			||||||
        if req_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
 | 
					        if url.scheme() in ('http', 'https') and req_type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked:
 | 
				
			||||||
            safe_open_url(url)
 | 
					            safe_open_url(url)
 | 
				
			||||||
 | 
					        prints('Blocking navigation request to:', url.toString())
 | 
				
			||||||
        return False
 | 
					        return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def go_to_anchor(self, anchor):
 | 
					    def go_to_anchor(self, anchor):
 | 
				
			||||||
 | 
				
			|||||||
@ -370,9 +370,7 @@ class WebPage(QWebEnginePage):
 | 
				
			|||||||
            pass
 | 
					            pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def acceptNavigationRequest(self, url, req_type, is_main_frame):
 | 
					    def acceptNavigationRequest(self, url, req_type, is_main_frame):
 | 
				
			||||||
        if req_type == QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload:
 | 
					        if req_type in (QWebEngineUrlRequestInfo.NavigationType.NavigationTypeReload, QWebEngineUrlRequestInfo.NavigationType.NavigationTypeBackForward):
 | 
				
			||||||
            return True
 | 
					 | 
				
			||||||
        if req_type == QWebEngineUrlRequestInfo.NavigationType.NavigationTypeBackForward:
 | 
					 | 
				
			||||||
            return True
 | 
					            return True
 | 
				
			||||||
        if url.scheme() in (FAKE_PROTOCOL, 'data'):
 | 
					        if url.scheme() in (FAKE_PROTOCOL, 'data'):
 | 
				
			||||||
            return True
 | 
					            return True
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user