зеркало из https://github.com/mozilla/pjs.git
bug 107579, infrastructure for detecting 3rd-party cookies, r=darin,rpotts, sr=devitz
This commit is contained in:
Родитель
b16ab30f08
Коммит
b26cb82e9b
|
@ -840,6 +840,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
SetReferrer(referrer);
|
||||
}
|
||||
|
||||
mHttpChannel = httpChannel;
|
||||
|
||||
nsCOMPtr<nsICachingChannel> cachingChan = do_QueryInterface(httpChannel);
|
||||
if (cachingChan) {
|
||||
nsCOMPtr<nsISupports> cacheToken;
|
||||
|
@ -2187,7 +2189,7 @@ nsHTMLDocument::SetCookie(const nsAReadableString& aCookie)
|
|||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
char* cookie = ToNewCString(aCookie);
|
||||
if (cookie) {
|
||||
result = service->SetCookieString(mDocumentURL, prompt, cookie, 0);
|
||||
result = service->SetCookieString(mDocumentURL, prompt, cookie, mHttpChannel);
|
||||
nsCRT::free(cookie);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsRDFCID.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "pldhash.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
|
||||
// Document.Write() related
|
||||
#include "nsIWyciwygChannel.h"
|
||||
|
@ -227,6 +228,7 @@ protected:
|
|||
nsString* mBaseTarget;
|
||||
nsString* mLastModified;
|
||||
nsString* mReferrer;
|
||||
nsCOMPtr<nsIHttpChannel> mHttpChannel;
|
||||
nsDTDMode mDTDMode;
|
||||
nsCOMPtr<nsISupportsArray> mImageMaps;
|
||||
|
||||
|
|
|
@ -484,7 +484,8 @@ nsDocShell::ConvertLoadTypeToDocShellLoadInfo(PRUint32 aLoadType)
|
|||
NS_IMETHODIMP
|
||||
nsDocShell::LoadURI(nsIURI * aURI,
|
||||
nsIDocShellLoadInfo * aLoadInfo,
|
||||
PRUint32 aLoadFlags)
|
||||
PRUint32 aLoadFlags,
|
||||
PRBool firstParty)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
|
@ -646,7 +647,8 @@ nsDocShell::LoadURI(nsIURI * aURI,
|
|||
postStream,
|
||||
nsnull, // No headers stream
|
||||
loadType,
|
||||
nsnull); // No SHEntry
|
||||
nsnull, // No SHEntry
|
||||
firstParty);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -2366,7 +2368,7 @@ nsDocShell::LoadURI(const PRUnichar * aURI,
|
|||
|
||||
// XXX: Need to pass in the extra headers stream too...
|
||||
|
||||
rv = LoadURI(uri, loadInfo, 0);
|
||||
rv = LoadURI(uri, loadInfo, 0, PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -2415,7 +2417,8 @@ nsDocShell::Reload(PRUint32 aReloadFlags)
|
|||
nsnull, // No post data
|
||||
nsnull, // No headers data
|
||||
type, // Load type
|
||||
nsnull); // No SHEntry
|
||||
nsnull, // No SHEntry
|
||||
PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -4281,7 +4284,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData,
|
||||
PRUint32 aLoadType,
|
||||
nsISHEntry * aSHEntry)
|
||||
nsISHEntry * aSHEntry,
|
||||
PRBool firstParty)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -4392,7 +4396,8 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
aPostData,
|
||||
aHeadersData,
|
||||
aLoadType,
|
||||
aSHEntry);
|
||||
aSHEntry,
|
||||
firstParty);
|
||||
if (rv == NS_ERROR_NO_CONTENT) {
|
||||
if (bIsNewWindow) {
|
||||
//
|
||||
|
@ -4507,7 +4512,7 @@ nsDocShell::InternalLoad(nsIURI * aURI,
|
|||
// been called.
|
||||
mLSHE = aSHEntry;
|
||||
|
||||
rv = DoURILoad(aURI, aReferrer, owner, aPostData, aHeadersData);
|
||||
rv = DoURILoad(aURI, aReferrer, owner, aPostData, aHeadersData, firstParty);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -4582,7 +4587,8 @@ nsresult nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
nsIURI * aReferrerURI,
|
||||
nsISupports * aOwner,
|
||||
nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData)
|
||||
nsIInputStream * aHeadersData,
|
||||
PRBool firstParty)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURILoader> uriLoader;
|
||||
|
@ -4611,6 +4617,15 @@ nsresult nsDocShell::DoURILoad(nsIURI * aURI,
|
|||
channel->SetOriginalURI(aURI);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
|
||||
if (httpChannel) {
|
||||
if (firstParty) {
|
||||
httpChannel->SetDocumentURI(aURI);
|
||||
} else {
|
||||
httpChannel->SetDocumentURI(aReferrerURI);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If this is a HTTP channel, then set up the HTTP specific information
|
||||
// (ie. POST data, referrer, ...)
|
||||
|
@ -5484,7 +5499,8 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType)
|
|||
postData, // Post data stream
|
||||
nsnull, // No headers stream
|
||||
aLoadType, // Load type
|
||||
aEntry); // SHEntry
|
||||
aEntry, // SHEntry
|
||||
PR_TRUE);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -6193,13 +6209,13 @@ nsRefreshTimer::Notify(nsITimer * aTimer)
|
|||
* its refreshData instance to be released...
|
||||
*/
|
||||
mDocShell->LoadURI(mURI, loadInfo,
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE, PR_TRUE);
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadRefresh);
|
||||
mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
|
||||
mDocShell->LoadURI(mURI, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,8 @@ protected:
|
|||
nsIURI * aReferrer,
|
||||
nsISupports * aOwner,
|
||||
nsIInputStream * aPostData,
|
||||
nsIInputStream * aHeadersData);
|
||||
nsIInputStream * aHeadersData,
|
||||
PRBool firstParty);
|
||||
NS_IMETHOD AddHeadersToChannel(nsIInputStream * aHeadersData,
|
||||
nsIChannel * aChannel);
|
||||
virtual nsresult DoChannelLoad(nsIChannel * aChannel,
|
||||
|
|
|
@ -67,7 +67,8 @@ interface nsIDocShell : nsISupports
|
|||
*/
|
||||
[noscript]void loadURI(in nsIURI uri,
|
||||
in nsIDocShellLoadInfo loadInfo,
|
||||
in unsigned long aLoadFlags);
|
||||
in unsigned long aLoadFlags,
|
||||
in boolean firstParty);
|
||||
|
||||
/**
|
||||
* Loads a given stream. This will give priority to loading the requested
|
||||
|
@ -121,7 +122,8 @@ interface nsIDocShell : nsISupports
|
|||
in nsIInputStream aPostDataStream,
|
||||
in nsIInputStream aHeadersStream,
|
||||
in unsigned long aLoadFlags,
|
||||
in nsISHEntry aSHEntry);
|
||||
in nsISHEntry aSHEntry,
|
||||
in boolean firstParty);
|
||||
|
||||
/**
|
||||
* Creates a DocShellLoadInfo object that you can manipulate and then pass
|
||||
|
|
|
@ -610,7 +610,8 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
|||
aPostDataStream, // Post data stream
|
||||
aHeadersDataStream, // Headers stream
|
||||
LOAD_LINK, // Load type
|
||||
nsnull); // No SHEntry
|
||||
nsnull, // No SHEntry
|
||||
PR_TRUE); // first party site
|
||||
}
|
||||
break;
|
||||
case eLinkVerb_Embed:
|
||||
|
@ -1005,8 +1006,8 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
|||
inputStream, // Post data stream
|
||||
nsnull, // No headers stream
|
||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE,// Load type
|
||||
nsnull); // No SHEntry
|
||||
|
||||
nsnull, // No SHEntry
|
||||
PR_TRUE); // first party site
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
il->LoadImage(imgURI, nsnull, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1472,7 +1472,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
il->LoadImage(newURI, nsnull, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1909,8 +1909,10 @@ nsImageFrame::RealLoadImage(const nsAReadableString& aSpec, nsIPresContext *aPre
|
|||
/* set this back to FALSE before we do the real load */
|
||||
mInitialLoadCompleted = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
rv = aPresContext->GetBaseURL(getter_AddRefs(baseURI));
|
||||
nsCOMPtr<imgIRequest> tempRequest;
|
||||
return il->LoadImage(uri, loadGroup, mListener, aPresContext, loadFlags, nsnull, aRequest, getter_AddRefs(tempRequest));
|
||||
return il->LoadImage(uri, baseURI, loadGroup, mListener, aPresContext, loadFlags, nsnull, aRequest, getter_AddRefs(tempRequest));
|
||||
}
|
||||
|
||||
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */
|
||||
|
|
|
@ -145,7 +145,7 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
il->LoadImage(imgURI, nsnull, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1472,7 +1472,7 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
il->LoadImage(newURI, nsnull, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1909,8 +1909,10 @@ nsImageFrame::RealLoadImage(const nsAReadableString& aSpec, nsIPresContext *aPre
|
|||
/* set this back to FALSE before we do the real load */
|
||||
mInitialLoadCompleted = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
rv = aPresContext->GetBaseURL(getter_AddRefs(baseURI));
|
||||
nsCOMPtr<imgIRequest> tempRequest;
|
||||
return il->LoadImage(uri, loadGroup, mListener, aPresContext, loadFlags, nsnull, aRequest, getter_AddRefs(tempRequest));
|
||||
return il->LoadImage(uri, baseURI, loadGroup, mListener, aPresContext, loadFlags, nsnull, aRequest, getter_AddRefs(tempRequest));
|
||||
}
|
||||
|
||||
#define INTERNAL_GOPHER_LENGTH 16 /* "internal-gopher-" length */
|
||||
|
|
|
@ -457,7 +457,7 @@ nsImageBoxFrame::UpdateImage(nsIPresContext* aPresContext, PRBool& aResize)
|
|||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
il->LoadImage(srcURI, loadGroup, mListener, aPresContext, mLoadFlags, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
il->LoadImage(srcURI, nsnull, loadGroup, mListener, aPresContext, mLoadFlags, nsnull, nsnull, getter_AddRefs(mImageRequest));
|
||||
|
||||
aResize = PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -1668,7 +1668,7 @@ nsOutlinerBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID,
|
|||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
mImageGuard = PR_TRUE;
|
||||
il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
il->LoadImage(srcURI, nsnull, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
mImageGuard = PR_FALSE;
|
||||
|
||||
// In a case it was already cached.
|
||||
|
|
|
@ -1668,7 +1668,7 @@ nsOutlinerBodyFrame::GetImage(PRInt32 aRowIndex, const PRUnichar* aColID,
|
|||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
mImageGuard = PR_TRUE;
|
||||
il->LoadImage(srcURI, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
il->LoadImage(srcURI, nsnull, nsnull, listener, mPresContext, nsIRequest::LOAD_NORMAL, nsnull, nsnull, getter_AddRefs(imageRequest));
|
||||
mImageGuard = PR_FALSE;
|
||||
|
||||
// In a case it was already cached.
|
||||
|
|
|
@ -58,7 +58,7 @@ interface imgILoader : nsISupports
|
|||
* @param aRequest A newly created, unused imgIRequest object or NULL for one to
|
||||
be created for you.
|
||||
*/
|
||||
imgIRequest loadImage(in nsIURI aURI, in nsILoadGroup aLoadGroup,
|
||||
imgIRequest loadImage(in nsIURI aURI, in nsIURI parentURL, in nsILoadGroup aLoadGroup,
|
||||
in imgIDecoderObserver aObserver, in nsISupports aCX,
|
||||
in nsLoadFlags aLoadFlags, in nsISupports cacheKey,
|
||||
in imgIRequest aRequest);
|
||||
|
|
|
@ -53,6 +53,12 @@ interface nsIHttpChannel : nsIChannel
|
|||
const unsigned long REFERRER_INLINES = 2; // images and other inlines
|
||||
const unsigned long REFERRER_NON_HTTP = 3; // e.g. news or FTP clicks
|
||||
|
||||
/**
|
||||
* An http channel can own a reference to the document URI
|
||||
*/
|
||||
attribute nsIURI documentURI;
|
||||
|
||||
|
||||
/**
|
||||
* Header strings are case insensitive
|
||||
*/
|
||||
|
|
|
@ -116,6 +116,7 @@ nsHttpChannel::Init(nsIURI *uri,
|
|||
|
||||
mURI = uri;
|
||||
mOriginalURI = uri;
|
||||
mDocumentURI = nsnull;
|
||||
mCapabilities = caps;
|
||||
|
||||
//
|
||||
|
@ -199,10 +200,6 @@ nsHttpChannel::Init(nsIURI *uri,
|
|||
// check to see if authorization headers should be included
|
||||
AddAuthorizationHeaders();
|
||||
|
||||
// Notify nsIHttpNotify implementations
|
||||
rv = nsHttpHandler::get()->OnModifyRequest(this);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "OnModifyRequest failed");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1217,6 +1214,7 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
|
|||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
|
||||
if (redirectType == 305) {
|
||||
// we must repeat the request via the proxy specified by location
|
||||
|
@ -1246,7 +1244,6 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
|
|||
nsCOMPtr<nsIIOService> ioService;
|
||||
rv = nsHttpHandler::get()->GetIOService(getter_AddRefs(ioService));
|
||||
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
rv = ioService->NewURI(location, mURI, getter_AddRefs(newURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -1278,6 +1275,9 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType)
|
|||
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(newChannel);
|
||||
if (httpChannel) {
|
||||
// update the DocumentURI indicator since we were just redirected
|
||||
if (newURI && (mURI == mDocumentURI))
|
||||
httpChannel->SetDocumentURI(newURI);
|
||||
// convey the referrer if one was used for this channel to the next one
|
||||
if (mReferrer)
|
||||
httpChannel->SetReferrer(mReferrer, mReferrerType);
|
||||
|
@ -2069,6 +2069,10 @@ nsHttpChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *context)
|
|||
rv = NS_CheckPortSafety(port, "http", ioService); // this works for https
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Notify nsIHttpNotify implementations
|
||||
rv = nsHttpHandler::get()->OnModifyRequest(this);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "OnModifyRequest failed");
|
||||
|
||||
mIsPending = PR_TRUE;
|
||||
|
||||
|
@ -2110,6 +2114,22 @@ nsHttpChannel::SetRequestMethod(const char *method)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetDocumentURI(nsIURI **aDocumentURI)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocumentURI);
|
||||
*aDocumentURI = mDocumentURI;
|
||||
NS_IF_ADDREF(*aDocumentURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::SetDocumentURI(nsIURI *aDocumentURI)
|
||||
{
|
||||
mDocumentURI = aDocumentURI;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::GetReferrer(nsIURI **referrer)
|
||||
{
|
||||
|
|
|
@ -125,6 +125,7 @@ private:
|
|||
private:
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIURI> mDocumentURI;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
nsCOMPtr<nsISupports> mListenerContext;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
|
|
Загрузка…
Ссылка в новой задаче