mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1356605 - Part 1: Add an enumerator for getting session cookies only. r=valentin
This commit is contained in:
parent
c745ceee90
commit
6523b5834f
@ -2361,6 +2361,31 @@ nsCookieService::GetEnumerator(nsISimpleEnumerator **aEnumerator)
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieService::GetSessionEnumerator(nsISimpleEnumerator **aEnumerator)
|
||||
{
|
||||
if (!mDBState) {
|
||||
NS_WARNING("No DBState! Profile already closed?");
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
EnsureReadComplete();
|
||||
|
||||
nsCOMArray<nsICookie> cookieList(mDBState->cookieCount);
|
||||
for (auto iter = mDBState->hostTable.Iter(); !iter.Done(); iter.Next()) {
|
||||
const nsCookieEntry::ArrayType& cookies = iter.Get()->GetCookies();
|
||||
for (nsCookieEntry::IndexType i = 0; i < cookies.Length(); ++i) {
|
||||
nsCookie* cookie = cookies[i];
|
||||
// Filter out non-session cookies.
|
||||
if (cookie->IsSession()) {
|
||||
cookieList.AppendObject(cookie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_NewArrayEnumerator(aEnumerator, cookieList);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
InitializeOriginAttributes(OriginAttributes* aAttrs,
|
||||
JS::HandleValue aOriginAttributes,
|
||||
|
@ -41,6 +41,12 @@ interface nsICookieManager : nsISupports
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator enumerator;
|
||||
|
||||
/**
|
||||
* Called to enumerate through each session cookie in the cookie list.
|
||||
* The objects enumerated over are of type nsICookie
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator sessionEnumerator;
|
||||
|
||||
/**
|
||||
* Called to remove an individual cookie from the cookie list, specified
|
||||
* by host, name, and path. If the cookie cannot be found, no exception
|
||||
|
Loading…
Reference in New Issue
Block a user