mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
Bug 580449 - Address nsCookieService.cpp review. r=jdm, a=fennec2.0+
This commit is contained in:
parent
e40712bedd
commit
75f1d1f405
@ -75,8 +75,8 @@ CookieServiceParent::RecvGetCookieString(const IPC::URI& aHost,
|
||||
if (!hostURI)
|
||||
return false;
|
||||
|
||||
mCookieService->GetCookieInternal(hostURI, originatingURI,
|
||||
aFromHttp, *aResult);
|
||||
mCookieService->GetCookieStringInternal(hostURI, originatingURI,
|
||||
aFromHttp, *aResult);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1075,16 +1075,7 @@ nsCookieService::GetCookieString(nsIURI *aHostURI,
|
||||
nsIChannel *aChannel,
|
||||
char **aCookie)
|
||||
{
|
||||
NS_ENSURE_ARG(aHostURI);
|
||||
NS_ENSURE_ARG(aCookie);
|
||||
|
||||
nsCOMPtr<nsIURI> originatingURI;
|
||||
GetOriginatingURI(aChannel, getter_AddRefs(originatingURI));
|
||||
|
||||
nsCAutoString result;
|
||||
GetCookieInternal(aHostURI, originatingURI, PR_FALSE, result);
|
||||
*aCookie = result.IsEmpty() ? nsnull : ToNewCString(result);
|
||||
return NS_OK;
|
||||
return GetCookieStringCommon(aHostURI, aChannel, false, aCookie);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1092,6 +1083,15 @@ nsCookieService::GetCookieStringFromHttp(nsIURI *aHostURI,
|
||||
nsIURI *aFirstURI,
|
||||
nsIChannel *aChannel,
|
||||
char **aCookie)
|
||||
{
|
||||
return GetCookieStringCommon(aHostURI, aChannel, true, aCookie);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCookieService::GetCookieStringCommon(nsIURI *aHostURI,
|
||||
nsIChannel *aChannel,
|
||||
bool aHttpBound,
|
||||
char** aCookie)
|
||||
{
|
||||
NS_ENSURE_ARG(aHostURI);
|
||||
NS_ENSURE_ARG(aCookie);
|
||||
@ -1100,7 +1100,7 @@ nsCookieService::GetCookieStringFromHttp(nsIURI *aHostURI,
|
||||
GetOriginatingURI(aChannel, getter_AddRefs(originatingURI));
|
||||
|
||||
nsCAutoString result;
|
||||
GetCookieInternal(aHostURI, originatingURI, PR_TRUE, result);
|
||||
GetCookieStringInternal(aHostURI, originatingURI, aHttpBound, result);
|
||||
*aCookie = result.IsEmpty() ? nsnull : ToNewCString(result);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1111,16 +1111,7 @@ nsCookieService::SetCookieString(nsIURI *aHostURI,
|
||||
const char *aCookieHeader,
|
||||
nsIChannel *aChannel)
|
||||
{
|
||||
NS_ENSURE_ARG(aHostURI);
|
||||
NS_ENSURE_ARG(aCookieHeader);
|
||||
|
||||
nsCOMPtr<nsIURI> originatingURI;
|
||||
GetOriginatingURI(aChannel, getter_AddRefs(originatingURI));
|
||||
|
||||
nsDependentCString cookieString(aCookieHeader);
|
||||
SetCookieStringInternal(aHostURI, originatingURI,
|
||||
cookieString, EmptyCString(), PR_FALSE);
|
||||
return NS_OK;
|
||||
return SetCookieStringCommon(aHostURI, aCookieHeader, NULL, aChannel, false);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1130,6 +1121,17 @@ nsCookieService::SetCookieStringFromHttp(nsIURI *aHostURI,
|
||||
const char *aCookieHeader,
|
||||
const char *aServerTime,
|
||||
nsIChannel *aChannel)
|
||||
{
|
||||
return SetCookieStringCommon(aHostURI, aCookieHeader, aServerTime, aChannel,
|
||||
true);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCookieService::SetCookieStringCommon(nsIURI *aHostURI,
|
||||
const char *aCookieHeader,
|
||||
const char *aServerTime,
|
||||
nsIChannel *aChannel,
|
||||
bool aFromHttp)
|
||||
{
|
||||
NS_ENSURE_ARG(aHostURI);
|
||||
NS_ENSURE_ARG(aCookieHeader);
|
||||
@ -1140,7 +1142,7 @@ nsCookieService::SetCookieStringFromHttp(nsIURI *aHostURI,
|
||||
nsDependentCString cookieString(aCookieHeader);
|
||||
nsDependentCString serverTime(aServerTime ? aServerTime : "");
|
||||
SetCookieStringInternal(aHostURI, originatingURI, cookieString,
|
||||
serverTime, PR_TRUE);
|
||||
serverTime, aFromHttp);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1151,6 +1153,8 @@ nsCookieService::SetCookieStringInternal(nsIURI *aHostURI,
|
||||
const nsCString &aServerTime,
|
||||
PRBool aFromHttp)
|
||||
{
|
||||
NS_ASSERTION(aHostURI, "null host!");
|
||||
|
||||
// get the base domain for the host URI.
|
||||
// e.g. for "www.bbc.co.uk", this would be "bbc.co.uk".
|
||||
// file:// URI's (i.e. with an empty host) are allowed, but any other
|
||||
@ -1879,15 +1883,12 @@ public:
|
||||
};
|
||||
|
||||
void
|
||||
nsCookieService::GetCookieInternal(nsIURI *aHostURI,
|
||||
nsIURI *aOriginatingURI,
|
||||
PRBool aHttpBound,
|
||||
nsCString &aCookieString)
|
||||
nsCookieService::GetCookieStringInternal(nsIURI *aHostURI,
|
||||
nsIURI *aOriginatingURI,
|
||||
PRBool aHttpBound,
|
||||
nsCString &aCookieString)
|
||||
{
|
||||
if (!aHostURI) {
|
||||
COOKIE_LOGFAILURE(GET_COOKIE, nsnull, nsnull, "host URI is null");
|
||||
return;
|
||||
}
|
||||
NS_ASSERTION(aHostURI, "null host!");
|
||||
|
||||
// get the base domain, host, and path from the URI.
|
||||
// e.g. for "www.bbc.co.uk", the base domain would be "bbc.co.uk".
|
||||
@ -2073,6 +2074,8 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI,
|
||||
PRInt64 aServerTime,
|
||||
PRBool aFromHttp)
|
||||
{
|
||||
NS_ASSERTION(aHostURI, "null host!");
|
||||
|
||||
// create a stack-based nsCookieAttributes, to store all the
|
||||
// attributes parsed from the cookie
|
||||
nsCookieAttributes cookieAttributes;
|
||||
@ -2140,7 +2143,8 @@ nsCookieService::SetCookieInternal(nsIURI *aHostURI,
|
||||
if (mPermissionService) {
|
||||
PRBool permission;
|
||||
// Not passing an nsIChannel here means CanSetCookie will use the currently
|
||||
// active window to display the prompt. This isn't exactly ideal...
|
||||
// active window to display the prompt. This isn't exactly ideal, but this
|
||||
// code is going away. See bug 546746.
|
||||
mPermissionService->CanSetCookie(aHostURI,
|
||||
nsnull,
|
||||
static_cast<nsICookie2*>(static_cast<nsCookie*>(cookie)),
|
||||
|
@ -228,7 +228,9 @@ class nsCookieService : public nsICookieService
|
||||
nsresult NormalizeHost(nsCString &aHost);
|
||||
nsresult GetBaseDomain(nsIURI *aHostURI, nsCString &aBaseDomain, PRBool &aRequireHostMatch);
|
||||
nsresult GetBaseDomainFromHost(const nsACString &aHost, nsCString &aBaseDomain);
|
||||
void GetCookieInternal(nsIURI *aHostURI, nsIURI *aOriginatingURI, PRBool aHttpBound, nsCString &aCookie);
|
||||
nsresult GetCookieStringCommon(nsIURI *aHostURI, nsIChannel *aChannel, bool aHttpBound, char** aCookie);
|
||||
void GetCookieStringInternal(nsIURI *aHostURI, nsIURI *aOriginatingURI, PRBool aHttpBound, nsCString &aCookie);
|
||||
nsresult SetCookieStringCommon(nsIURI *aHostURI, const char *aCookieHeader, const char *aServerTime, nsIChannel *aChannel, bool aFromHttp);
|
||||
void SetCookieStringInternal(nsIURI *aHostURI, nsIURI *aOriginatingURI, const nsCString &aCookieHeader, const nsCString &aServerTime, PRBool aFromHttp);
|
||||
PRBool SetCookieInternal(nsIURI *aHostURI, const nsCString& aBaseDomain, PRBool aRequireHostMatch, CookieStatus aStatus, nsDependentCString &aCookieHeader, PRInt64 aServerTime, PRBool aFromHttp);
|
||||
void AddInternal(const nsCString& aBaseDomain, nsCookie *aCookie, PRInt64 aCurrentTimeInUsec, nsIURI *aHostURI, const char *aCookieHeader, PRBool aFromHttp);
|
||||
|
Loading…
x
Reference in New Issue
Block a user