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
This commit is contained in:
Valentin Gosu 2017-08-09 17:43:58 +02:00
parent d1bbd84d19
commit 7520c99a2c
8 changed files with 51 additions and 1 deletions

View File

@ -41,7 +41,7 @@ function onLoadPermission(uri, principal) {
gPermURI = uri;
gPermPrincipal = principal;
var hostText = document.getElementById("hostText");
hostText.value = gPermURI.prePath;
hostText.value = gPermURI.displayPrePath;
for (var i of gPermissions)
initRow(i);

View File

@ -367,6 +367,12 @@ NullPrincipalURI::GetDisplayHost(nsACString &aUnicodeHost)
return GetHost(aUnicodeHost);
}
NS_IMETHODIMP
NullPrincipalURI::GetDisplayPrePath(nsACString &aPrePath)
{
return GetPrePath(aPrePath);
}
////////////////////////////////////////////////////////////////////////////////
//// nsIIPCSerializableURI

View File

@ -135,6 +135,12 @@ nsMozIconURI::GetDisplayHost(nsACString& aUnicodeHost)
return GetHost(aUnicodeHost);
}
NS_IMETHODIMP
nsMozIconURI::GetDisplayPrePath(nsACString& aPrePath)
{
return GetPrePath(aPrePath);
}
NS_IMETHODIMP
nsMozIconURI::GetHasRef(bool* result)
{

View File

@ -240,6 +240,12 @@ nsJARURI::GetDisplayHostPort(nsACString &aUnicodeHostPort)
return GetHostPort(aUnicodeHostPort);
}
NS_IMETHODIMP
nsJARURI::GetDisplayPrePath(nsACString &aPrePath)
{
return GetPrePath(aPrePath);
}
NS_IMETHODIMP
nsJARURI::GetDisplayHost(nsACString &aUnicodeHost)
{

View File

@ -453,6 +453,12 @@ 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)
{

View File

@ -320,4 +320,11 @@ interface nsIURI : nsISupports
* 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;
};

View File

@ -273,6 +273,12 @@ nsSimpleURI::GetDisplayHost(nsACString &aUnicodeHost)
return GetHost(aUnicodeHost);
}
NS_IMETHODIMP
nsSimpleURI::GetDisplayPrePath(nsACString &aPrePath)
{
return GetPrePath(aPrePath);
}
NS_IMETHODIMP
nsSimpleURI::GetHasRef(bool *result)
{

View File

@ -1508,6 +1508,19 @@ nsStandardURL::GetPrePath(nsACString &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)