Commit 53b28046 authored by Mike Perry's avatar Mike Perry
Browse files

Damn, that nifty helper function wanted me to check its input for it.

Oh well, my fault for not reading the comment.
parent be7d6bc2
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
From eb5083671adc896d465caa40e188c3e16ddfeb6b Mon Sep 17 00:00:00 2001
From 81c1a8a664d433686367e44ebd49320be337a2f3 Mon Sep 17 00:00:00 2001
From: Mike Perry <mikeperry-git@torproject.org>
Date: Wed, 28 Nov 2012 17:08:29 -0500
Subject: [PATCH 19/26] Add mozIThirdPartyUtil.getFirstPartyURI API

API allows you to get the url bar URI for a channel or nsIDocument.
---
 content/base/src/ThirdPartyUtil.cpp        |   61 ++++++++++++++++++++++++++++
 content/base/src/ThirdPartyUtil.cpp        |   68 ++++++++++++++++++++++++++++
 content/base/src/ThirdPartyUtil.h          |    2 +
 netwerk/base/public/mozIThirdPartyUtil.idl |   21 ++++++++++
 3 files changed, 84 insertions(+), 0 deletions(-)
 netwerk/base/public/mozIThirdPartyUtil.idl |   21 +++++++++
 3 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/content/base/src/ThirdPartyUtil.cpp b/content/base/src/ThirdPartyUtil.cpp
index 97a000e..61e9eae 100644
index 97a000e..ad1b0fa 100644
--- a/content/base/src/ThirdPartyUtil.cpp
+++ b/content/base/src/ThirdPartyUtil.cpp
@@ -7,6 +7,9 @@
@@ -32,7 +32,7 @@ index 97a000e..61e9eae 100644
   return rv;
 }
 
@@ -282,3 +286,60 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
@@ -282,3 +286,67 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
 
   return NS_OK;
 }
@@ -44,6 +44,11 @@ index 97a000e..61e9eae 100644
+{
+  nsresult rv = NS_ERROR_NULL_POINTER;
+
+  if (!aOutput)
+    return rv;
+
+  *aOutput = nullptr;
+
+  if (!aChannel && aDoc) {
+    aChannel = aDoc->GetChannel();
+  }
@@ -70,8 +75,10 @@ index 97a000e..61e9eae 100644
+
+      nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
+      docURI = topDoc->GetOriginalURI();
+      if (docURI) {
+        // Give us a mutable URI and also addref
+        rv = NS_EnsureSafeToReturn(docURI, aOutput);
+      }
+    } else {
+      // XXX: Chrome callers (such as NoScript) can end up here
+      // through getImageData/canvas usage with no document state