зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1558915 - Use infallible nsIURI::SchemeIs in various places r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D40677 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6016550e26
Коммит
03c7998ef2
|
@ -372,9 +372,9 @@ bool nsCoreUtils::IsTabDocument(Document* aDocumentNode) {
|
|||
|
||||
bool nsCoreUtils::IsErrorPage(Document* aDocument) {
|
||||
nsIURI* uri = aDocument->GetDocumentURI();
|
||||
bool isAboutScheme = false;
|
||||
uri->SchemeIs("about", &isAboutScheme);
|
||||
if (!isAboutScheme) return false;
|
||||
if (!uri->SchemeIs("about")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsAutoCString path;
|
||||
uri->GetPathQueryRef(path);
|
||||
|
|
|
@ -143,10 +143,8 @@ nsresult ContentPrincipal::GenerateOriginNoSuffixFromURI(
|
|||
// These constraints can generally be achieved by restricting .origin to
|
||||
// nsIStandardURL-based URIs, but there are a few other URI schemes that we
|
||||
// need to handle.
|
||||
bool isBehaved;
|
||||
if ((NS_SUCCEEDED(origin->SchemeIs("about", &isBehaved)) && isBehaved) ||
|
||||
(NS_SUCCEEDED(origin->SchemeIs("moz-safe-about", &isBehaved)) &&
|
||||
isBehaved &&
|
||||
if (origin->SchemeIs("about") ||
|
||||
(origin->SchemeIs("moz-safe-about") &&
|
||||
// We generally consider two about:foo origins to be same-origin, but
|
||||
// about:blank is special since it can be generated from different
|
||||
// sources. We check for moz-safe-about:blank since origin is an
|
||||
|
@ -198,10 +196,7 @@ nsresult ContentPrincipal::GenerateOriginNoSuffixFromURI(
|
|||
|
||||
// See whether we have a useful hostPort. If we do, use that.
|
||||
nsAutoCString hostPort;
|
||||
bool isChrome = false;
|
||||
rv = origin->SchemeIs("chrome", &isChrome);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!isChrome) {
|
||||
if (!origin->SchemeIs("chrome")) {
|
||||
rv = origin->GetAsciiHostPort(hostPort);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
@ -408,8 +403,7 @@ static nsresult GetSpecialBaseDomain(const nsCOMPtr<nsIURI>& aURI,
|
|||
return aURI->GetSpec(aBaseDomain);
|
||||
}
|
||||
|
||||
bool isBehaved;
|
||||
if (NS_SUCCEEDED(aURI->SchemeIs("indexeddb", &isBehaved)) && isBehaved) {
|
||||
if (aURI->SchemeIs("indexeddb")) {
|
||||
*aHandled = true;
|
||||
return aURI->GetSpec(aBaseDomain);
|
||||
}
|
||||
|
@ -520,8 +514,7 @@ WebExtensionPolicy* ContentPrincipal::AddonPolicy() {
|
|||
if (!mAddon.isSome()) {
|
||||
NS_ENSURE_TRUE(mURI, nullptr);
|
||||
|
||||
bool isMozExt;
|
||||
if (NS_SUCCEEDED(mURI->SchemeIs("moz-extension", &isMozExt)) && isMozExt) {
|
||||
if (mURI->SchemeIs("moz-extension")) {
|
||||
mAddon.emplace(EPS().GetByURL(mURI.get()));
|
||||
} else {
|
||||
mAddon.emplace(nullptr);
|
||||
|
@ -554,8 +547,7 @@ ContentPrincipal::Read(nsIObjectInputStream* aStream) {
|
|||
principalURI = do_QueryInterface(supports);
|
||||
// Enforce re-parsing about: URIs so that if they change, we continue to use
|
||||
// their new principals correctly.
|
||||
bool isAbout = false;
|
||||
if (NS_SUCCEEDED(principalURI->SchemeIs("about", &isAbout)) && isAbout) {
|
||||
if (principalURI->SchemeIs("about")) {
|
||||
nsAutoCString spec;
|
||||
principalURI->GetSpec(spec);
|
||||
NS_ENSURE_SUCCESS(NS_NewURI(getter_AddRefs(principalURI), spec),
|
||||
|
@ -677,10 +669,7 @@ already_AddRefed<BasePrincipal> ContentPrincipal::FromProperties(
|
|||
{
|
||||
// Enforce re-parsing about: URIs so that if they change, we
|
||||
// continue to use their new principals correctly.
|
||||
bool isAbout =
|
||||
NS_SUCCEEDED(principalURI->SchemeIs("about", &isAbout)) &&
|
||||
isAbout;
|
||||
if (isAbout) {
|
||||
if (principalURI->SchemeIs("about")) {
|
||||
nsAutoCString spec;
|
||||
principalURI->GetSpec(spec);
|
||||
if (NS_FAILED(NS_NewURI(getter_AddRefs(principalURI), spec))) {
|
||||
|
|
|
@ -688,8 +688,6 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
|||
"security.view-source.reachable-from-inner-protocol");
|
||||
}
|
||||
|
||||
bool targetIsViewSource = false;
|
||||
|
||||
if (sourceScheme.LowerCaseEqualsLiteral(NS_NULLPRINCIPAL_SCHEME)) {
|
||||
// A null principal can target its own URI.
|
||||
if (sourceURI == aTargetURI) {
|
||||
|
@ -697,9 +695,7 @@ nsScriptSecurityManager::CheckLoadURIWithPrincipal(nsIPrincipal* aPrincipal,
|
|||
}
|
||||
} else if (sViewSourceReachableFromInner &&
|
||||
sourceScheme.EqualsIgnoreCase(targetScheme.get()) &&
|
||||
NS_SUCCEEDED(
|
||||
aTargetURI->SchemeIs("view-source", &targetIsViewSource)) &&
|
||||
targetIsViewSource) {
|
||||
aTargetURI->SchemeIs("view-source")) {
|
||||
// exception for foo: linking to view-source:foo for reftests...
|
||||
return NS_OK;
|
||||
} else if (sourceScheme.EqualsIgnoreCase("file") &&
|
||||
|
@ -948,9 +944,7 @@ nsresult nsScriptSecurityManager::CheckLoadURIFlags(
|
|||
}
|
||||
|
||||
// Allow chrome://
|
||||
bool isChrome = false;
|
||||
if (NS_SUCCEEDED(aSourceBaseURI->SchemeIs("chrome", &isChrome)) &&
|
||||
isChrome) {
|
||||
if (aSourceBaseURI->SchemeIs("chrome")) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -134,11 +134,7 @@ nsresult nsChromeRegistry::GetProviderAndPath(nsIURI* aChromeURL,
|
|||
nsACString& aPath) {
|
||||
nsresult rv;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool isChrome;
|
||||
aChromeURL->SchemeIs("chrome", &isChrome);
|
||||
NS_ASSERTION(isChrome, "Non-chrome URI?");
|
||||
#endif
|
||||
NS_ASSERTION(aChromeURL->SchemeIs("chrome"), "Non-chrome URI?");
|
||||
|
||||
nsAutoCString path;
|
||||
rv = aChromeURL->GetPathQueryRef(path);
|
||||
|
@ -284,11 +280,8 @@ nsChromeRegistry::AllowScriptsForPackage(nsIURI* aChromeURI, bool* aResult) {
|
|||
nsresult rv;
|
||||
*aResult = false;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool isChrome;
|
||||
aChromeURI->SchemeIs("chrome", &isChrome);
|
||||
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowScriptsForPackage!");
|
||||
#endif
|
||||
NS_ASSERTION(aChromeURI->SchemeIs("chrome"),
|
||||
"Non-chrome URI passed to AllowScriptsForPackage!");
|
||||
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(aChromeURI));
|
||||
NS_ENSURE_TRUE(url, NS_NOINTERFACE);
|
||||
|
@ -308,11 +301,8 @@ nsChromeRegistry::AllowContentToAccess(nsIURI* aURI, bool* aResult) {
|
|||
|
||||
*aResult = false;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool isChrome;
|
||||
aURI->SchemeIs("chrome", &isChrome);
|
||||
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowContentToAccess!");
|
||||
#endif
|
||||
NS_ASSERTION(aURI->SchemeIs("chrome"),
|
||||
"Non-chrome URI passed to AllowContentToAccess!");
|
||||
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
||||
if (!url) {
|
||||
|
@ -339,11 +329,8 @@ nsChromeRegistry::CanLoadURLRemotely(nsIURI* aURI, bool* aResult) {
|
|||
|
||||
*aResult = false;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool isChrome;
|
||||
aURI->SchemeIs("chrome", &isChrome);
|
||||
NS_ASSERTION(isChrome, "Non-chrome URI passed to CanLoadURLRemotely!");
|
||||
#endif
|
||||
NS_ASSERTION(aURI->SchemeIs("chrome"),
|
||||
"Non-chrome URI passed to CanLoadURLRemotely!");
|
||||
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
||||
if (!url) {
|
||||
|
@ -370,11 +357,8 @@ nsChromeRegistry::MustLoadURLRemotely(nsIURI* aURI, bool* aResult) {
|
|||
|
||||
*aResult = false;
|
||||
|
||||
#ifdef DEBUG
|
||||
bool isChrome;
|
||||
aURI->SchemeIs("chrome", &isChrome);
|
||||
NS_ASSERTION(isChrome, "Non-chrome URI passed to MustLoadURLRemotely!");
|
||||
#endif
|
||||
NS_ASSERTION(aURI->SchemeIs("chrome"),
|
||||
"Non-chrome URI passed to MustLoadURLRemotely!");
|
||||
|
||||
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
||||
if (!url) {
|
||||
|
|
|
@ -594,13 +594,8 @@ void nsChromeRegistryChrome::ManifestOverride(ManifestProcessingContext& cx,
|
|||
}
|
||||
|
||||
if (cx.mType == NS_SKIN_LOCATION) {
|
||||
bool chromeSkinOnly = false;
|
||||
nsresult rv = chromeuri->SchemeIs("chrome", &chromeSkinOnly);
|
||||
chromeSkinOnly = chromeSkinOnly && NS_SUCCEEDED(rv);
|
||||
if (chromeSkinOnly) {
|
||||
rv = resolveduri->SchemeIs("chrome", &chromeSkinOnly);
|
||||
chromeSkinOnly = chromeSkinOnly && NS_SUCCEEDED(rv);
|
||||
}
|
||||
bool chromeSkinOnly =
|
||||
chromeuri->SchemeIs("chrome") && resolveduri->SchemeIs("chrome");
|
||||
if (chromeSkinOnly) {
|
||||
nsAutoCString chromePath, resolvedPath;
|
||||
chromeuri->GetPathQueryRef(chromePath);
|
||||
|
|
|
@ -447,12 +447,8 @@ already_AddRefed<IDBOpenDBRequest> IDBFactory::Open(
|
|||
if (principal) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = principal->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv) && uri) {
|
||||
bool isAbout;
|
||||
rv = uri->SchemeIs("about", &isAbout);
|
||||
if (NS_SUCCEEDED(rv) && isAbout) {
|
||||
ignore = true;
|
||||
}
|
||||
if (NS_SUCCEEDED(rv) && uri && uri->SchemeIs("about")) {
|
||||
ignore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -319,14 +319,10 @@ nsresult nsContentBlocker::TestPermission(nsIURI* aCurrentURI,
|
|||
// Need a requesting uri for third party checks to work.
|
||||
if (!aFirstURI) return NS_OK;
|
||||
|
||||
bool trustedSource = false;
|
||||
rv = aFirstURI->SchemeIs("chrome", &trustedSource);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (!trustedSource) {
|
||||
rv = aFirstURI->SchemeIs("resource", &trustedSource);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// chrome: and resource: are always trusted.
|
||||
if (aFirstURI->SchemeIs("chrome") || aFirstURI->SchemeIs("resource")) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (trustedSource) return NS_OK;
|
||||
|
||||
// compare tails of names checking to see if they have a common domain
|
||||
// we do this by comparing the tails of both names where each tail
|
||||
|
|
|
@ -478,9 +478,7 @@ nsresult UpgradeHostToOriginAndInsert(
|
|||
// It was previously possible to insert useless entries to your permissions
|
||||
// database for URIs which have a null principal. This acts as a cleanup,
|
||||
// getting rid of these useless database entries
|
||||
bool nullpScheme = false;
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("moz-nullprincipal", &nullpScheme)) &&
|
||||
nullpScheme) {
|
||||
if (uri->SchemeIs("moz-nullprincipal")) {
|
||||
NS_WARNING("A moz-nullprincipal: permission is being discarded.");
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -1349,9 +1349,7 @@ void gfxUserFontSet::UserFontCache::Entry::ReportMemory(
|
|||
spec.ReplaceChar('/', '\\');
|
||||
// Some fonts are loaded using horrendously-long data: URIs;
|
||||
// truncate those before reporting them.
|
||||
bool isData;
|
||||
if (NS_SUCCEEDED(mURI->get()->SchemeIs("data", &isData)) && isData &&
|
||||
spec.Length() > 255) {
|
||||
if (mURI->get()->SchemeIs("data") && spec.Length() > 255) {
|
||||
spec.Truncate(252);
|
||||
spec.AppendLiteral("...");
|
||||
}
|
||||
|
|
|
@ -322,10 +322,9 @@ nsresult ScriptPreloader::Observe(nsISupports* subject, const char* topic,
|
|||
if (nsCOMPtr<dom::Document> doc = do_QueryInterface(subject)) {
|
||||
nsCOMPtr<nsIURI> uri = doc->GetDocumentURI();
|
||||
|
||||
bool schemeIs;
|
||||
if ((NS_IsAboutBlank(uri) &&
|
||||
doc->GetReadyStateEnum() == doc->READYSTATE_UNINITIALIZED) ||
|
||||
(NS_SUCCEEDED(uri->SchemeIs("chrome", &schemeIs)) && schemeIs)) {
|
||||
uri->SchemeIs("chrome")) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -401,11 +401,9 @@ static bool PrincipalImmuneToScriptPolicy(nsIPrincipal* aPrincipal) {
|
|||
aPrincipal->GetURI(getter_AddRefs(principalURI));
|
||||
MOZ_ASSERT(principalURI);
|
||||
|
||||
bool isAbout;
|
||||
nsresult rv = principalURI->SchemeIs("about", &isAbout);
|
||||
if (NS_SUCCEEDED(rv) && isAbout) {
|
||||
if (principalURI->SchemeIs("about")) {
|
||||
nsCOMPtr<nsIAboutModule> module;
|
||||
rv = NS_GetAboutModule(principalURI, getter_AddRefs(module));
|
||||
nsresult rv = NS_GetAboutModule(principalURI, getter_AddRefs(module));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
uint32_t flags;
|
||||
rv = module->GetURIFlags(principalURI, &flags);
|
||||
|
|
|
@ -687,12 +687,7 @@ void nsPresContext::AttachPresShell(mozilla::PresShell* aPresShell) {
|
|||
nsIURI* docURI = doc->GetDocumentURI();
|
||||
|
||||
if (IsDynamic() && docURI) {
|
||||
bool isChrome = false;
|
||||
bool isRes = false;
|
||||
docURI->SchemeIs("chrome", &isChrome);
|
||||
docURI->SchemeIs("resource", &isRes);
|
||||
|
||||
if (!isChrome && !isRes)
|
||||
if (!docURI->SchemeIs("chrome") && !docURI->SchemeIs("resource"))
|
||||
mImageAnimationMode = mImageAnimationModePref;
|
||||
else
|
||||
mImageAnimationMode = imgIContainer::kNormalAnimMode;
|
||||
|
|
|
@ -587,9 +587,7 @@ nsresult FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry,
|
|||
gfxFontSrcPrincipal* principal = aUserFontEntry->GetPrincipal();
|
||||
|
||||
uint32_t securityFlags = 0;
|
||||
bool isFile = false;
|
||||
if (NS_SUCCEEDED(aFontFaceSrc->mURI->get()->SchemeIs("file", &isFile)) &&
|
||||
isFile) {
|
||||
if (aFontFaceSrc->mURI->get()->SchemeIs("file")) {
|
||||
securityFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
|
||||
} else {
|
||||
securityFlags = nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
|
||||
|
|
|
@ -224,11 +224,11 @@ nsresult nsJARChannel::Init(nsIURI* uri) {
|
|||
// Prevent loading jar:javascript URIs (see bug 290982).
|
||||
nsCOMPtr<nsIURI> innerURI;
|
||||
rv = mJarURI->GetJARFile(getter_AddRefs(innerURI));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
bool isJS;
|
||||
rv = innerURI->SchemeIs("javascript", &isJS);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (isJS) {
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (innerURI->SchemeIs("javascript")) {
|
||||
NS_WARNING("blocking jar:javascript:");
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
|
|
@ -364,17 +364,13 @@ void nsHtml5StreamParser::SetViewSourceTitle(nsIURI* aURL) {
|
|||
|
||||
if (aURL) {
|
||||
nsCOMPtr<nsIURI> temp;
|
||||
bool isViewSource;
|
||||
aURL->SchemeIs("view-source", &isViewSource);
|
||||
if (isViewSource) {
|
||||
if (aURL->SchemeIs("view-source")) {
|
||||
nsCOMPtr<nsINestedURI> nested = do_QueryInterface(aURL);
|
||||
nested->GetInnerURI(getter_AddRefs(temp));
|
||||
} else {
|
||||
temp = aURL;
|
||||
}
|
||||
bool isData;
|
||||
temp->SchemeIs("data", &isData);
|
||||
if (isData) {
|
||||
if (temp->SchemeIs("data")) {
|
||||
// Avoid showing potentially huge data: URLs. The three last bytes are
|
||||
// UTF-8 for an ellipsis.
|
||||
mViewSourceTitle.AssignLiteral("data:\xE2\x80\xA6");
|
||||
|
@ -1045,9 +1041,7 @@ nsresult nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest) {
|
|||
nsCOMPtr<nsIURI> originalURI;
|
||||
rv = channel->GetOriginalURI(getter_AddRefs(originalURI));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
bool originalIsResource;
|
||||
originalURI->SchemeIs("resource", &originalIsResource);
|
||||
if (originalIsResource) {
|
||||
if (originalURI->SchemeIs("resource")) {
|
||||
mCharsetSource = kCharsetFromBuiltIn;
|
||||
mEncoding = UTF_8_ENCODING;
|
||||
} else {
|
||||
|
@ -1055,9 +1049,7 @@ nsresult nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest) {
|
|||
rv = channel->GetURI(getter_AddRefs(currentURI));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIURI> innermost = NS_GetInnermostURI(currentURI);
|
||||
bool innermostIsFile;
|
||||
innermost->SchemeIs("file", &innermostIsFile);
|
||||
mDecodingLocalFileAsUTF8 = innermostIsFile;
|
||||
mDecodingLocalFileAsUTF8 = innermost->SchemeIs("file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -880,9 +880,7 @@ nsIURI* nsHtml5TreeOpExecutor::GetViewSourceBaseURI() {
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> orig = mDocument->GetOriginalURI();
|
||||
bool isViewSource;
|
||||
orig->SchemeIs("view-source", &isViewSource);
|
||||
if (isViewSource) {
|
||||
if (orig->SchemeIs("view-source")) {
|
||||
nsCOMPtr<nsINestedURI> nested = do_QueryInterface(orig);
|
||||
NS_ASSERTION(nested, "URI with scheme view-source didn't QI to nested!");
|
||||
nested->GetInnerURI(getter_AddRefs(mViewSourceBaseURI));
|
||||
|
@ -899,11 +897,10 @@ bool nsHtml5TreeOpExecutor::IsExternalViewSource() {
|
|||
if (!StaticPrefs::view_source_editor_external()) {
|
||||
return false;
|
||||
}
|
||||
bool isViewSource = false;
|
||||
if (mDocumentURI) {
|
||||
mDocumentURI->SchemeIs("view-source", &isViewSource);
|
||||
return mDocumentURI->SchemeIs("view-source");
|
||||
}
|
||||
return isViewSource;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Speculative loading
|
||||
|
|
|
@ -136,12 +136,11 @@ static inline bool canonicalizeBase(nsAutoCString& spec, nsACString& out) {
|
|||
* underlying resource, or returns any other URI unchanged.
|
||||
*/
|
||||
nsresult ResolveURI(nsIURI* in, nsIURI** out) {
|
||||
bool equals;
|
||||
nsresult rv;
|
||||
|
||||
// Resolve resource:// URIs. At the end of this if/else block, we
|
||||
// have both spec and uri variables identifying the same URI.
|
||||
if (NS_SUCCEEDED(in->SchemeIs("resource", &equals)) && equals) {
|
||||
if (in->SchemeIs("resource")) {
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -157,7 +156,7 @@ nsresult ResolveURI(nsIURI* in, nsIURI** out) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return ioService->NewURI(spec, nullptr, nullptr, out);
|
||||
} else if (NS_SUCCEEDED(in->SchemeIs("chrome", &equals)) && equals) {
|
||||
} else if (in->SchemeIs("chrome")) {
|
||||
nsCOMPtr<nsIChromeRegistry> chromeReg =
|
||||
mozilla::services::GetChromeRegistryService();
|
||||
if (!chromeReg) return NS_ERROR_UNEXPECTED;
|
||||
|
@ -207,7 +206,7 @@ nsresult PathifyURI(nsIURI* in, nsACString& out) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!canonicalizeBase(spec, out)) {
|
||||
if (NS_SUCCEEDED(uri->SchemeIs("file", &equals)) && equals) {
|
||||
if (uri->SchemeIs("file")) {
|
||||
nsCOMPtr<nsIFileURL> baseFileURL;
|
||||
baseFileURL = do_QueryInterface(uri, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -217,7 +216,7 @@ nsresult PathifyURI(nsIURI* in, nsACString& out) {
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
out.Append(path);
|
||||
} else if (NS_SUCCEEDED(uri->SchemeIs("jar", &equals)) && equals) {
|
||||
} else if (uri->SchemeIs("jar")) {
|
||||
nsCOMPtr<nsIJARURI> jarURI = do_QueryInterface(uri, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -85,14 +85,11 @@ class ThumbnailHelper final
|
|||
// Deny storage if we're viewing a HTTPS page with a 'Cache-Control'
|
||||
// header having a value that is not 'public', unless enabled by user.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
bool isHttps = false;
|
||||
|
||||
if (NS_FAILED(channel->GetURI(getter_AddRefs(uri))) || !uri ||
|
||||
NS_FAILED(uri->SchemeIs("https", &isHttps))) {
|
||||
if (NS_FAILED(channel->GetURI(getter_AddRefs(uri))) || !uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isHttps ||
|
||||
if (!uri->SchemeIs("https") ||
|
||||
Preferences::GetBool("browser.cache.disk_cache_ssl", false)) {
|
||||
// Allow storing non-HTTPS thumbnails, and HTTPS ones if enabled by
|
||||
// user.
|
||||
|
|
|
@ -313,9 +313,8 @@ NS_IMETHODIMP nsSound::Play(nsIURL* aURL) {
|
|||
|
||||
if (!libcanberra) return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
bool isFile;
|
||||
nsresult rv = aURL->SchemeIs("file", &isFile);
|
||||
if (NS_SUCCEEDED(rv) && isFile) {
|
||||
nsresult rv;
|
||||
if (aURL->SchemeIs("file")) {
|
||||
ca_context* ctx = ca_context_get_default();
|
||||
if (!ctx) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -20,8 +20,7 @@ nsSoundProxy::Play(nsIURL* aURL) {
|
|||
nsCOMPtr<nsIURI> soundURI(aURL);
|
||||
bool isChrome = false;
|
||||
// Only allow playing a chrome:// URL from the content process.
|
||||
if (!soundURI || NS_FAILED(soundURI->SchemeIs("chrome", &isChrome)) ||
|
||||
!isChrome) {
|
||||
if (!soundURI || !soundURI->SchemeIs("chrome")) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче