[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser/tor-browser-24.1.1esr-1] fixup! Add mozIThirdPartyUtil.getFirstPartyURI API



commit 2df3a6e502c52c4a8e3bc34921aad0eda80af340
Author: Kathy Brade <brade@xxxxxxxxxxxxxxxxx>
Date:   Fri Dec 6 10:54:24 2013 -0500

    fixup! Add mozIThirdPartyUtil.getFirstPartyURI API
    
    Add mozIThirdPartyUtil.getFirstPartyURIFromChannel() API.
    
    Marked getFirstPartyURI() as [noscript] since it cannot be
    called from JS due to its use of an nsIDocument parameter.
    See Tor bug # 8167.
---
 content/base/src/ThirdPartyUtil.cpp        |   20 +++++++++++++++++++-
 content/base/src/ThirdPartyUtil.h          |    2 ++
 netwerk/base/public/mozIThirdPartyUtil.idl |   24 ++++++++++++++++++++++--
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/content/base/src/ThirdPartyUtil.cpp b/content/base/src/ThirdPartyUtil.cpp
index 6c17974..55eb316 100644
--- a/content/base/src/ThirdPartyUtil.cpp
+++ b/content/base/src/ThirdPartyUtil.cpp
@@ -411,11 +411,21 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
   return NS_OK;
 }
 
+// Not scriptable due to the use of an nsIDocument parameter.
 NS_IMETHODIMP
 ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
                                  nsIDocument *aDoc,
                                  nsIURI **aOutput)
 {
+  return GetFirstPartyURIInternal(aChannel, aDoc, true, aOutput);
+}
+
+nsresult
+ThirdPartyUtil::GetFirstPartyURIInternal(nsIChannel *aChannel,
+                                         nsIDocument *aDoc,
+                                         bool aLogErrors,
+                                         nsIURI **aOutput)
+{
   nsresult rv = NS_ERROR_NULL_POINTER;
 
   if (!aOutput)
@@ -490,7 +500,7 @@ ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
   }
 
   // Log failure to error console.
-  if (NS_FAILED(rv)) {
+  if (aLogErrors && NS_FAILED(rv)) {
     nsCOMPtr<nsIConsoleService> console
                               (do_GetService(NS_CONSOLESERVICE_CONTRACTID));
     if (console) {
@@ -525,6 +535,14 @@ ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
 }
 
 NS_IMETHODIMP
+ThirdPartyUtil::GetFirstPartyURIFromChannel(nsIChannel *aChannel,
+                                            bool aLogErrors,
+                                            nsIURI **aOutput)
+{
+  return GetFirstPartyURIInternal(aChannel, nullptr, aLogErrors, aOutput);
+}
+
+NS_IMETHODIMP
 ThirdPartyUtil::GetFirstPartyHostForIsolation(nsIURI *aFirstPartyURI,
                                               nsACString& aHost)
 {
diff --git a/content/base/src/ThirdPartyUtil.h b/content/base/src/ThirdPartyUtil.h
index 93d3e1f..8777f44 100644
--- a/content/base/src/ThirdPartyUtil.h
+++ b/content/base/src/ThirdPartyUtil.h
@@ -30,6 +30,8 @@ private:
   bool SchemeIsWhiteListed(nsIURI *aURI);
   static already_AddRefed<nsIURI> GetURIFromWindow(nsIDOMWindow* aWin);
   static nsresult GetOriginatingURI(nsIChannel  *aChannel, nsIURI **aURI);
+  nsresult GetFirstPartyURIInternal(nsIChannel *aChannel, nsIDocument *aDoc,
+                                    bool aLogErrors, nsIURI **aOutput);
 
   nsCOMPtr<nsIEffectiveTLDService> mTLDService;
   nsCOMPtr<nsICookiePermission> mCookiePermissions;
diff --git a/netwerk/base/public/mozIThirdPartyUtil.idl b/netwerk/base/public/mozIThirdPartyUtil.idl
index b602ac3..6137274 100644
--- a/netwerk/base/public/mozIThirdPartyUtil.idl
+++ b/netwerk/base/public/mozIThirdPartyUtil.idl
@@ -161,8 +161,28 @@ interface mozIThirdPartyUtil : nsISupports
    * @throws if the URI cannot be obtained or the URI lacks a hostname and the
    *         URI's scheme is not white listed.
    */
-  nsIURI getFirstPartyURI(in nsIChannel aChannel,
-                          in nsIDocument aDoc);
+  [noscript] nsIURI getFirstPartyURI(in nsIChannel aChannel,
+                                     in nsIDocument aDoc);
+
+  /**
+   * getFirstPartyURIFromChannel
+   *
+   * Obtain the top-level url bar URI for a channel.
+   *
+   * @param aChannel
+   *        An arbitrary channel for some content element of a first party
+   *        load.
+   *
+   * @param aLogErrors
+   *        If true, log errors to the Error Console.
+   *
+   * @return the first party url bar URI for the load.
+   *
+   * @throws if the URI cannot be obtained or the URI lacks a hostname and the
+   *         URI's scheme is not white listed.
+   */
+  nsIURI getFirstPartyURIFromChannel(in nsIChannel aChannel,
+                                     in bool aLogErrors);
 
   /**
    * getFirstPartyHostForIsolation

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits