Bug 1558923 - Remove nsContentUtils::GetThreadSafe{ASCII,UTF8}Origin, r=valentin

Differential Revision: https://phabricator.services.mozilla.com/D34767

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrea Marchesini 2019-06-13 16:42:53 +00:00
parent ac563a2551
commit 0d82acdb60
3 changed files with 1 additions and 86 deletions

View File

@ -5745,7 +5745,6 @@ nsresult nsContentUtils::GetASCIIOrigin(nsIPrincipal* aPrincipal,
/* static */
nsresult nsContentUtils::GetASCIIOrigin(nsIURI* aURI, nsACString& aOrigin) {
MOZ_ASSERT(aURI, "missing uri");
MOZ_ASSERT(NS_IsMainThread());
bool isBlobURL = false;
nsresult rv = aURI->SchemeIs(BLOBURI_SCHEME, &isBlobURL);
@ -5796,69 +5795,6 @@ nsresult nsContentUtils::GetASCIIOrigin(nsIURI* aURI, nsACString& aOrigin) {
return NS_OK;
}
/* static */
nsresult nsContentUtils::GetThreadSafeASCIIOrigin(nsIURI* aURI,
nsACString& aOrigin) {
MOZ_ASSERT(aURI, "missing uri");
bool isBlobURL = false;
nsresult rv = aURI->SchemeIs(BLOBURI_SCHEME, &isBlobURL);
NS_ENSURE_SUCCESS(rv, rv);
// For Blob URI, the path is the URL of the owning page.
if (isBlobURL) {
nsAutoCString path;
rv = aURI->GetPathQueryRef(path);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIURI> uri;
nsresult rv = NS_NewURI(getter_AddRefs(uri), path);
if (rv == NS_ERROR_UNKNOWN_PROTOCOL) {
return NS_ERROR_UNKNOWN_PROTOCOL;
}
if (NS_FAILED(rv)) {
aOrigin.AssignLiteral("null");
return NS_OK;
}
return GetThreadSafeASCIIOrigin(uri, aOrigin);
}
aOrigin.Truncate();
// This is not supported yet.
nsCOMPtr<nsINestedURI> nestedURI(do_QueryInterface(aURI));
if (nestedURI) {
return NS_ERROR_UNKNOWN_PROTOCOL;
}
nsAutoCString host;
rv = aURI->GetAsciiHost(host);
if (NS_SUCCEEDED(rv) && !host.IsEmpty()) {
nsAutoCString userPass;
aURI->GetUserPass(userPass);
nsCOMPtr<nsIURI> uri = aURI;
nsAutoCString prePath;
if (!userPass.IsEmpty()) {
rv = NS_MutateURI(uri).SetUserPass(EmptyCString()).Finalize(uri);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = uri->GetPrePath(prePath);
NS_ENSURE_SUCCESS(rv, rv);
aOrigin = prePath;
} else {
aOrigin.AssignLiteral("null");
}
return NS_OK;
}
/* static */
nsresult nsContentUtils::GetUTFOrigin(nsIPrincipal* aPrincipal,
nsAString& aOrigin) {
@ -5877,7 +5813,6 @@ nsresult nsContentUtils::GetUTFOrigin(nsIPrincipal* aPrincipal,
/* static */
nsresult nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin) {
MOZ_ASSERT(aURI, "missing uri");
MOZ_ASSERT(NS_IsMainThread());
nsresult rv;
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
@ -5901,24 +5836,6 @@ nsresult nsContentUtils::GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin) {
return NS_OK;
}
/* static */
nsresult nsContentUtils::GetThreadSafeUTFOrigin(nsIURI* aURI,
nsAString& aOrigin) {
#if defined(MOZ_THUNDERBIRD) || defined(MOZ_SUITE)
return NS_ERROR_UNKNOWN_PROTOCOL;
#endif
MOZ_ASSERT(aURI, "missing uri");
nsresult rv;
nsAutoCString asciiOrigin;
rv = GetThreadSafeASCIIOrigin(aURI, asciiOrigin);
NS_ENSURE_SUCCESS(rv, rv);
aOrigin = NS_ConvertUTF8toUTF16(asciiOrigin);
return NS_OK;
}
/* static */
bool nsContentUtils::CheckMayLoad(nsIPrincipal* aPrincipal,
nsIChannel* aChannel,

View File

@ -2141,10 +2141,8 @@ class nsContentUtils {
*/
static nsresult GetASCIIOrigin(nsIPrincipal* aPrincipal, nsACString& aOrigin);
static nsresult GetASCIIOrigin(nsIURI* aURI, nsACString& aOrigin);
static nsresult GetThreadSafeASCIIOrigin(nsIURI* aURI, nsACString& aOrigin);
static nsresult GetUTFOrigin(nsIPrincipal* aPrincipal, nsAString& aOrigin);
static nsresult GetUTFOrigin(nsIURI* aURI, nsAString& aOrigin);
static nsresult GetThreadSafeUTFOrigin(nsIURI* aURI, nsAString& aOrigin);
/**
* This method creates and dispatches "command" event, which implements

View File

@ -172,7 +172,7 @@ void URL::SetHref(const nsAString& aHref, ErrorResult& aRv) {
}
void URL::GetOrigin(nsAString& aOrigin, ErrorResult& aRv) const {
nsresult rv = nsContentUtils::GetThreadSafeUTFOrigin(GetURI(), aOrigin);
nsresult rv = nsContentUtils::GetUTFOrigin(GetURI(), aOrigin);
if (NS_WARN_IF(NS_FAILED(rv))) {
aOrigin.Truncate();
}