[tbb-commits] [tor-browser/tor-browser-24.7.0esr-3.x-1] fixup! API allows you to get the url bar URI for a channel or nsIDocument.
mikeperry at torproject.org
mikeperry at torproject.org
Wed Aug 20 04:24:42 UTC 2014
commit 8751adf3f98016212a3aac2d5a12e59b2e425d5a
Author: Mike Perry <mikeperry-git at torproject.org>
Date: Sat Aug 16 19:25:57 2014 -0700
fixup! API allows you to get the url bar URI for a channel or nsIDocument.
Log the URI of the source doc/channel that failed.
---
content/base/src/ThirdPartyUtil.cpp | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/content/base/src/ThirdPartyUtil.cpp b/content/base/src/ThirdPartyUtil.cpp
index 55eb316..569201e 100644
--- a/content/base/src/ThirdPartyUtil.cpp
+++ b/content/base/src/ThirdPartyUtil.cpp
@@ -427,6 +427,7 @@ ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
nsIURI **aOutput)
{
nsresult rv = NS_ERROR_NULL_POINTER;
+ nsCOMPtr<nsIURI> srcURI;
if (!aOutput)
return rv;
@@ -441,6 +442,7 @@ ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
// for sure
if (aChannel) {
rv = GetOriginatingURI(aChannel, aOutput);
+ aChannel->GetURI(getter_AddRefs(srcURI));
if (NS_SUCCEEDED(rv) && *aOutput) {
// At this point, about: and chrome: URLs have been mapped to file: or
// jar: URLs. Try to recover the original URL.
@@ -467,6 +469,7 @@ ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
nsCOMPtr<nsIDOMWindow> top;
nsCOMPtr<nsIDOMDocument> topDDoc;
nsIURI *docURI = nullptr;
+ srcURI = aDoc->GetDocumentURI();
if (aDoc->GetWindow()) {
aDoc->GetWindow()->GetTop(getter_AddRefs(top));
@@ -505,14 +508,19 @@ ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
nsCString spec;
+ nsCString srcSpec("unknown");
+
+ if (srcURI)
+ srcURI->GetSpec(srcSpec);
+
if (*aOutput)
(*aOutput)->GetSpec(spec);
if (spec.Length() > 0) {
- nsPrintfCString msg("getFirstPartyURI: no host in first party URI %s",
- spec.get()); // TODO: L10N
+ nsPrintfCString msg("getFirstPartyURI failed for %s: no host in first party URI %s",
+ srcSpec.get(), spec.get()); // TODO: L10N
console->LogStringMessage(NS_ConvertUTF8toUTF16(msg).get());
} else {
- nsPrintfCString msg("getFirstPartyURI failed: 0x%x", rv);
+ nsPrintfCString msg("getFirstPartyURI failed for %s: 0x%x", srcSpec.get(), rv);
console->LogStringMessage(NS_ConvertUTF8toUTF16(msg).get());
}
}
More information about the tbb-commits
mailing list