Bug 1380617 - Add nsIURI.displayPrePath r=mcmanus,Gijs
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 09 Aug 2017 17:43:58 +0200
changeset 373593 82c04a5c89b6bbe4a711a7e6531bc50ec5e48483
parent 373592 87bfb9b2974c83c7c7f71cb0587236292c12a47d
child 373594 19915252f2d4d7701bca41d10fb16dcf87334a7d
push id32305
push userryanvm@gmail.com
push dateWed, 09 Aug 2017 22:43:53 +0000
treeherdermozilla-central@411fe4772f31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, Gijs
bugs1380617
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1380617 - Add nsIURI.displayPrePath r=mcmanus,Gijs - Use displayPrePath in the pageInfo permissions that shows "Permissions for:" - The extra displayPrePath method is necessary because it's difficult to compute it manually, as opposed to not having a displaySpecWithoutRef - as it's easy to get that by truncating displaySpec at the first '#' symbol. MozReview-Commit-ID: 9RM5kQ2OqfC
browser/base/content/pageinfo/permissions.js
caps/NullPrincipalURI.cpp
image/decoders/icon/nsIconURI.cpp
modules/libjar/nsJARURI.cpp
netwerk/base/RustURL.cpp
netwerk/base/nsIURI.idl
netwerk/base/nsSimpleURI.cpp
netwerk/base/nsStandardURL.cpp
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -36,17 +36,17 @@ var permissionObserver = {
 };
 
 function onLoadPermission(uri, principal) {
   var permTab = document.getElementById("permTab");
   if (SitePermissions.isSupportedURI(uri)) {
     gPermURI = uri;
     gPermPrincipal = principal;
     var hostText = document.getElementById("hostText");
-    hostText.value = gPermURI.prePath;
+    hostText.value = gPermURI.displayPrePath;
 
     for (var i of gPermissions)
       initRow(i);
     var os = Components.classes["@mozilla.org/observer-service;1"]
                        .getService(Components.interfaces.nsIObserverService);
     os.addObserver(permissionObserver, "perm-changed");
     onUnloadRegistry.push(onUnloadPermission);
     permTab.hidden = false;
--- a/caps/NullPrincipalURI.cpp
+++ b/caps/NullPrincipalURI.cpp
@@ -362,16 +362,22 @@ NullPrincipalURI::GetDisplayHostPort(nsA
 }
 
 NS_IMETHODIMP
 NullPrincipalURI::GetDisplayHost(nsACString &aUnicodeHost)
 {
   return GetHost(aUnicodeHost);
 }
 
+NS_IMETHODIMP
+NullPrincipalURI::GetDisplayPrePath(nsACString &aPrePath)
+{
+    return GetPrePath(aPrePath);
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIIPCSerializableURI
 
 void
 NullPrincipalURI::Serialize(mozilla::ipc::URIParams& aParams)
 {
   aParams = mozilla::ipc::NullPrincipalURIParams();
 }
--- a/image/decoders/icon/nsIconURI.cpp
+++ b/image/decoders/icon/nsIconURI.cpp
@@ -131,16 +131,22 @@ nsMozIconURI::GetDisplayHostPort(nsACStr
 
 NS_IMETHODIMP
 nsMozIconURI::GetDisplayHost(nsACString& aUnicodeHost)
 {
   return GetHost(aUnicodeHost);
 }
 
 NS_IMETHODIMP
+nsMozIconURI::GetDisplayPrePath(nsACString& aPrePath)
+{
+  return GetPrePath(aPrePath);
+}
+
+NS_IMETHODIMP
 nsMozIconURI::GetHasRef(bool* result)
 {
   *result = false;
   return NS_OK;
 }
 
 // takes a string like ?size=32&contentType=text/html and returns a new string
 // containing just the attribute value. i.e you could pass in this string with
--- a/modules/libjar/nsJARURI.cpp
+++ b/modules/libjar/nsJARURI.cpp
@@ -236,16 +236,22 @@ nsJARURI::GetDisplaySpec(nsACString &aUn
 
 NS_IMETHODIMP
 nsJARURI::GetDisplayHostPort(nsACString &aUnicodeHostPort)
 {
     return GetHostPort(aUnicodeHostPort);
 }
 
 NS_IMETHODIMP
+nsJARURI::GetDisplayPrePath(nsACString &aPrePath)
+{
+    return GetPrePath(aPrePath);
+}
+
+NS_IMETHODIMP
 nsJARURI::GetDisplayHost(nsACString &aUnicodeHost)
 {
     return GetHost(aUnicodeHost);
 }
 
 NS_IMETHODIMP
 nsJARURI::GetHasRef(bool *result)
 {
--- a/netwerk/base/RustURL.cpp
+++ b/netwerk/base/RustURL.cpp
@@ -449,16 +449,22 @@ RustURL::GetDisplayHostPort(nsACString &
 
 NS_IMETHODIMP
 RustURL::GetDisplayHost(nsACString &aUnicodeHost)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
+RustURL::GetDisplayPrePath(nsACString & aPrePath)
+{
+  return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
 RustURL::GetHasRef(bool *aHasRef)
 {
   *aHasRef = false;
   return rusturl_has_fragment(mURL.get(), aHasRef);
 }
 
 /// nsIURL
 
--- a/netwerk/base/nsIURI.idl
+++ b/netwerk/base/nsIURI.idl
@@ -315,9 +315,16 @@ interface nsIURI : nsISupports
     readonly attribute AUTF8String displayHostPort;
 
     /**
      * Returns the same as calling .spec, only with a UTF8 encoded hostname
      * (if that hostname doesn't contain blacklisted characters, and
      * the network.IDN_show_punycode pref is false)
      */
     readonly attribute AUTF8String displaySpec;
+
+    /**
+     * Returns the same as calling .prePath, only with a UTF8 encoded hostname
+     * (if that hostname doesn't contain blacklisted characters, and
+     * the network.IDN_show_punycode pref is false)
+     */
+    readonly attribute AUTF8String displayPrePath;
 };
--- a/netwerk/base/nsSimpleURI.cpp
+++ b/netwerk/base/nsSimpleURI.cpp
@@ -269,16 +269,22 @@ nsSimpleURI::GetDisplayHostPort(nsACStri
 
 NS_IMETHODIMP
 nsSimpleURI::GetDisplayHost(nsACString &aUnicodeHost)
 {
     return GetHost(aUnicodeHost);
 }
 
 NS_IMETHODIMP
+nsSimpleURI::GetDisplayPrePath(nsACString &aPrePath)
+{
+    return GetPrePath(aPrePath);
+}
+
+NS_IMETHODIMP
 nsSimpleURI::GetHasRef(bool *result)
 {
     *result = mIsRefValid;
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSimpleURI::SetSpec(const nsACString &aSpec)
--- a/netwerk/base/nsStandardURL.cpp
+++ b/netwerk/base/nsStandardURL.cpp
@@ -1503,16 +1503,29 @@ nsStandardURL::GetPrePath(nsACString &re
     MOZ_ASSERT(mCheckedIfHostA);
     if (!gPunycodeHost && !mDisplayHost.IsEmpty()) {
         result.Replace(mHost.mPos, mHost.mLen, mDisplayHost);
     }
     CALL_RUST_GETTER_STR(result, GetPrePath, result);
     return NS_OK;
 }
 
+// result may contain unescaped UTF-8 characters
+NS_IMETHODIMP
+nsStandardURL::GetDisplayPrePath(nsACString &result)
+{
+    result = Prepath();
+    CheckIfHostIsAscii();
+    MOZ_ASSERT(mCheckedIfHostA);
+    if (!mDisplayHost.IsEmpty()) {
+        result.Replace(mHost.mPos, mHost.mLen, mDisplayHost);
+    }
+    return NS_OK;
+}
+
 // result is strictly US-ASCII
 NS_IMETHODIMP
 nsStandardURL::GetScheme(nsACString &result)
 {
     result = Scheme();
     CALL_RUST_GETTER_STR(result, GetScheme, result);
     return NS_OK;
 }