Table Of Contents

Previous topic


Next topic





Static functions

Detailed Description

The PySide.QtWebKit.QWebSecurityOrigin class defines a security boundary for web sites.

PySide.QtWebKit.QWebSecurityOrigin provides access to the security domains defined by web sites. An origin consists of a host name, a scheme, and a port number. Web sites with the same security origin can access each other’s resources for client-side scripting or databases.

For example the site is allowed to share the same database as , or access each other’s documents when used in HTML frame sets and JavaScript. At the same time it prevents from accessing ‘s resources, because they are of a different security origin.

By default local schemes like file:// and qrc:// are concidered to be in the same security origin, and can access each other’s resources. You can add additional local schemes by using QWebSecurityOrigin.addLocalScheme() , or override the default same-origin behavior by setting QWebSettings.LocalContentCanAccessFileUrls to false .


Local resources are by default restricted from accessing remote content, which means your file:// will not be able to access . You can relax this restriction by setting QWebSettings.LocalContentCanAccessRemoteUrls to true .

Call QWebFrame.securityOrigin() to get the PySide.QtWebKit.QWebSecurityOrigin for a frame in a web page, and use , PySide.QtWebKit.QWebSecurityOrigin.scheme() and PySide.QtWebKit.QWebSecurityOrigin.port() to identify the security origin.

Use PySide.QtWebKit.QWebSecurityOrigin.databases() to access the databases defined within a security origin. The disk usage of the origin’s databases can be limited with PySide.QtWebKit.QWebSecurityOrigin.setDatabaseQuota() . PySide.QtWebKit.QWebSecurityOrigin.databaseQuota() and PySide.QtWebKit.QWebSecurityOrigin.databaseUsage() report the current limit as well as the current usage.

For more information refer to the “Same origin policy” Wikipedia Article.

class PySide.QtWebKit.QWebSecurityOrigin(other)

Constructs a security origin from other .

static PySide.QtWebKit.QWebSecurityOrigin.addLocalScheme(scheme)
Parameters:scheme – unicode

Adds the given scheme to the list of schemes that are considered equivalent to the file : scheme.

Cross domain restrictions depend on the two web settings QWebSettings.LocalContentCanAccessFileUrls and QWebSettings.LocalContentCanAccessFileUrls . By default all local schemes are concidered to be in the same security origin, and local schemes can not access remote content.

static PySide.QtWebKit.QWebSecurityOrigin.allOrigins()
Return type:

Returns a list of all security origins with a database quota defined.

Return type:PySide.QtCore.qint64

Returns the quota for the databases in the security origin.

Return type:PySide.QtCore.qint64

Returns the number of bytes all databases in the security origin use on the disk.

Return type:

Returns a list of all databases defined in the security origin.
Return type:unicode

Returns the host name defining the security origin.

static PySide.QtWebKit.QWebSecurityOrigin.localSchemes()
Return type:list of strings

Returns a list of all the schemes concidered to be local.

By default this is file:// and qrc:// .


Returns the port number defining the security origin.

static PySide.QtWebKit.QWebSecurityOrigin.removeLocalScheme(scheme)
Parameters:scheme – unicode

Removes the given scheme from the list of local schemes.


You can not remove the file:// scheme from the list of local schemes.

Return type:unicode

Returns the scheme defining the security origin.


Sets the quota for the databases in the security origin to quota bytes.

If the quota is set to a value less than the current usage, the quota will remain and no data will be purged to meet the new quota. However, no new data can be added to databases in this origin.