/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim:set ts=4 sw=2 sts=2 et cin: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* static */ nsresult nsChromeProtocolHandler::CreateNewURI( const nsACString& aSpec, constchar* aCharset, nsIURI* aBaseURI,
nsIURI** result) { // Chrome: URLs (currently) have no additional structure beyond that provided // by standard URLs, so there is no "outer" given to CreateInstance
nsresult rv;
nsCOMPtr<nsIURI> surl;
rv =
NS_MutateURI(new mozilla::net::nsStandardURL::Mutator())
.Apply(&nsIStandardURLMutator::Init, nsIStandardURL::URLTYPE_STANDARD,
-1, aSpec, aCharset, aBaseURI, nullptr)
.Finalize(surl); if (NS_FAILED(rv)) { return rv;
}
// Canonify the "chrome:" URL; e.g., so that we collapse // "chrome://navigator/content/" and "chrome://navigator/content" // and "chrome://navigator/content/navigator.xul".
if (!nsChromeRegistry::gChromeRegistry) { // We don't actually want this ref, we just want the service to // initialize if it hasn't already.
nsCOMPtr<nsIChromeRegistry> reg = mozilla::services::GetChromeRegistry();
NS_ENSURE_TRUE(nsChromeRegistry::gChromeRegistry, NS_ERROR_FAILURE);
}
// We don't want to allow the inner protocol handler modify the result // principal URI since we want either |aURI| or anything pre-set by upper // layers to prevail.
nsCOMPtr<nsIURI> savedResultPrincipalURI;
rv =
aLoadInfo->GetResultPrincipalURI(getter_AddRefs(savedResultPrincipalURI));
NS_ENSURE_SUCCESS(rv, rv);
// Make sure that the channel remembers where it was // originally loaded from.
rv = aLoadInfo->SetResultPrincipalURI(savedResultPrincipalURI);
NS_ENSURE_SUCCESS(rv, rv);
rv = result->SetOriginalURI(aURI); if (NS_FAILED(rv)) return rv;
// Use a system principal for /content and /skin files. // See bug 1855225 for discussion about whether to extend it more generally // to other chrome:// URIs.
nsAutoCString path;
aURI->GetPathQueryRef(path); if (StringBeginsWith(path, "/content/"_ns) ||
StringBeginsWith(path, "/skin/"_ns)) {
result->SetOwner(nsContentUtils::GetSystemPrincipal());
}
// XXX Removed dependency-tracking code from here, because we're not // tracking them anyways (with fastload we checked only in DEBUG // and with startupcache not at all), but this is where we would start // if we need to re-add. // See bug 531886, bug 533038.
result->SetContentCharset("UTF-8"_ns);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.