QWebSecurityOrigin Class Reference

[ QtWebKit module]

The QWebSecurityOrigin class defines a security boundary for web sites. 更多...

方法

Static Methods


详细描述

The QWebSecurityOrigin class defines a security boundary for web sites.

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 数据库。

For example the site http://www.example.com/my/page.html is allowed to share the same database as http://www.example.com/my/overview.html , or access each other's documents when used in HTML frame sets and JavaScript. At the same time it prevents http://www.malicious.com/evil.html from accessing http://www.example.com/ '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 http://domain.com/foo.html . You can relax this restriction by setting QWebSettings.LocalContentCanAccessRemoteUrls to true .

调用 QWebFrame.securityOrigin () 到 get the QWebSecurityOrigin for a frame in a web page, and use host (), scheme () 和 port () to identify the security origin.

使用 databases () to access the databases defined within a security origin. The disk usage of the origin's databases can be limited with setDatabaseQuota (). databaseQuota () and databaseUsage () report the current limit as well as the current usage.

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


方法文档编制

QWebSecurityOrigin.__init__ ( self , QWebSecurityOrigin   other )

Constructs a security origin from other .

QWebSecurityOrigin.addLocalScheme (QString  scheme )

添加给定 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 内容。

该函数在 Qt 4.6 引入。

list-of-QWebSecurityOrigin QWebSecurityOrigin.allOrigins ()

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

int QWebSecurityOrigin.databaseQuota ( self )

Returns the quota for the databases in the security origin.

另请参阅 setDatabaseQuota ().

list-of-QWebDatabase QWebSecurityOrigin.databases ( self )

Returns a list of all databases defined in the security origin.

int QWebSecurityOrigin.databaseUsage ( self )

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

QString QWebSecurityOrigin.host ( self )

Returns the host name defining the security origin.

QStringList QWebSecurityOrigin.localSchemes ()

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

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

该函数在 Qt 4.6 引入。

另请参阅 addLocalScheme () 和 removeLocalScheme ().

int QWebSecurityOrigin.port ( self )

Returns the port number defining the security origin.

QWebSecurityOrigin.removeLocalScheme (QString  scheme )

移除给定 scheme from the list of local schemes.

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

该函数在 Qt 4.6 引入。

另请参阅 addLocalScheme ().

QString QWebSecurityOrigin.scheme ( self )

Returns the scheme defining the security origin.

QWebSecurityOrigin.setApplicationCacheQuota ( self , int  quota )

QWebSecurityOrigin.setDatabaseQuota ( self , int  quota )

Sets the quota for the databases in the security origin to quota 字节。

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.

另请参阅 databaseQuota ().