зеркало из https://github.com/mozilla/gecko-dev.git
Document referrer propagation through webshell and docloader.
This commit is contained in:
Родитель
d1453f5030
Коммит
21477c4cd3
|
@ -223,14 +223,16 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 localIP = 0,
|
||||
nsISupports * aHistoryState = nsnull);
|
||||
nsISupports * aHistoryState = nsnull,
|
||||
const PRUnichar* aReferrer=nsnull);
|
||||
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
||||
const char* aCommand,
|
||||
nsIInputStream* aPostDataStream=nsnull,
|
||||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 localIP = 0,
|
||||
nsISupports * aHistoryState=nsnull);
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull);
|
||||
|
||||
NS_IMETHOD LoadURI(nsIURI * aUri,
|
||||
const char * aCommand,
|
||||
|
@ -238,7 +240,8 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP=0,
|
||||
nsISupports * aHistoryState=nsnull);
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull);
|
||||
|
||||
NS_IMETHOD Stop(void);
|
||||
|
||||
|
@ -392,7 +395,6 @@ public:
|
|||
NS_IMETHOD SetUrlDispatcher(nsIUrlDispatcher * anObserver);
|
||||
NS_IMETHOD GetUrlDispatcher(nsIUrlDispatcher *& aResult);
|
||||
|
||||
|
||||
protected:
|
||||
void InitFrameData(PRBool aCompleteInitScrolling);
|
||||
nsresult CheckForTrailingSlash(nsIURI* aURL);
|
||||
|
@ -429,6 +431,7 @@ protected:
|
|||
|
||||
nsString mTitle;
|
||||
nsString mURL;
|
||||
nsString mReferrer;
|
||||
|
||||
nsString mOverURL;
|
||||
nsString mOverTarget;
|
||||
|
@ -454,7 +457,8 @@ protected:
|
|||
const char* aCommand,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP);
|
||||
const PRUint32 aLocalIP,
|
||||
const PRUnichar* aReferrer);
|
||||
|
||||
float mZoom;
|
||||
|
||||
|
@ -1644,6 +1648,8 @@ nsWebShell::ChildAt(PRInt32 aIndex, nsIWebShell*& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::GetName(const PRUnichar** aName)
|
||||
{
|
||||
// XXX This is wrong unless the parameter is marked "shared".
|
||||
// It should otherwise be copied and freed by the caller.
|
||||
*aName = mName.GetUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1658,6 +1664,8 @@ nsWebShell::SetName(const PRUnichar* aName)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::GetURL(const PRUnichar** aURL)
|
||||
{
|
||||
// XXX This is wrong unless the parameter is marked "shared".
|
||||
// It should otherwise be copied and freed by the caller.
|
||||
*aURL = mURL.GetUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1910,15 +1918,18 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
PRBool aModifyHistory,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP,
|
||||
nsISupports * aHistoryState)
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
// Initialize margnwidth, marginheight. Put scrolling back the way it was
|
||||
// before the last document was loaded.
|
||||
InitFrameData(PR_FALSE);
|
||||
|
||||
const char *cmd = mViewSource ? "view-source" : "view" ;
|
||||
mViewSource = PR_FALSE; // reset it
|
||||
return LoadURL(aURLSpec, cmd , aPostDataStream,
|
||||
aModifyHistory,aType, aLocalIP, aHistoryState);
|
||||
return LoadURL(aURLSpec, "view", aPostDataStream,
|
||||
aModifyHistory,aType, aLocalIP, aHistoryState,
|
||||
aReferrer);
|
||||
}
|
||||
|
||||
// Nisheeth: returns true if the host and the file parts of
|
||||
|
@ -1968,8 +1979,8 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
const char* aCommand,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP)
|
||||
|
||||
const PRUint32 aLocalIP,
|
||||
const PRUnichar* aReferrer)
|
||||
|
||||
{
|
||||
if (!aUri)
|
||||
|
@ -2094,7 +2105,8 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
nsnull, // Extra Info...
|
||||
mObserver, // Observer
|
||||
aType, // reload type
|
||||
aLocalIP); // load attributes.
|
||||
aLocalIP, // load attributes.
|
||||
aReferrer); // referrer
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2104,12 +2116,15 @@ nsWebShell::LoadURI(nsIURI * aUri,
|
|||
PRBool aModifyHistory,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP,
|
||||
nsISupports * aHistoryState)
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv;
|
||||
CancelRefreshURITimers();
|
||||
nsXPIDLCString scheme, CUriSpec;
|
||||
|
||||
mReferrer = aReferrer;
|
||||
|
||||
rv = aUri->GetScheme(getter_Copies(scheme));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aUri->GetSpec(getter_Copies(CUriSpec));
|
||||
|
@ -2207,7 +2222,7 @@ nsWebShell::LoadURI(nsIURI * aUri,
|
|||
}
|
||||
|
||||
|
||||
return DoLoadURL(aUri, aCommand, aPostDataStream, aType, aLocalIP);
|
||||
return DoLoadURL(aUri, aCommand, aPostDataStream, aType, aLocalIP, aReferrer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2217,7 +2232,8 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
PRBool aModifyHistory,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP,
|
||||
nsISupports * aHistoryState)
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -2304,7 +2320,7 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
|
||||
|
||||
// now that we have a uri, call the REAL LoadURI method which requires a nsIURI.
|
||||
return LoadURI(uri, aCommand, aPostDataStream, aModifyHistory, aType, aLocalIP, aHistoryState);
|
||||
return LoadURI(uri, aCommand, aPostDataStream, aModifyHistory, aType, aLocalIP, aHistoryState, aReferrer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2486,7 +2502,8 @@ nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
|||
"view", // Command
|
||||
nsnull, // Post Data
|
||||
nsIChannel::LOAD_NORMAL, // the reload type
|
||||
0); // load attributes
|
||||
0, // load attributes
|
||||
nsnull); // referrer
|
||||
}
|
||||
return rv;
|
||||
#else
|
||||
|
@ -3001,7 +3018,9 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
|||
{
|
||||
nsIWebShell* shell = GetTarget(target.GetUnicode());
|
||||
if (nsnull != shell) {
|
||||
(void)shell->LoadURL(aURLSpec, aPostDataStream);
|
||||
(void)shell->LoadURL(aURLSpec, aPostDataStream,
|
||||
PR_TRUE, nsIChannel::LOAD_NORMAL,
|
||||
0, nsnull, mURL.GetUnicode());
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
|
@ -3198,8 +3217,9 @@ nsWebShell::ReportScriptError(const char* aErrorString,
|
|||
// XXX To be implemented by scc. The following implementation
|
||||
// is temporary.
|
||||
|
||||
nsCAutoString error;
|
||||
error.SetString(aErrorString);
|
||||
nsAutoString error;
|
||||
error.SetString("JavaScript Error: ");
|
||||
error.Append(aErrorString);
|
||||
error += "\n";
|
||||
|
||||
if (aFileName) {
|
||||
|
@ -3220,7 +3240,16 @@ nsWebShell::ReportScriptError(const char* aErrorString,
|
|||
error += "'\n";
|
||||
}
|
||||
|
||||
printf("JavaScript Error: %s\n", error.GetBuffer());
|
||||
// XXX Ughhh...allocation
|
||||
char* errorStr = error.ToNewCString();
|
||||
if (errorStr) {
|
||||
printf("%s\n", errorStr);
|
||||
Recycle(errorStr);
|
||||
}
|
||||
|
||||
if (mPrompter) {
|
||||
mPrompter->Alert(error.GetUnicode());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3272,9 +3301,9 @@ nsWebShell::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|||
*Fire the OnStartDocumentLoad of the webshell observer
|
||||
*/
|
||||
if ((nsnull != mContainer) && (nsnull != dlObserver))
|
||||
{
|
||||
{
|
||||
dlObserver->OnStartDocumentLoad(mDocLoader, aURL, aCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsresult Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream = nsnull);
|
||||
nsresult Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream = nsnull, const PRUnichar* aReferrer=nsnull);
|
||||
|
||||
nsresult Bind(nsIStreamListener *aListener);
|
||||
|
||||
|
@ -223,7 +223,8 @@ public:
|
|||
nsISupports* aExtraInfo = nsnull,
|
||||
nsIStreamObserver* anObserver = nsnull,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP = 0);
|
||||
const PRUint32 aLocalIP = 0,
|
||||
const PRUnichar* aReferrer = nsnull);
|
||||
|
||||
NS_IMETHOD LoadSubDocument(nsIURI * aUri,
|
||||
nsISupports* aExtraInfo = nsnull,
|
||||
|
@ -409,12 +410,14 @@ nsDocLoaderImpl::~nsDocLoaderImpl()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of ISupports methods...
|
||||
*/
|
||||
NS_IMPL_ADDREF(nsDocLoaderImpl);
|
||||
NS_IMPL_RELEASE(nsDocLoaderImpl);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -546,7 +549,8 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
|
|||
nsISupports* aExtraInfo,
|
||||
nsIStreamObserver* anObserver,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP)
|
||||
const PRUint32 aLocalIP,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsDocumentBindInfo* loader = nsnull;
|
||||
|
@ -588,7 +592,7 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
|
|||
|
||||
mStreamObserver = dont_QueryInterface(anObserver);
|
||||
|
||||
rv = loader->Bind(aUri, nsnull, aPostDataStream);
|
||||
rv = loader->Bind(aUri, nsnull, aPostDataStream, aReferrer);
|
||||
|
||||
done:
|
||||
NS_RELEASE(loader);
|
||||
|
@ -630,7 +634,7 @@ nsDocLoaderImpl::LoadSubDocument(nsIURI *aUri,
|
|||
mStreamObserver); // Observer
|
||||
|
||||
|
||||
rv = loader->Bind(aUri, nsnull, nsnull);
|
||||
rv = loader->Bind(aUri, nsnull, nsnull, nsnull);
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
@ -779,6 +783,16 @@ NS_IMETHODIMP
|
|||
nsDocLoaderImpl::Destroy()
|
||||
{
|
||||
Stop();
|
||||
#if 0
|
||||
if (nsnull != mParent) {
|
||||
#ifdef NECKO
|
||||
mParent->RemoveChildGroup(GetLoadGroup());
|
||||
#else
|
||||
mParent->RemoveChildGroup(this);
|
||||
#endif
|
||||
NS_RELEASE(mParent);
|
||||
}
|
||||
#endif
|
||||
NS_IF_RELEASE(mDocumentChannel);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1576,7 +1590,7 @@ private:
|
|||
// XXXbe second arg is unnecessary given first; hidden static IID in macro... scc help!
|
||||
NS_IMPL_ISUPPORTS(nsWebShellEventSinkGetter, nsCOMTypeInfo<nsIEventSinkGetter>::GetIID())
|
||||
|
||||
nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream)
|
||||
nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream, const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -1603,13 +1617,21 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener, ns
|
|||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, loadGroup, eventSinkGetter);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (postDataStream)
|
||||
if (postDataStream || aReferrer)
|
||||
{
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel)
|
||||
{
|
||||
httpChannel->SetRequestMethod(HM_POST);
|
||||
httpChannel->SetPostDataStream(postDataStream);
|
||||
if (postDataStream) {
|
||||
httpChannel->SetRequestMethod(HM_POST);
|
||||
httpChannel->SetPostDataStream(postDataStream);
|
||||
}
|
||||
if (aReferrer) {
|
||||
// Referer - misspelled, but per the HTTP spec
|
||||
nsCAutoString str = aReferrer;
|
||||
nsCOMPtr<nsIAtom> key = NS_NewAtom("referer");
|
||||
httpChannel->SetRequestHeader(key, str.GetBuffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
m_DocLoader->SetDocumentChannel(channel);
|
||||
|
|
|
@ -109,7 +109,8 @@ public:
|
|||
nsISupports* aExtraInfo = nsnull,
|
||||
nsIStreamObserver* anObserver = nsnull,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP = 0) = 0;
|
||||
const PRUint32 aLocalIP = 0,
|
||||
const PRUnichar* aReferrer = nsnull) = 0;
|
||||
|
||||
NS_IMETHOD LoadSubDocument(nsIURI * aUri,
|
||||
nsISupports* aExtraInfo = nsnull,
|
||||
|
|
|
@ -349,7 +349,8 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP=0,
|
||||
nsISupports * aHistoryState=nsnull) = 0;
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Load the document associated with the specified URL into the WebShell.
|
||||
|
@ -360,7 +361,8 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP=0,
|
||||
nsISupports * aHistoryState=nsnull) = 0;
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull) = 0;
|
||||
|
||||
/**
|
||||
* Load the document with the specified URI into the WebShell. Assuming you have
|
||||
|
@ -372,7 +374,8 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP=0,
|
||||
nsISupports * aHistoryState=nsnull) = 0;
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull) = 0;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -159,7 +159,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsresult Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream = nsnull);
|
||||
nsresult Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream = nsnull, const PRUnichar* aReferrer=nsnull);
|
||||
|
||||
nsresult Bind(nsIStreamListener *aListener);
|
||||
|
||||
|
@ -223,7 +223,8 @@ public:
|
|||
nsISupports* aExtraInfo = nsnull,
|
||||
nsIStreamObserver* anObserver = nsnull,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP = 0);
|
||||
const PRUint32 aLocalIP = 0,
|
||||
const PRUnichar* aReferrer = nsnull);
|
||||
|
||||
NS_IMETHOD LoadSubDocument(nsIURI * aUri,
|
||||
nsISupports* aExtraInfo = nsnull,
|
||||
|
@ -409,12 +410,14 @@ nsDocLoaderImpl::~nsDocLoaderImpl()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of ISupports methods...
|
||||
*/
|
||||
NS_IMPL_ADDREF(nsDocLoaderImpl);
|
||||
NS_IMPL_RELEASE(nsDocLoaderImpl);
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
|
@ -546,7 +549,8 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
|
|||
nsISupports* aExtraInfo,
|
||||
nsIStreamObserver* anObserver,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP)
|
||||
const PRUint32 aLocalIP,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsDocumentBindInfo* loader = nsnull;
|
||||
|
@ -588,7 +592,7 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri,
|
|||
|
||||
mStreamObserver = dont_QueryInterface(anObserver);
|
||||
|
||||
rv = loader->Bind(aUri, nsnull, aPostDataStream);
|
||||
rv = loader->Bind(aUri, nsnull, aPostDataStream, aReferrer);
|
||||
|
||||
done:
|
||||
NS_RELEASE(loader);
|
||||
|
@ -630,7 +634,7 @@ nsDocLoaderImpl::LoadSubDocument(nsIURI *aUri,
|
|||
mStreamObserver); // Observer
|
||||
|
||||
|
||||
rv = loader->Bind(aUri, nsnull, nsnull);
|
||||
rv = loader->Bind(aUri, nsnull, nsnull, nsnull);
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
@ -779,6 +783,16 @@ NS_IMETHODIMP
|
|||
nsDocLoaderImpl::Destroy()
|
||||
{
|
||||
Stop();
|
||||
#if 0
|
||||
if (nsnull != mParent) {
|
||||
#ifdef NECKO
|
||||
mParent->RemoveChildGroup(GetLoadGroup());
|
||||
#else
|
||||
mParent->RemoveChildGroup(this);
|
||||
#endif
|
||||
NS_RELEASE(mParent);
|
||||
}
|
||||
#endif
|
||||
NS_IF_RELEASE(mDocumentChannel);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1576,7 +1590,7 @@ private:
|
|||
// XXXbe second arg is unnecessary given first; hidden static IID in macro... scc help!
|
||||
NS_IMPL_ISUPPORTS(nsWebShellEventSinkGetter, nsCOMTypeInfo<nsIEventSinkGetter>::GetIID())
|
||||
|
||||
nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream)
|
||||
nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener, nsIInputStream *postDataStream, const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -1603,13 +1617,21 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener, ns
|
|||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, loadGroup, eventSinkGetter);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (postDataStream)
|
||||
if (postDataStream || aReferrer)
|
||||
{
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel)
|
||||
{
|
||||
httpChannel->SetRequestMethod(HM_POST);
|
||||
httpChannel->SetPostDataStream(postDataStream);
|
||||
if (postDataStream) {
|
||||
httpChannel->SetRequestMethod(HM_POST);
|
||||
httpChannel->SetPostDataStream(postDataStream);
|
||||
}
|
||||
if (aReferrer) {
|
||||
// Referer - misspelled, but per the HTTP spec
|
||||
nsCAutoString str = aReferrer;
|
||||
nsCOMPtr<nsIAtom> key = NS_NewAtom("referer");
|
||||
httpChannel->SetRequestHeader(key, str.GetBuffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
m_DocLoader->SetDocumentChannel(channel);
|
||||
|
|
|
@ -223,14 +223,16 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 localIP = 0,
|
||||
nsISupports * aHistoryState = nsnull);
|
||||
nsISupports * aHistoryState = nsnull,
|
||||
const PRUnichar* aReferrer=nsnull);
|
||||
NS_IMETHOD LoadURL(const PRUnichar *aURLSpec,
|
||||
const char* aCommand,
|
||||
nsIInputStream* aPostDataStream=nsnull,
|
||||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 localIP = 0,
|
||||
nsISupports * aHistoryState=nsnull);
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull);
|
||||
|
||||
NS_IMETHOD LoadURI(nsIURI * aUri,
|
||||
const char * aCommand,
|
||||
|
@ -238,7 +240,8 @@ public:
|
|||
PRBool aModifyHistory=PR_TRUE,
|
||||
nsLoadFlags aType = nsIChannel::LOAD_NORMAL,
|
||||
const PRUint32 aLocalIP=0,
|
||||
nsISupports * aHistoryState=nsnull);
|
||||
nsISupports * aHistoryState=nsnull,
|
||||
const PRUnichar* aReferrer=nsnull);
|
||||
|
||||
NS_IMETHOD Stop(void);
|
||||
|
||||
|
@ -392,7 +395,6 @@ public:
|
|||
NS_IMETHOD SetUrlDispatcher(nsIUrlDispatcher * anObserver);
|
||||
NS_IMETHOD GetUrlDispatcher(nsIUrlDispatcher *& aResult);
|
||||
|
||||
|
||||
protected:
|
||||
void InitFrameData(PRBool aCompleteInitScrolling);
|
||||
nsresult CheckForTrailingSlash(nsIURI* aURL);
|
||||
|
@ -429,6 +431,7 @@ protected:
|
|||
|
||||
nsString mTitle;
|
||||
nsString mURL;
|
||||
nsString mReferrer;
|
||||
|
||||
nsString mOverURL;
|
||||
nsString mOverTarget;
|
||||
|
@ -454,7 +457,8 @@ protected:
|
|||
const char* aCommand,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP);
|
||||
const PRUint32 aLocalIP,
|
||||
const PRUnichar* aReferrer);
|
||||
|
||||
float mZoom;
|
||||
|
||||
|
@ -1644,6 +1648,8 @@ nsWebShell::ChildAt(PRInt32 aIndex, nsIWebShell*& aResult)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::GetName(const PRUnichar** aName)
|
||||
{
|
||||
// XXX This is wrong unless the parameter is marked "shared".
|
||||
// It should otherwise be copied and freed by the caller.
|
||||
*aName = mName.GetUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1658,6 +1664,8 @@ nsWebShell::SetName(const PRUnichar* aName)
|
|||
NS_IMETHODIMP
|
||||
nsWebShell::GetURL(const PRUnichar** aURL)
|
||||
{
|
||||
// XXX This is wrong unless the parameter is marked "shared".
|
||||
// It should otherwise be copied and freed by the caller.
|
||||
*aURL = mURL.GetUnicode();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1910,15 +1918,18 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
PRBool aModifyHistory,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP,
|
||||
nsISupports * aHistoryState)
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
// Initialize margnwidth, marginheight. Put scrolling back the way it was
|
||||
// before the last document was loaded.
|
||||
InitFrameData(PR_FALSE);
|
||||
|
||||
const char *cmd = mViewSource ? "view-source" : "view" ;
|
||||
mViewSource = PR_FALSE; // reset it
|
||||
return LoadURL(aURLSpec, cmd , aPostDataStream,
|
||||
aModifyHistory,aType, aLocalIP, aHistoryState);
|
||||
return LoadURL(aURLSpec, "view", aPostDataStream,
|
||||
aModifyHistory,aType, aLocalIP, aHistoryState,
|
||||
aReferrer);
|
||||
}
|
||||
|
||||
// Nisheeth: returns true if the host and the file parts of
|
||||
|
@ -1968,8 +1979,8 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
const char* aCommand,
|
||||
nsIInputStream* aPostDataStream,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP)
|
||||
|
||||
const PRUint32 aLocalIP,
|
||||
const PRUnichar* aReferrer)
|
||||
|
||||
{
|
||||
if (!aUri)
|
||||
|
@ -2094,7 +2105,8 @@ nsWebShell::DoLoadURL(nsIURI * aUri,
|
|||
nsnull, // Extra Info...
|
||||
mObserver, // Observer
|
||||
aType, // reload type
|
||||
aLocalIP); // load attributes.
|
||||
aLocalIP, // load attributes.
|
||||
aReferrer); // referrer
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2104,12 +2116,15 @@ nsWebShell::LoadURI(nsIURI * aUri,
|
|||
PRBool aModifyHistory,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP,
|
||||
nsISupports * aHistoryState)
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv;
|
||||
CancelRefreshURITimers();
|
||||
nsXPIDLCString scheme, CUriSpec;
|
||||
|
||||
mReferrer = aReferrer;
|
||||
|
||||
rv = aUri->GetScheme(getter_Copies(scheme));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aUri->GetSpec(getter_Copies(CUriSpec));
|
||||
|
@ -2207,7 +2222,7 @@ nsWebShell::LoadURI(nsIURI * aUri,
|
|||
}
|
||||
|
||||
|
||||
return DoLoadURL(aUri, aCommand, aPostDataStream, aType, aLocalIP);
|
||||
return DoLoadURL(aUri, aCommand, aPostDataStream, aType, aLocalIP, aReferrer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -2217,7 +2232,8 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
PRBool aModifyHistory,
|
||||
nsLoadFlags aType,
|
||||
const PRUint32 aLocalIP,
|
||||
nsISupports * aHistoryState)
|
||||
nsISupports * aHistoryState,
|
||||
const PRUnichar* aReferrer)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -2304,7 +2320,7 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
|||
|
||||
|
||||
// now that we have a uri, call the REAL LoadURI method which requires a nsIURI.
|
||||
return LoadURI(uri, aCommand, aPostDataStream, aModifyHistory, aType, aLocalIP, aHistoryState);
|
||||
return LoadURI(uri, aCommand, aPostDataStream, aModifyHistory, aType, aLocalIP, aHistoryState, aReferrer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2486,7 +2502,8 @@ nsWebShell::GoTo(PRInt32 aHistoryIndex)
|
|||
"view", // Command
|
||||
nsnull, // Post Data
|
||||
nsIChannel::LOAD_NORMAL, // the reload type
|
||||
0); // load attributes
|
||||
0, // load attributes
|
||||
nsnull); // referrer
|
||||
}
|
||||
return rv;
|
||||
#else
|
||||
|
@ -3001,7 +3018,9 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent,
|
|||
{
|
||||
nsIWebShell* shell = GetTarget(target.GetUnicode());
|
||||
if (nsnull != shell) {
|
||||
(void)shell->LoadURL(aURLSpec, aPostDataStream);
|
||||
(void)shell->LoadURL(aURLSpec, aPostDataStream,
|
||||
PR_TRUE, nsIChannel::LOAD_NORMAL,
|
||||
0, nsnull, mURL.GetUnicode());
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
|
@ -3198,8 +3217,9 @@ nsWebShell::ReportScriptError(const char* aErrorString,
|
|||
// XXX To be implemented by scc. The following implementation
|
||||
// is temporary.
|
||||
|
||||
nsCAutoString error;
|
||||
error.SetString(aErrorString);
|
||||
nsAutoString error;
|
||||
error.SetString("JavaScript Error: ");
|
||||
error.Append(aErrorString);
|
||||
error += "\n";
|
||||
|
||||
if (aFileName) {
|
||||
|
@ -3220,7 +3240,16 @@ nsWebShell::ReportScriptError(const char* aErrorString,
|
|||
error += "'\n";
|
||||
}
|
||||
|
||||
printf("JavaScript Error: %s\n", error.GetBuffer());
|
||||
// XXX Ughhh...allocation
|
||||
char* errorStr = error.ToNewCString();
|
||||
if (errorStr) {
|
||||
printf("%s\n", errorStr);
|
||||
Recycle(errorStr);
|
||||
}
|
||||
|
||||
if (mPrompter) {
|
||||
mPrompter->Alert(error.GetUnicode());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3272,9 +3301,9 @@ nsWebShell::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
|||
*Fire the OnStartDocumentLoad of the webshell observer
|
||||
*/
|
||||
if ((nsnull != mContainer) && (nsnull != dlObserver))
|
||||
{
|
||||
{
|
||||
dlObserver->OnStartDocumentLoad(mDocLoader, aURL, aCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
Загрузка…
Ссылка в новой задаче