nsICookiePermission 编辑

The nsICookiePermission interface is used to test for cookie permissions

netwerk/cookie/nsICookiePermission.idlScriptable 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

ConstantValueDescription
ACCESS_DEFAULT0nsCookieAccess's access default value
ACCESS_ALLOW1nsCookieAccess's access allow value
ACCESS_DENY2nsCookieAccess's access deny value
ACCESS_SESSION8Additional 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 current isSession 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:74 次

字数:6990

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文