From 8fa070e5cd21eb9df58187af141f37e42f4e8083 Mon Sep 17 00:00:00 2001 From: "darin%netscape.com" Date: Wed, 25 Sep 2002 21:28:53 +0000 Subject: [PATCH] fixes bug 170648 "eliminate referrer type from nsIHttpChannel in preparation for freezing" r=dougt sr=rpotts git-svn-id: svn://10.0.0.236/trunk@130442 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsScriptLoader.cpp | 3 +-- .../content/html/style/src/nsCSSLoader.cpp | 3 +-- mozilla/docshell/base/nsDocShell.cpp | 13 ++++++++---- mozilla/layout/style/nsCSSLoader.cpp | 3 +-- mozilla/modules/libpr0n/src/imgLoader.cpp | 2 +- .../plugin/base/src/nsPluginHostImpl.cpp | 2 +- mozilla/netwerk/base/public/nsIChannel.idl | 12 +++++++++-- .../netwerk/base/public/nsIStreamLoader.idl | 3 +-- mozilla/netwerk/base/public/nsNetUtil.h | 6 ++---- mozilla/netwerk/base/src/nsStreamLoader.cpp | 5 ++--- .../protocol/http/public/nsIHttpChannel.idl | 12 ++--------- .../protocol/http/src/nsHttpChannel.cpp | 21 +++++++++++-------- .../netwerk/protocol/http/src/nsHttpChannel.h | 1 - 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp index 932dc24d789..25f445b650f 100644 --- a/mozilla/content/base/src/nsScriptLoader.cpp +++ b/mozilla/content/base/src/nsScriptLoader.cpp @@ -387,8 +387,7 @@ nsScriptLoader::ProcessScriptElement(nsIDOMHTMLScriptElement *aElement, nsCOMPtr channel; rv = NS_NewStreamLoader(getter_AddRefs(loader), scriptURI, this, reqsup, loadGroup, prompter, - nsIChannel::LOAD_NORMAL, documentURI, - nsIHttpChannel::REFERRER_INLINES); + nsIChannel::LOAD_NORMAL, documentURI); if (NS_FAILED(rv)) { mPendingRequests.RemoveElement(reqsup, 0); return FireErrorNotification(rv, aElement, aObserver); diff --git a/mozilla/content/html/style/src/nsCSSLoader.cpp b/mozilla/content/html/style/src/nsCSSLoader.cpp index bea6e7f8879..d8256c8bb6a 100644 --- a/mozilla/content/html/style/src/nsCSSLoader.cpp +++ b/mozilla/content/html/style/src/nsCSSLoader.cpp @@ -1578,8 +1578,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData) if (document_uri) { nsCOMPtr httpChannel(do_QueryInterface(channel)); if (httpChannel) { - result = httpChannel->SetReferrer(document_uri, - nsIHttpChannel::REFERRER_INLINES); + result = httpChannel->SetReferrer(document_uri); } } diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index c18e0083bcd..45143b2f4ac 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -5079,6 +5079,12 @@ nsDocShell::DoURILoad(nsIURI * aURI, getter_AddRefs(loadGroup)); if (NS_FAILED(rv)) return rv; + nsLoadFlags loadFlags = nsIRequest::LOAD_NORMAL; + if (firstParty) { + // tag first party URL loads + loadFlags |= nsIChannel::LOAD_INITIAL_DOCUMENT_URI; + } + // open a channel for the url nsCOMPtr channel; @@ -5086,14 +5092,14 @@ nsDocShell::DoURILoad(nsIURI * aURI, aURI, nsnull, loadGroup, - NS_STATIC_CAST(nsIInterfaceRequestor *, this)); + NS_STATIC_CAST(nsIInterfaceRequestor *, this), + loadFlags); if (NS_FAILED(rv)) return rv; channel->SetOriginalURI(aURI); nsCOMPtr httpChannel(do_QueryInterface(channel)); - if (httpChannel) { if (firstParty) { httpChannel->SetDocumentURI(aURI); @@ -5166,8 +5172,7 @@ nsDocShell::DoURILoad(nsIURI * aURI, } // Set the referrer explicitly if (aReferrerURI) // Referrer is currenly only set for link clicks here. - httpChannel->SetReferrer(aReferrerURI, - nsIHttpChannel::REFERRER_LINK_CLICK); + httpChannel->SetReferrer(aReferrerURI); } // We want to use the pref for directory listings nsCOMPtr dirList = do_QueryInterface(channel); diff --git a/mozilla/layout/style/nsCSSLoader.cpp b/mozilla/layout/style/nsCSSLoader.cpp index bea6e7f8879..d8256c8bb6a 100644 --- a/mozilla/layout/style/nsCSSLoader.cpp +++ b/mozilla/layout/style/nsCSSLoader.cpp @@ -1578,8 +1578,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData) if (document_uri) { nsCOMPtr httpChannel(do_QueryInterface(channel)); if (httpChannel) { - result = httpChannel->SetReferrer(document_uri, - nsIHttpChannel::REFERRER_INLINES); + result = httpChannel->SetReferrer(document_uri); } } diff --git a/mozilla/modules/libpr0n/src/imgLoader.cpp b/mozilla/modules/libpr0n/src/imgLoader.cpp index d4b42c149c4..341f52731d6 100644 --- a/mozilla/modules/libpr0n/src/imgLoader.cpp +++ b/mozilla/modules/libpr0n/src/imgLoader.cpp @@ -187,7 +187,7 @@ static nsresult NewImageChannel(nsIChannel **aResult, newHttpChannel = do_QueryInterface(*aResult); if (newHttpChannel) { newHttpChannel->SetDocumentURI(aInitialDocumentURI); - newHttpChannel->SetReferrer(aReferringURI, nsIHttpChannel::REFERRER_INLINES); + newHttpChannel->SetReferrer(aReferringURI); } return NS_OK; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 9f57ca68016..e123e30c9fc 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -5831,7 +5831,7 @@ nsresult nsPluginHostImpl::NewEmbededPluginStream(nsIURI* aURL, if (httpChannel && doc) { nsCOMPtr referrerURL; if (NS_SUCCEEDED(doc->GetBaseURL(*getter_AddRefs(referrerURL)))) - httpChannel->SetReferrer(referrerURL, nsIHttpChannel::REFERRER_INLINES); + httpChannel->SetReferrer(referrerURL); } rv = channel->AsyncOpen(listener, nsnull); diff --git a/mozilla/netwerk/base/public/nsIChannel.idl b/mozilla/netwerk/base/public/nsIChannel.idl index 6072a7b2b39..5847f04e563 100644 --- a/mozilla/netwerk/base/public/nsIChannel.idl +++ b/mozilla/netwerk/base/public/nsIChannel.idl @@ -145,11 +145,13 @@ interface nsIChannel : nsIRequest /************************************************************************** * Channel specific load flags: + * + * Bits 20-31 are reserved for future use by this interface */ /** - * Used (e.g., by the uriloader and docshell) to indicate whether or not - * the channel corresponds to the toplevel document. + * Set (e.g., by the docshell) to indicate whether or not the channel + * corresponds to a document URI. */ const unsigned long LOAD_DOCUMENT_URI = 1 << 16; @@ -165,4 +167,10 @@ interface nsIChannel : nsIRequest * used by the multipart/replace stream converter. */ const unsigned long LOAD_REPLACE = 1 << 18; + + /** + * Set (e.g., by the docshell) to indicate whether or not the channel + * corresponds to an initial document URI load (e.g., link click). + */ + const unsigned long LOAD_INITIAL_DOCUMENT_URI = 1 << 19; }; diff --git a/mozilla/netwerk/base/public/nsIStreamLoader.idl b/mozilla/netwerk/base/public/nsIStreamLoader.idl index 0eaeaff38ad..0f45b9ad9cd 100644 --- a/mozilla/netwerk/base/public/nsIStreamLoader.idl +++ b/mozilla/netwerk/base/public/nsIStreamLoader.idl @@ -63,8 +63,7 @@ interface nsIStreamLoader : nsISupports in nsILoadGroup loadGroup, in nsIInterfaceRequestor notificationCallbacks, in nsLoadFlags loadAttributes, - in nsIURI referrer, - in unsigned long refererFlags); + in nsIURI referrer); /** * Gets the number of bytes read so far. diff --git a/mozilla/netwerk/base/public/nsNetUtil.h b/mozilla/netwerk/base/public/nsNetUtil.h index fb99368ec2c..c6d8089f182 100644 --- a/mozilla/netwerk/base/public/nsNetUtil.h +++ b/mozilla/netwerk/base/public/nsNetUtil.h @@ -415,8 +415,7 @@ NS_NewStreamLoader(nsIStreamLoader* *result, nsILoadGroup* loadGroup = nsnull, nsIInterfaceRequestor* notificationCallbacks = nsnull, nsLoadFlags loadAttributes = NS_STATIC_CAST(nsLoadFlags, nsIRequest::LOAD_NORMAL), - nsIURI* referrer = nsnull, - PRUint32 referrerFlags = 0) + nsIURI* referrer = nsnull) { nsresult rv; nsCOMPtr loader; @@ -427,8 +426,7 @@ NS_NewStreamLoader(nsIStreamLoader* *result, getter_AddRefs(loader)); if (NS_FAILED(rv)) return rv; rv = loader->Init(uri, observer, context, loadGroup, - notificationCallbacks, loadAttributes, referrer, - referrerFlags); + notificationCallbacks, loadAttributes, referrer); if (NS_FAILED(rv)) return rv; *result = loader; diff --git a/mozilla/netwerk/base/src/nsStreamLoader.cpp b/mozilla/netwerk/base/src/nsStreamLoader.cpp index 51450b38ad9..f0e73b200b6 100644 --- a/mozilla/netwerk/base/src/nsStreamLoader.cpp +++ b/mozilla/netwerk/base/src/nsStreamLoader.cpp @@ -52,8 +52,7 @@ nsStreamLoader::Init(nsIURI* aURL, nsILoadGroup* aGroup, nsIInterfaceRequestor* notificationCallbacks, nsLoadFlags loadAttributes, - nsIURI *referrer, - PRUint32 referrerFlags) + nsIURI *referrer) { nsresult rv = NS_OK; @@ -67,7 +66,7 @@ nsStreamLoader::Init(nsIURI* aURL, nsCOMPtr httpChannel(do_QueryInterface(channel)); if (httpChannel) { - rv = httpChannel->SetReferrer(referrer, referrerFlags); + rv = httpChannel->SetReferrer(referrer); if (NS_FAILED(rv)) return rv; } } diff --git a/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl index 1a961c73c56..4dcf688bdf7 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl @@ -42,17 +42,9 @@ interface nsIHttpChannel : nsIChannel /** * Get/set the referrer URI on the request. This is the address (URI) of * the resource from which this channel's URI was obtained (see RFC2616 - * section 14.36). The referrer type may be used to block the referrer - * from being sent in certain cases. + * section 14.36). */ - readonly attribute nsIURI referrer; - void setReferrer(in nsIURI referrer, in unsigned long referrerType); - - /* possible values for the referrerType */ - const unsigned long REFERRER_NONE = 0; - const unsigned long REFERRER_LINK_CLICK = 1; // http link clicks - const unsigned long REFERRER_INLINES = 2; // images and other inlines - const unsigned long REFERRER_NON_HTTP = 3; // e.g. news or FTP clicks + attribute nsIURI referrer; /** * An http channel can own a reference to the document URI diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index 582ddc80224..6911dbc8c28 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -64,7 +64,6 @@ nsHttpChannel::nsHttpChannel() , mStatus(NS_OK) , mLogicalOffset(0) , mCapabilities(0) - , mReferrerType(REFERRER_NONE) , mCachedResponseHead(nsnull) , mCacheAccess(0) , mPostID(0) @@ -398,8 +397,9 @@ nsHttpChannel::SetupTransaction() // XXX does the toplevel document check really belong here? // XXX or, should we push it out entirely to necko consumers? PRUint8 caps = mCapabilities; - if (!mAllowPipelining || (mURI == mDocumentURI) || - !(mRequestHead.Method() == nsHttp::Get || mRequestHead.Method() == nsHttp::Head)) { + if (!mAllowPipelining || (mLoadFlags && LOAD_INITIAL_DOCUMENT_URI) || + !(mRequestHead.Method() == nsHttp::Get || + mRequestHead.Method() == nsHttp::Head)) { LOG(("nsHttpChannel::SetupTransaction [this=%x] pipelining disallowed\n", this)); caps &= ~NS_HTTP_ALLOW_PIPELINING; } @@ -1546,7 +1546,7 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType) httpChannel->SetDocumentURI(mDocumentURI); // convey the referrer if one was used for this channel to the next one if (mReferrer) - httpChannel->SetReferrer(mReferrer, mReferrerType); + httpChannel->SetReferrer(mReferrer); // convey the mApplyConversion flag (bug 91862) httpChannel->SetApplyConversion(mApplyConversion); // convey the mAllowPipelining flag @@ -2459,11 +2459,17 @@ nsHttpChannel::GetReferrer(nsIURI **referrer) } NS_IMETHODIMP -nsHttpChannel::SetReferrer(nsIURI *referrerIn, PRUint32 referrerType) +nsHttpChannel::SetReferrer(nsIURI *referrerIn) { NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS); - if (nsHttpHandler::get()->ReferrerLevel() < referrerType) + PRUint32 referrerLevel; + if (mLoadFlags & LOAD_INITIAL_DOCUMENT_URI) + referrerLevel = 1; // user action + else + referrerLevel = 2; // inline content + + if (nsHttpHandler::get()->ReferrerLevel() < referrerLevel) return NS_OK; nsCOMPtr referrer = referrerIn; @@ -2538,9 +2544,6 @@ nsHttpChannel::SetReferrer(nsIURI *referrerIn, PRUint32 referrerType) // save a copy of the referrer so we can return it if requested mReferrer = referrer; - // save a copy of the referrer type for redirects - mReferrerType = (PRUint8) referrerType; - // clear the old referer first mRequestHead.SetHeader(nsHttp::Referer, NS_LITERAL_CSTRING("")); diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.h b/mozilla/netwerk/protocol/http/src/nsHttpChannel.h index 41f5ec0f404..0ee43afa649 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.h @@ -159,7 +159,6 @@ private: PRUint32 mStatus; PRUint32 mLogicalOffset; PRUint8 mCapabilities; - PRUint8 mReferrerType; // cache specific data nsCOMPtr mCacheEntry;