eric7.WebBrowser.WebBrowserPage

Module implementing the helpbrowser using QWebView.

Global Attributes

SSL_AVAILABLE

Classes

WebBrowserPage Class implementing an enhanced web page.

Functions

None


WebBrowserPage

Class implementing an enhanced web page.

Signals

navigationRequestAccepted(url, navigation type, main frame)
emitted to signal an accepted navigation request
printPageRequested()
emitted to indicate a print request of the shown web page
safeBrowsingAbort()
emitted to indicate an abort due to a safe browsing event
safeBrowsingBad(threatType, threatMessages)
emitted to indicate a malicious web site as determined by safe browsing
sslConfigurationChanged()
emitted to indicate a change of the stored SSL configuration data

Derived from

QWebEnginePage

Class Attributes

SafeJsWorld
UnsafeJsWorld

Class Methods

setUserAgent Class method to set the global user agent string.
userAgent Class method to get the global user agent setting.
userAgentForUrl Class method to determine the user agent for the given URL.

Methods

WebBrowserPage Constructor
__contentsSizeChanged Private slot to work around QWebEnginePage not scrolling to anchors when opened in a background tab.
__featurePermissionRequested Private slot handling a feature permission request.
__fullScreenRequested Private slot handling a full screen request.
__registerProtocolHandlerRequested Private slot to handle the registration of a custom protocol handler.
__setupChannelTimeout Private slot to initiate the setup of the web channel.
__setupWebChannelForUrl Private method to setup a web channel to our external object.
__urlChanged Private slot to handle changes of the URL.
acceptNavigationRequest Public method to determine, if a request may be accepted.
certificateError Public method to handle SSL certificate errors.
clearSslConfiguration Public slot to clear the stored SSL configuration data.
execJavaScript Public method to execute a JavaScript function synchroneously.
getSafeBrowsingStatus Public method to get the safe browsing status of the current page.
getSslCertificate Public method to get a reference to the SSL certificate.
getSslCertificateChain Public method to get a reference to the SSL certificate chain.
getSslConfiguration Public method to return a reference to the current SSL configuration.
hasValidSslInfo Public method to check, if the page has a valid SSL certificate.
hitTestContent Public method to test the content at a specified position.
isJavaScriptEnabled Public method to test, if JavaScript is enabled.
javaScriptConsoleMessage Public method to show a console message.
mapToViewport Public method to map a position to the viewport.
resultCallback
runJavaScript Public method to run a script in the context of the page.
scroll Public method to scroll by the given amount of pixels.
scrollTo Public method to scroll to the given position.
setSslConfiguration Public slot to set the SSL configuration data of the page.
showSslInfo Public slot to show some SSL information for the loaded page.
view Public method to get a reference to the WebBrowserView associated with the page.

Static Methods

None

WebBrowserPage.setUserAgent (class method)

setUserAgent(agent)

Class method to set the global user agent string.

agent (str)
new current user agent string

WebBrowserPage.userAgent (class method)

userAgent(resolveEmpty=False)

Class method to get the global user agent setting.

resolveEmpty (bool)
flag indicating to resolve an empty user agent
Return:
user agent string
Return Type:
str

WebBrowserPage.userAgentForUrl (class method)

userAgentForUrl(url)

Class method to determine the user agent for the given URL.

url (QUrl)
URL to determine user agent for
Return:
user agent string
Return Type:
str

WebBrowserPage (Constructor)

WebBrowserPage(view, parent=None)

Constructor

view (WebBrowserView)
reference to the WebBrowserView associated with the page
parent (QWidget (optional))
reference to the parent widget (defaults to None)

WebBrowserPage.__contentsSizeChanged

__contentsSizeChanged(_size)

Private slot to work around QWebEnginePage not scrolling to anchors when opened in a background tab.

_size (QSizeF)
changed contents size (unused) (unused)

WebBrowserPage.__featurePermissionRequested

__featurePermissionRequested(url, feature)

Private slot handling a feature permission request.

url (QUrl)
url requesting the feature
feature (QWebEnginePage.Feature)
requested feature

WebBrowserPage.__fullScreenRequested

__fullScreenRequested(request)

Private slot handling a full screen request.

request (QWebEngineFullScreenRequest)
reference to the full screen request

WebBrowserPage.__registerProtocolHandlerRequested

__registerProtocolHandlerRequested(request)

Private slot to handle the registration of a custom protocol handler.

request (QWebEngineRegisterProtocolHandlerRequest)
reference to the registration request

WebBrowserPage.__setupChannelTimeout

__setupChannelTimeout()

Private slot to initiate the setup of the web channel.

WebBrowserPage.__setupWebChannelForUrl

__setupWebChannelForUrl(url)

Private method to setup a web channel to our external object.

url (QUrl)
URL for which to setup the web channel

WebBrowserPage.__urlChanged

__urlChanged(url)

Private slot to handle changes of the URL.

url (QUrl)
new URL

WebBrowserPage.acceptNavigationRequest

acceptNavigationRequest(url, type_, isMainFrame)

Public method to determine, if a request may be accepted.

url (QUrl)
URL to navigate to
type_ (QWebEnginePage.NavigationType)
type of the navigation request
isMainFrame (bool)
flag indicating, that the request originated from the main frame
Return:
flag indicating acceptance
Return Type:
bool

WebBrowserPage.certificateError

certificateError(error)

Public method to handle SSL certificate errors.

error (QWebEngineCertificateError)
object containing the certificate error information
Return:
flag indicating to ignore this error
Return Type:
bool

WebBrowserPage.clearSslConfiguration

clearSslConfiguration()

Public slot to clear the stored SSL configuration data.

WebBrowserPage.execJavaScript

execJavaScript(script, worldId=QWebEngineScript.ScriptWorldId.MainWorld, timeout=500)

Public method to execute a JavaScript function synchroneously.

script (str)
JavaScript script source to be executed
worldId (QWebEngineScript.ScriptWorldId)
ID to run the script under
timeout (int)
max. time the script is given to execute
Return:
result of the script
Return Type:
depending upon script result

WebBrowserPage.getSafeBrowsingStatus

getSafeBrowsingStatus()

Public method to get the safe browsing status of the current page.

Return:
flag indicating a safe site
Return Type:
bool

WebBrowserPage.getSslCertificate

getSslCertificate()

Public method to get a reference to the SSL certificate.

Return:
amended SSL certificate
Return Type:
QSslCertificate

WebBrowserPage.getSslCertificateChain

getSslCertificateChain()

Public method to get a reference to the SSL certificate chain.

Return:
SSL certificate chain
Return Type:
list of QSslCertificate

WebBrowserPage.getSslConfiguration

getSslConfiguration()

Public method to return a reference to the current SSL configuration.

Return:
reference to the SSL configuration in use
Return Type:
QSslConfiguration

WebBrowserPage.hasValidSslInfo

hasValidSslInfo()

Public method to check, if the page has a valid SSL certificate.

Return:
flag indicating a valid SSL certificate
Return Type:
bool

WebBrowserPage.hitTestContent

hitTestContent(pos)

Public method to test the content at a specified position.

pos (QPoint)
position to execute the test at
Return:
test result object
Return Type:
WebHitTestResult

WebBrowserPage.isJavaScriptEnabled

isJavaScriptEnabled()

Public method to test, if JavaScript is enabled.

Return:
flag indicating the state of the JavaScript support
Return Type:
bool

WebBrowserPage.javaScriptConsoleMessage

javaScriptConsoleMessage(level, message, lineNumber, sourceId)

Public method to show a console message.

level (QWebEnginePage.JavaScriptConsoleMessageLevel)
severity
message (str)
message to be shown
lineNumber (int)
line number of an error
sourceId (str)
source URL causing the error

WebBrowserPage.mapToViewport

mapToViewport(pos)

Public method to map a position to the viewport.

pos (QPoint)
position to be mapped
Return:
viewport position
Return Type:
QPoint

WebBrowserPage.resultCallback

resultCallback(resDict=resultDict)

WebBrowserPage.runJavaScript

runJavaScript(script, worldId=-1, callback=None)

Public method to run a script in the context of the page.

script (str)
JavaScript script source to be executed
worldId (int)
ID to run the script under
callback (function)
callback function to be executed when the script has ended

WebBrowserPage.scroll

scroll(x, y)

Public method to scroll by the given amount of pixels.

x (int)
horizontal scroll value
y (int)
vertical scroll value

WebBrowserPage.scrollTo

scrollTo(pos)

Public method to scroll to the given position.

pos (QPointF)
position to scroll to

WebBrowserPage.setSslConfiguration

setSslConfiguration(sslConfiguration)

Public slot to set the SSL configuration data of the page.

sslConfiguration (QSslConfiguration)
SSL configuration to be set

WebBrowserPage.showSslInfo

showSslInfo(pos)

Public slot to show some SSL information for the loaded page.

pos (QPoint)
position to show the info at

WebBrowserPage.view

view()

Public method to get a reference to the WebBrowserView associated with the page.

Return:
reference to the WebBrowserView associated with the page
Return Type:
WebBrowserView
Up