diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 18e462d9f30..6308aced31b 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -82,6 +82,7 @@ #include "nsILocaleService.h" static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); +static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); #ifdef XP_PC #include @@ -1789,7 +1790,7 @@ nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandl } NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType, - const char * aCommand, + nsURILoadCommand aCommand, const char * aWindowTarget, char ** aDesiredContentType, PRBool * aCanHandleContent) @@ -1814,11 +1815,11 @@ NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType, NS_IMETHODIMP nsWebShell::DoContent(const char * aContentType, - const char * aCommand, - const char * aWindowTarget, - nsIChannel * aOpenedChannel, - nsIStreamListener ** aContentHandler, - PRBool * aAbortProcess) + nsURILoadCommand aCommand, + const char * aWindowTarget, + nsIChannel * aOpenedChannel, + nsIStreamListener ** aContentHandler, + PRBool * aAbortProcess) { if (aAbortProcess) *aAbortProcess = PR_FALSE; @@ -1827,16 +1828,16 @@ nsWebShell::DoContent(const char * aContentType, // had we gone through OpenURI nsCOMPtr aUri; aOpenedChannel->GetURI(getter_AddRefs(aUri)); - PrepareToLoadURI(aUri, aCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); + PrepareToLoadURI(aUri, "view", nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); // mscott: when I called DoLoadURL I found that we ran into problems because // we currently don't have channel retargeting yet. Basically, what happens is that // DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group // however since we can't retarget yet, we were basically canceling our very // own load group!!! So the request would get canceled out from under us... // after retargeting we may be able to safely call DoLoadURL. - DoLoadURL(aUri, aCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); + DoLoadURL(aUri, "view", nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); return mDocLoader->LoadOpenedDocument(aOpenedChannel, - aCommand, + "view", this, nsnull, nsnull, @@ -2754,9 +2755,27 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, if (nsnull != shell) { // Allocate since mURL may change beneath us PRUnichar* str = mURL.ToNewUnicode(); - (void)shell->LoadURL(aURLSpec, aPostDataStream, - PR_TRUE, nsIChannel::LOAD_NORMAL, - 0, nsnull, str); + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); + PRBool useURILoader = PR_FALSE; + if (NS_SUCCEEDED(rv)) + prefs->GetBoolPref("browser.uriloader", &useURILoader); + if (useURILoader) + { + // for now, just hack the verb to be view-link-clicked + // and down in the load document code we'll detect this and + // set the correct uri loader command + (void)shell->LoadURL(aURLSpec, "view-link-click", aPostDataStream, + PR_TRUE, nsIChannel::LOAD_NORMAL, + 0, nsnull, str); + } + else + { + (void)shell->LoadURL(aURLSpec, aPostDataStream, + PR_TRUE, nsIChannel::LOAD_NORMAL, + 0, nsnull, str); + } Recycle(str); NS_RELEASE(shell); } diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp index 7db4da0cbef..e97eaafa56b 100644 --- a/mozilla/uriloader/base/nsDocLoader.cpp +++ b/mozilla/uriloader/base/nsDocLoader.cpp @@ -560,16 +560,7 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, // dispatching code for those schemes which work with uri dispatching... if (useURILoader && aUri) { - if (nsCRT::strcasecmp(aUrlScheme, "imap") == 0 - || nsCRT::strcasecmp(aUrlScheme, "news") == 0 - || nsCRT::strcasecmp(aUrlScheme, "mailbox") == 0 - || nsCRT::strcasecmp(aUrlScheme, "mailboxMessage") ==0 - || nsCRT::strcasecmp(aUrlScheme, "mailto") == 0 - || nsCRT::strcasecmp(aUrlScheme, "http") == 0 - || nsCRT::strcasecmp(aUrlScheme, "chrome") == 0 - || nsCRT::strcasecmp(aUrlScheme, "res") == 0) - { - nsCOMPtr aOpenContext = do_QueryInterface(mLoadGroup); + nsCOMPtr aOpenContext = do_QueryInterface(mLoadGroup); // let's try uri dispatching... NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv); @@ -583,6 +574,10 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, */ mIsLoadingDocument = PR_TRUE; + nsURILoadCommand loadCmd = nsIURILoader::viewNormal; + if (nsCRT::strcasecmp(aCommand, "view-link-click") == 0) + loadCmd = nsIURILoader::viewUserClick; + // temporary hack for post data...eventually this snippet of code // should be moved into the layout call when callers go through the // uri loader directly! @@ -592,16 +587,18 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, // query for private post data stream interface nsCOMPtr postLoader = do_QueryInterface(pURILoader, &rv); if (NS_SUCCEEDED(rv)) - rv = postLoader->OpenURIWithPostData(aUri, nsnull /* window target */, - aContainer, - nsnull /* referring uri */, - aPostDataStream, - mLoadGroup, - getter_AddRefs(aOpenContext)); + rv = postLoader->OpenURIWithPostData(aUri, + loadCmd, + nsnull /* window target */, + aContainer, + nsnull /* referring uri */, + aPostDataStream, + mLoadGroup, + getter_AddRefs(aOpenContext)); } else - rv = pURILoader->OpenURI(aUri, nsnull /* window target */, + rv = pURILoader->OpenURI(aUri, loadCmd, nsnull /* window target */, aContainer, nsnull /* refferring URI */, mLoadGroup, @@ -611,7 +608,6 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, } return rv; - } } // end try uri loader code nsDocumentBindInfo* loader = nsnull; diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp index 7db4da0cbef..e97eaafa56b 100644 --- a/mozilla/webshell/src/nsDocLoader.cpp +++ b/mozilla/webshell/src/nsDocLoader.cpp @@ -560,16 +560,7 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, // dispatching code for those schemes which work with uri dispatching... if (useURILoader && aUri) { - if (nsCRT::strcasecmp(aUrlScheme, "imap") == 0 - || nsCRT::strcasecmp(aUrlScheme, "news") == 0 - || nsCRT::strcasecmp(aUrlScheme, "mailbox") == 0 - || nsCRT::strcasecmp(aUrlScheme, "mailboxMessage") ==0 - || nsCRT::strcasecmp(aUrlScheme, "mailto") == 0 - || nsCRT::strcasecmp(aUrlScheme, "http") == 0 - || nsCRT::strcasecmp(aUrlScheme, "chrome") == 0 - || nsCRT::strcasecmp(aUrlScheme, "res") == 0) - { - nsCOMPtr aOpenContext = do_QueryInterface(mLoadGroup); + nsCOMPtr aOpenContext = do_QueryInterface(mLoadGroup); // let's try uri dispatching... NS_WITH_SERVICE(nsIURILoader, pURILoader, kURILoaderCID, &rv); @@ -583,6 +574,10 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, */ mIsLoadingDocument = PR_TRUE; + nsURILoadCommand loadCmd = nsIURILoader::viewNormal; + if (nsCRT::strcasecmp(aCommand, "view-link-click") == 0) + loadCmd = nsIURILoader::viewUserClick; + // temporary hack for post data...eventually this snippet of code // should be moved into the layout call when callers go through the // uri loader directly! @@ -592,16 +587,18 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, // query for private post data stream interface nsCOMPtr postLoader = do_QueryInterface(pURILoader, &rv); if (NS_SUCCEEDED(rv)) - rv = postLoader->OpenURIWithPostData(aUri, nsnull /* window target */, - aContainer, - nsnull /* referring uri */, - aPostDataStream, - mLoadGroup, - getter_AddRefs(aOpenContext)); + rv = postLoader->OpenURIWithPostData(aUri, + loadCmd, + nsnull /* window target */, + aContainer, + nsnull /* referring uri */, + aPostDataStream, + mLoadGroup, + getter_AddRefs(aOpenContext)); } else - rv = pURILoader->OpenURI(aUri, nsnull /* window target */, + rv = pURILoader->OpenURI(aUri, loadCmd, nsnull /* window target */, aContainer, nsnull /* refferring URI */, mLoadGroup, @@ -611,7 +608,6 @@ nsDocLoaderImpl::LoadDocument(nsIURI * aUri, } return rv; - } } // end try uri loader code nsDocumentBindInfo* loader = nsnull; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 18e462d9f30..6308aced31b 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -82,6 +82,7 @@ #include "nsILocaleService.h" static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); +static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); #ifdef XP_PC #include @@ -1789,7 +1790,7 @@ nsWebShell::GetProtocolHandler(nsIURI *aURI, nsIProtocolHandler **aProtocolHandl } NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType, - const char * aCommand, + nsURILoadCommand aCommand, const char * aWindowTarget, char ** aDesiredContentType, PRBool * aCanHandleContent) @@ -1814,11 +1815,11 @@ NS_IMETHODIMP nsWebShell::CanHandleContent(const char * aContentType, NS_IMETHODIMP nsWebShell::DoContent(const char * aContentType, - const char * aCommand, - const char * aWindowTarget, - nsIChannel * aOpenedChannel, - nsIStreamListener ** aContentHandler, - PRBool * aAbortProcess) + nsURILoadCommand aCommand, + const char * aWindowTarget, + nsIChannel * aOpenedChannel, + nsIStreamListener ** aContentHandler, + PRBool * aAbortProcess) { if (aAbortProcess) *aAbortProcess = PR_FALSE; @@ -1827,16 +1828,16 @@ nsWebShell::DoContent(const char * aContentType, // had we gone through OpenURI nsCOMPtr aUri; aOpenedChannel->GetURI(getter_AddRefs(aUri)); - PrepareToLoadURI(aUri, aCommand, nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); + PrepareToLoadURI(aUri, "view", nsnull, PR_TRUE, nsIChannel::LOAD_NORMAL, 0, nsnull, nsnull); // mscott: when I called DoLoadURL I found that we ran into problems because // we currently don't have channel retargeting yet. Basically, what happens is that // DoLoadURL calls StopBeforeRequestingURL and this cancels the current load group // however since we can't retarget yet, we were basically canceling our very // own load group!!! So the request would get canceled out from under us... // after retargeting we may be able to safely call DoLoadURL. - DoLoadURL(aUri, aCommand, nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); + DoLoadURL(aUri, "view", nsnull, nsIChannel::LOAD_NORMAL, 0, nsnull, PR_FALSE); return mDocLoader->LoadOpenedDocument(aOpenedChannel, - aCommand, + "view", this, nsnull, nsnull, @@ -2754,9 +2755,27 @@ nsWebShell::HandleLinkClickEvent(nsIContent *aContent, if (nsnull != shell) { // Allocate since mURL may change beneath us PRUnichar* str = mURL.ToNewUnicode(); - (void)shell->LoadURL(aURLSpec, aPostDataStream, - PR_TRUE, nsIChannel::LOAD_NORMAL, - 0, nsnull, str); + nsresult rv = NS_OK; + + NS_WITH_SERVICE(nsIPref, prefs, kPrefServiceCID, &rv); + PRBool useURILoader = PR_FALSE; + if (NS_SUCCEEDED(rv)) + prefs->GetBoolPref("browser.uriloader", &useURILoader); + if (useURILoader) + { + // for now, just hack the verb to be view-link-clicked + // and down in the load document code we'll detect this and + // set the correct uri loader command + (void)shell->LoadURL(aURLSpec, "view-link-click", aPostDataStream, + PR_TRUE, nsIChannel::LOAD_NORMAL, + 0, nsnull, str); + } + else + { + (void)shell->LoadURL(aURLSpec, aPostDataStream, + PR_TRUE, nsIChannel::LOAD_NORMAL, + 0, nsnull, str); + } Recycle(str); NS_RELEASE(shell); }