mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1585664 - Add GetAsciiSpecForLogging and update callers r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D47909 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7e6ee22f60
commit
f4b2f14328
@ -423,6 +423,17 @@ BasePrincipal::GetIsExpandedPrincipal(bool* aResult) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetAsciiSpec(nsACString& aSpec) {
|
||||
aSpec.Truncate();
|
||||
nsCOMPtr<nsIURI> prinURI;
|
||||
nsresult rv = GetURI(getter_AddRefs(prinURI));
|
||||
if (NS_FAILED(rv) || !prinURI) {
|
||||
return NS_OK;
|
||||
}
|
||||
return prinURI->GetAsciiSpec(aSpec);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
BasePrincipal::GetIsSystemPrincipal(bool* aResult) {
|
||||
*aResult = IsSystemPrincipal();
|
||||
|
@ -121,6 +121,7 @@ class BasePrincipal : public nsJSPrincipals {
|
||||
NS_IMETHOD GetIsAddonOrExpandedAddonPrincipal(bool* aResult) override;
|
||||
NS_IMETHOD GetOriginAttributes(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aVal) final;
|
||||
NS_IMETHOD GetAsciiSpec(nsACString& aSpec) override;
|
||||
NS_IMETHOD GetOriginSuffix(nsACString& aOriginSuffix) final;
|
||||
NS_IMETHOD GetIsInIsolatedMozBrowserElement(
|
||||
bool* aIsInIsolatedMozBrowserElement) final;
|
||||
|
@ -199,6 +199,16 @@ interface nsIPrincipal : nsISerializable
|
||||
*/
|
||||
readonly attribute ACString origin;
|
||||
|
||||
/**
|
||||
* Returns the ASCII Spec from the Principals URI.
|
||||
* Might return the empty string, e.g. for the case of
|
||||
* a SystemPrincipal or an EpxandedPrincipal.
|
||||
*
|
||||
* WARNING: DO NOT USE FOR SECURITY CHECKS.
|
||||
* just for logging purposes!
|
||||
*/
|
||||
readonly attribute ACString AsciiSpec;
|
||||
|
||||
/**
|
||||
* Checks if the Principal's URI Scheme matches with the parameter
|
||||
*
|
||||
|
@ -30,15 +30,13 @@ void FramingChecker::ReportError(const char* aMessageTag,
|
||||
}
|
||||
|
||||
Document* parentDocument = aParentDocShellItem->GetDocument();
|
||||
nsCOMPtr<nsIURI> parentURI;
|
||||
parentDocument->NodePrincipal()->GetURI(getter_AddRefs(parentURI));
|
||||
MOZ_ASSERT(!parentDocument->NodePrincipal()->IsSystemPrincipal(),
|
||||
"Should not get system principal here.");
|
||||
|
||||
// Get the parent URL spec
|
||||
nsAutoCString parentSpec;
|
||||
nsresult rv;
|
||||
rv = parentURI->GetAsciiSpec(parentSpec);
|
||||
rv = parentDocument->NodePrincipal()->GetAsciiSpec(parentSpec);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
@ -629,12 +629,8 @@ static void LogPrincipal(nsIPrincipal* aPrincipal,
|
||||
origin.get()));
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIURI> principalURI;
|
||||
nsAutoCString principalSpec;
|
||||
aPrincipal->GetURI(getter_AddRefs(principalURI));
|
||||
if (principalURI) {
|
||||
principalURI->GetSpec(principalSpec);
|
||||
}
|
||||
aPrincipal->GetAsciiSpec(principalSpec);
|
||||
MOZ_LOG(sCSMLog, LogLevel::Debug,
|
||||
(" %s: %s\n", NS_ConvertUTF16toUTF8(aPrincipalName).get(),
|
||||
principalSpec.get()));
|
||||
|
@ -1374,18 +1374,15 @@ void gfxUserFontSet::UserFontCache::Entry::ReportMemory(
|
||||
path.AppendPrintf(", url=%s", spec.get());
|
||||
}
|
||||
if (mPrincipal) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
mPrincipal->get()->GetURI(getter_AddRefs(uri));
|
||||
if (uri) {
|
||||
nsCString spec = uri->GetSpecOrDefault();
|
||||
if (!spec.IsEmpty()) {
|
||||
// Include a clue as to who loaded this resource. (Note
|
||||
// that because of font entry sharing, other pages may now
|
||||
// be using this resource, and the original page may not
|
||||
// even be loaded any longer.)
|
||||
spec.ReplaceChar('/', '\\');
|
||||
path.AppendPrintf(", principal=%s", spec.get());
|
||||
}
|
||||
nsAutoCString spec;
|
||||
mPrincipal->get()->GetAsciiSpec(spec);
|
||||
if (!spec.IsEmpty()) {
|
||||
// Include a clue as to who loaded this resource. (Note
|
||||
// that because of font entry sharing, other pages may now
|
||||
// be using this resource, and the original page may not
|
||||
// even be loaded any longer.)
|
||||
spec.ReplaceChar('/', '\\');
|
||||
path.AppendPrintf(", principal=%s", spec.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user