rev nsICookieManager2 interface to allow adding httpOnly cookies, and update consumers to match. b=379408, r+sr=biesi.
git-svn-id: svn://10.0.0.236/trunk@228214 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
f9b3e89ee7
commit
e5717e9ec9
@ -1843,8 +1843,9 @@ nsIEProfileMigrator::CopyCookiesFromBuffer(char *aBuffer,
|
||||
stringPath,
|
||||
stringName,
|
||||
nsDependentCString(value),
|
||||
flagsValue & 0x1,
|
||||
PR_FALSE,
|
||||
flagsValue & 0x1, // isSecure
|
||||
PR_FALSE, // isHttpOnly
|
||||
PR_FALSE, // isSession
|
||||
PRInt64(expirationDate));
|
||||
if (NS_FAILED(onerv)) {
|
||||
rv = onerv;
|
||||
|
||||
@ -40,7 +40,6 @@
|
||||
#include "nsICookieManager2.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
@ -341,7 +340,7 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
|
||||
PRInt32 numInts;
|
||||
PRInt64 expires;
|
||||
PRBool isDomain;
|
||||
nsInt64 currentTime = nsInt64(PR_Now()) / nsInt64(1000000);
|
||||
PRInt64 currentTime = PR_Now() / PR_USEC_PER_SEC;
|
||||
|
||||
nsCOMPtr<nsICookieManager2> cookieManager(do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -380,7 +379,7 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
|
||||
char *iter = buffer.BeginWriting();
|
||||
*(iter += nameIndex - 1) = char(0);
|
||||
numInts = PR_sscanf(buffer.get() + expiresIndex, "%lld", &expires);
|
||||
if (numInts != 1 || nsInt64(expires) < currentTime)
|
||||
if (numInts != 1 || expires < currentTime)
|
||||
continue;
|
||||
|
||||
isDomain = Substring(buffer, isDomainIndex, pathIndex - isDomainIndex - 1).Equals(kTrue);
|
||||
@ -398,7 +397,8 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
|
||||
Substring(buffer, nameIndex, cookieIndex - nameIndex - 1),
|
||||
Substring(buffer, cookieIndex, buffer.Length() - cookieIndex),
|
||||
Substring(buffer, secureIndex, expiresIndex - secureIndex - 1).Equals(kTrue),
|
||||
PR_FALSE,
|
||||
PR_FALSE, // isHttpOnly
|
||||
PR_FALSE, // isSession
|
||||
expires);
|
||||
}
|
||||
|
||||
|
||||
@ -906,7 +906,8 @@ nsOperaCookieMigrator::AddCookie(nsICookieManager2* aManager)
|
||||
mCurrCookie.id,
|
||||
mCurrCookie.data,
|
||||
mCurrCookie.isSecure,
|
||||
PR_FALSE,
|
||||
PR_FALSE, // isHttpOnly
|
||||
PR_FALSE, // isSession
|
||||
PRInt64(mCurrCookie.expiryTime));
|
||||
|
||||
mCurrCookie.isSecure = 0;
|
||||
|
||||
@ -823,7 +823,10 @@ nsSafariProfileMigrator::CopyCookies(PRBool aReplace)
|
||||
|
||||
expiryTime += SAFARI_DATE_OFFSET;
|
||||
cookieManager->Add(domain, path, name, value,
|
||||
PR_FALSE, PR_FALSE, expiryTime);
|
||||
PR_FALSE, // isSecure
|
||||
PR_FALSE, // isHttpOnly
|
||||
PR_FALSE, // isSession
|
||||
expiryTime);
|
||||
}
|
||||
}
|
||||
::CFRelease(safariCookies);
|
||||
|
||||
@ -37,7 +37,6 @@
|
||||
|
||||
#include "nsBrowserProfileMigratorUtils.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsICookieManager2.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsILoginInfo.h"
|
||||
#include "nsILoginManager.h"
|
||||
|
||||
@ -619,8 +619,9 @@ nsTridentPreferencesWin::CopyCookiesFromBuffer(
|
||||
stringPath,
|
||||
stringName,
|
||||
nsDependentCString(value),
|
||||
flagsValue & 0x1,
|
||||
PR_FALSE,
|
||||
flagsValue & 0x1, // isSecure
|
||||
PR_FALSE, // isHttpOnly
|
||||
PR_FALSE, // isSession
|
||||
PRInt64(expirationDate));
|
||||
if (NS_FAILED(onerv)) {
|
||||
rv = onerv;
|
||||
|
||||
@ -69,7 +69,6 @@
|
||||
// needed for the cookie policy manager
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsICookie2.h"
|
||||
#include "nsICookieManager2.h"
|
||||
|
||||
// needed for mailnews content load policy manager
|
||||
#include "nsIDocShell.h"
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
* access of cookie objects
|
||||
*/
|
||||
|
||||
[scriptable, uuid(1f5b06e1-8d52-46a0-a26d-762bd6a1Cf75)]
|
||||
[scriptable, uuid(736619fe-8d09-4e59-8223-32f176c22977)]
|
||||
|
||||
interface nsICookie2 : nsICookie
|
||||
{
|
||||
@ -76,7 +76,7 @@ interface nsICookie2 : nsICookie
|
||||
/**
|
||||
* true if the cookie is an http only cookie
|
||||
*/
|
||||
readonly attribute boolean httpOnly;
|
||||
readonly attribute boolean isHttpOnly;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -43,7 +43,7 @@ interface nsICookie2;
|
||||
* Additions to the frozen nsICookieManager
|
||||
*/
|
||||
|
||||
[scriptable, uuid(9facbb48-c05d-470b-b4da-897c8d613e00)]
|
||||
[scriptable, uuid(fdbce92e-254c-436c-a0ba-04504d1434d0)]
|
||||
interface nsICookieManager2 : nsICookieManager
|
||||
{
|
||||
/**
|
||||
@ -60,8 +60,11 @@ interface nsICookieManager2 : nsICookieManager
|
||||
* cookie name
|
||||
* @param aValue
|
||||
* cookie data
|
||||
* @param aSecure
|
||||
* @param aIsSecure
|
||||
* true if the cookie should only be sent over a secure connection.
|
||||
* @param aIsHttpOnly
|
||||
* true if the cookie should only be sent to, and can only be
|
||||
* modified by, an http connection.
|
||||
* @param aIsSession
|
||||
* true if the cookie should exist for the current session only.
|
||||
* see aExpiry.
|
||||
@ -74,7 +77,8 @@ interface nsICookieManager2 : nsICookieManager
|
||||
in AUTF8String aPath,
|
||||
in ACString aName,
|
||||
in ACString aValue,
|
||||
in boolean aSecure,
|
||||
in boolean aIsSecure,
|
||||
in boolean aIsHttpOnly,
|
||||
in boolean aIsSession,
|
||||
in PRInt64 aExpiry);
|
||||
|
||||
|
||||
@ -88,13 +88,13 @@ nsCookie::Create(const nsACString &aName,
|
||||
const nsACString &aValue,
|
||||
const nsACString &aHost,
|
||||
const nsACString &aPath,
|
||||
PRInt64 aExpiry,
|
||||
PRInt64 aCreationID,
|
||||
PRBool aIsSession,
|
||||
PRBool aIsSecure,
|
||||
PRBool aIsHttpOnly,
|
||||
nsCookieStatus aStatus,
|
||||
nsCookiePolicy aPolicy)
|
||||
PRInt64 aExpiry,
|
||||
PRInt64 aCreationID,
|
||||
PRBool aIsSession,
|
||||
PRBool aIsSecure,
|
||||
PRBool aIsHttpOnly,
|
||||
nsCookieStatus aStatus,
|
||||
nsCookiePolicy aPolicy)
|
||||
{
|
||||
// find the required string buffer size, adding 4 for the terminating nulls
|
||||
const PRUint32 stringLength = aName.Length() + aValue.Length() +
|
||||
@ -143,7 +143,7 @@ NS_IMETHODIMP nsCookie::GetIsDomain(PRBool *aIsDomain) { *aIsDomain = IsDoma
|
||||
NS_IMETHODIMP nsCookie::GetIsSecure(PRBool *aIsSecure) { *aIsSecure = IsSecure(); return NS_OK; }
|
||||
NS_IMETHODIMP nsCookie::GetStatus(nsCookieStatus *aStatus) { *aStatus = Status(); return NS_OK; }
|
||||
NS_IMETHODIMP nsCookie::GetPolicy(nsCookiePolicy *aPolicy) { *aPolicy = Policy(); return NS_OK; }
|
||||
NS_IMETHODIMP nsCookie::GetHttpOnly(PRBool *aHttpOnly) { *aHttpOnly = IsHttpOnly(); return NS_OK; }
|
||||
NS_IMETHODIMP nsCookie::GetIsHttpOnly(PRBool *aHttpOnly) { *aHttpOnly = IsHttpOnly(); return NS_OK; }
|
||||
|
||||
// compatibility method, for use with the legacy nsICookie interface.
|
||||
// here, expires == 0 denotes a session cookie.
|
||||
|
||||
@ -1051,6 +1051,7 @@ nsCookieService::Add(const nsACString &aDomain,
|
||||
const nsACString &aName,
|
||||
const nsACString &aValue,
|
||||
PRBool aIsSecure,
|
||||
PRBool aIsHttpOnly,
|
||||
PRBool aIsSession,
|
||||
PRInt64 aExpiry)
|
||||
{
|
||||
@ -1062,7 +1063,7 @@ nsCookieService::Add(const nsACString &aDomain,
|
||||
currentTimeInUsec,
|
||||
aIsSession,
|
||||
aIsSecure,
|
||||
PR_FALSE,
|
||||
aIsHttpOnly,
|
||||
nsICookie::STATUS_UNKNOWN,
|
||||
nsICookie::POLICY_UNKNOWN);
|
||||
if (!cookie) {
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
#include "nsICookieManager2.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsILineInputStream.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
@ -934,7 +933,7 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
|
||||
PRInt32 numInts;
|
||||
PRInt64 expires;
|
||||
PRBool isDomain;
|
||||
nsInt64 currentTime = nsInt64(PR_Now()) / nsInt64(1000000);
|
||||
PRInt64 currentTime = PR_Now() / PR_USEC_PER_SEC;
|
||||
|
||||
nsCOMPtr<nsICookieManager2> cookieManager(
|
||||
do_GetService(NS_COOKIEMANAGER_CONTRACTID, &rv));
|
||||
@ -974,7 +973,7 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
|
||||
char* iter = buffer.BeginWriting();
|
||||
*(iter += nameIndex - 1) = char(0);
|
||||
numInts = PR_sscanf(buffer.get() + expiresIndex, "%lld", &expires);
|
||||
if (numInts != 1 || nsInt64(expires) < currentTime)
|
||||
if (numInts != 1 || expires < currentTime)
|
||||
continue;
|
||||
|
||||
isDomain = Substring(buffer, isDomainIndex,
|
||||
@ -989,15 +988,12 @@ nsNetscapeProfileMigratorBase::ImportNetscapeCookies(nsIFile* aCookiesFile)
|
||||
|
||||
// create a new nsCookie and assign the data.
|
||||
rv = cookieManager->Add(host,
|
||||
Substring(buffer, pathIndex,
|
||||
secureIndex - pathIndex - 1),
|
||||
Substring(buffer, nameIndex,
|
||||
cookieIndex - nameIndex - 1),
|
||||
Substring(buffer, cookieIndex,
|
||||
buffer.Length() - cookieIndex),
|
||||
Substring(buffer, secureIndex,
|
||||
expiresIndex - secureIndex - 1).Equals(kTrue),
|
||||
PR_FALSE,
|
||||
Substring(buffer, pathIndex, secureIndex - pathIndex - 1),
|
||||
Substring(buffer, nameIndex, cookieIndex - nameIndex - 1),
|
||||
Substring(buffer, cookieIndex, buffer.Length() - cookieIndex),
|
||||
Substring(buffer, secureIndex, expiresIndex - secureIndex - 1).Equals(kTrue),
|
||||
PR_FALSE, // isHttpOnly
|
||||
PR_FALSE, // isSession
|
||||
expires);
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
#include "nsSuiteProfileMigratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsICookieManager2.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
#include "nsSuiteProfileMigratorUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsICookieManager2.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIPasswordManagerInternal.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user