Bug 1558915 - Use infallible nsIURI::SchemeIs in toolkit/ r=Ehsan

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Schuster 2019-08-02 16:31:54 +00:00
Родитель 4e8705e93b
Коммит 37b519e15a
9 изменённых файлов: 18 добавлений и 41 удалений

Просмотреть файл

@ -220,10 +220,7 @@ int32_t CookiesBehavior(nsILoadInfo* aLoadInfo,
// WebExtensions 3rd party URI always get BEHAVIOR_ACCEPT as cookieBehavior,
// this is semantically equivalent to the principal having a AddonPolicy().
bool is3rdPartyMozExt = false;
if (NS_SUCCEEDED(
a3rdPartyURI->SchemeIs("moz-extension", &is3rdPartyMozExt)) &&
is3rdPartyMozExt) {
if (a3rdPartyURI->SchemeIs("moz-extension")) {
return nsICookieService::BEHAVIOR_ACCEPT;
}

Просмотреть файл

@ -138,12 +138,8 @@ static StorageAccess InternalStorageAllowedCheck(
if (!uri) {
Unused << aPrincipal->GetURI(getter_AddRefs(uri));
}
if (uri) {
bool isAbout = false;
MOZ_ALWAYS_SUCCEEDS(uri->SchemeIs("about", &isAbout));
if (isAbout) {
return access;
}
if (uri && uri->SchemeIs("about")) {
return access;
}
if (!StorageDisabledByAntiTracking(aWindow, aChannel, aPrincipal, aURI,

Просмотреть файл

@ -1919,10 +1919,7 @@ nsNavBookmarks::OnPageChanged(nsIURI* aURI, uint32_t aChangedAttribute,
changeData.bookmark.type = TYPE_BOOKMARK;
// Favicons may be set to either pure URIs or to folder URIs
bool isPlaceURI;
rv = aURI->SchemeIs("place", &isPlaceURI);
NS_ENSURE_SUCCESS(rv, rv);
if (isPlaceURI) {
if (aURI->SchemeIs("place")) {
nsNavHistory* history = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -177,9 +177,7 @@ nsresult nsUrlClassifierStreamUpdater::FetchUpdate(
// Set the appropriate content type for file/data URIs, for unit testing
// purposes.
// This is only used for testing and should be deleted.
bool match;
if ((NS_SUCCEEDED(aUpdateUrl->SchemeIs("file", &match)) && match) ||
(NS_SUCCEEDED(aUpdateUrl->SchemeIs("data", &match)) && match)) {
if (aUpdateUrl->SchemeIs("file") || aUpdateUrl->SchemeIs("data")) {
mChannel->SetContentType(
NS_LITERAL_CSTRING("application/vnd.google.safebrowsing-update"));
} else {

Просмотреть файл

@ -617,7 +617,7 @@ nsresult nsWindowWatcher::OpenWindowInternal(
if (NS_FAILED(rv)) {
return rv;
}
uriToLoad->SchemeIs("chrome", &uriToLoadIsChrome);
uriToLoadIsChrome = uriToLoad->SchemeIs("chrome");
}
bool nameSpecified = false;

Просмотреть файл

@ -111,11 +111,8 @@ AddonContentPolicy::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo,
// Only apply this policy to requests from documents loaded from
// moz-extension URLs, or to resources being loaded from moz-extension URLs.
bool equals;
if (!((NS_SUCCEEDED(aContentLocation->SchemeIs("moz-extension", &equals)) &&
equals) ||
(NS_SUCCEEDED(requestOrigin->SchemeIs("moz-extension", &equals)) &&
equals))) {
if (!(aContentLocation->SchemeIs("moz-extension") ||
requestOrigin->SchemeIs("moz-extension"))) {
return NS_OK;
}

Просмотреть файл

@ -55,9 +55,7 @@ bool AddonManagerWebAPI::IsValidSite(nsIURI* uri) {
return false;
}
bool isSecure;
nsresult rv = uri->SchemeIs("https", &isSecure);
if (NS_FAILED(rv) || !isSecure) {
if (!uri->SchemeIs("https")) {
if (!(xpc::IsInAutomation() &&
Preferences::GetBool("extensions.webapi.testing.http", false))) {
return false;
@ -65,7 +63,7 @@ bool AddonManagerWebAPI::IsValidSite(nsIURI* uri) {
}
nsAutoCString host;
rv = uri->GetHost(host);
nsresult rv = uri->GetHost(host);
if (NS_FAILED(rv)) {
return false;
}

Просмотреть файл

@ -175,10 +175,9 @@ static nsresult GetProxyFromEnvironment(const nsACString& aScheme,
// Is there a way to specify "socks://" or something in these environment
// variables? I can't find any documentation.
bool isHTTP;
rv = proxyURI->SchemeIs("http", &isHTTP);
NS_ENSURE_SUCCESS(rv, rv);
if (!isHTTP) return NS_ERROR_UNKNOWN_PROTOCOL;
if (!proxyURI->SchemeIs("http")) {
return NS_ERROR_UNKNOWN_PROTOCOL;
}
nsAutoCString proxyHost;
rv = proxyURI->GetHost(proxyHost);

Просмотреть файл

@ -1001,18 +1001,13 @@ nsXULAppInfo::GetServerURL(nsIURL** aServerURL) {
NS_IMETHODIMP
nsXULAppInfo::SetServerURL(nsIURL* aServerURL) {
bool schemeOk;
// only allow https or http URLs
nsresult rv = aServerURL->SchemeIs("https", &schemeOk);
NS_ENSURE_SUCCESS(rv, rv);
if (!schemeOk) {
rv = aServerURL->SchemeIs("http", &schemeOk);
NS_ENSURE_SUCCESS(rv, rv);
if (!schemeOk) return NS_ERROR_INVALID_ARG;
// Only allow https or http URLs
if (!aServerURL->SchemeIs("http") && !aServerURL->SchemeIs("https")) {
return NS_ERROR_INVALID_ARG;
}
nsAutoCString spec;
rv = aServerURL->GetSpec(spec);
nsresult rv = aServerURL->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
return CrashReporter::SetServerURL(spec);