nsICookiePermission 编辑
The nsICookiePermission
interface is used to test for cookie permissions
netwerk/cookie/nsICookiePermission.idl
Scriptable Please add a summary to this article. Last changed in Gecko 1.9 (Firefox 3)Inherits from: nsISupports
Method overview
nsCookieAccess canAccess(in nsIURI aURI, in nsIChannel aChannel); |
boolean canSetCookie(in nsIURI aURI, in nsIChannel aChannel, in nsICookie2 aCookie, inout boolean aIsSession, inout PRInt64 aExpiry); |
nsIURI getOriginatingURI(in nsIChannel aChannel); |
void setAccess(in nsIURI aURI, in nsCookieAccess aAccess); |
Constants
Constant | Value | Description |
ACCESS_DEFAULT | 0 | nsCookieAccess 's access default value |
ACCESS_ALLOW | 1 | nsCookieAccess 's access allow value |
ACCESS_DENY | 2 | nsCookieAccess 's access deny value |
ACCESS_SESSION | 8 | Additional values for nsCookieAccess , which are not directly used by any methods on this interface, but are nevertheless convenient to define here. These may be relocated somewhere else if we ever consider freezing this interface. |
Methods
canAccess()
Tests whether or not the given URI/channel may access the cookie database, either to set or get cookies.
nsCookieAccess canAccess( in nsIURI aURI, in nsIURI aFirstURI, Obsolete since Gecko 1.9 in nsIChannel aChannel );
Parameters
aURI
- The URI trying to access cookies.
aFirstURI
- The URI initiated by the user that resulted in
aURI
being loaded. aChannel
- The channel corresponding to
aURI
.
Return value
One of the nsCookieAccess
values: ACCESS_DEFAULT
, ACCESS_ALLOW
, or ACCESS_DENY
.
canSetCookie()
Tests whether or not the given URI/channel may set a specific cookie. This method is always preceded by a call to canAccess()
. It may modify the isSession
and expiry
attributes of the cookie via the aIsSession
and aExpiry
parameters, in order to limit or extend the lifetime of the cookie. This is useful, for instance, to downgrade a cookie to session-only if it fails to meet certain criteria.
boolean canSetCookie( in nsIURI aURI, in nsIChannel aChannel, in nsICookie2 aCookie, inout boolean aIsSession, inout PRInt64 aExpiry );
Parameters
aURI
- The URI trying to set the cookie.
aChannel
- The channel corresponding to
aURI
. aCookie
- The cookie being added to the cookie database.
aIsSession
- When
canSetCookie
is invoked, this is the currentisSession
attribute of the cookie.canSetCookie
may leave this value unchanged to preserve this attribute of the cookie. aExpiry
- When
canSetCookie
is invoked, this is the current expiry time of the cookie.canSetCookie
may leave this value unchanged to preserve this attribute of the cookie.
Return value
true
if the cookie can be set.
getOriginatingURI()
Determines the originating URI for a load given a channel, for third-party cookie blocking. This is done by leveraging the loadgroup of the channel to find the root content docshell, and the URI associated with its principal. If the root content docshell or its principal's URI cannot be obtained, this method will throw.
nsIURI getOriginatingURI( in nsIChannel aChannel );
Parameters
aChannel
- The channel for the load trying to get or set cookies.
Return value
The originating URI.
setAccess()
Sets cookie access permissions for the given URI. This may result in other URIs being blocked as well, such as URIs that share the same host name.
void setAccess( in nsIURI aURI, in nsCookieAccess aAccess );
Parameters
aURI
- The URI to block.
aAccess
- The new cookie access permissions for the URI.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论