Bug 1446937 - Have ContextForTopLevelLoad return already_AddRefed<nsISupports> within LoadInfo, r=qdot

This commit is contained in:
Andrea Marchesini 2018-05-30 21:21:18 +02:00
Родитель 1273dc5391
Коммит 9023e7c7b4
5 изменённых файлов: 11 добавлений и 9 удалений

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

@ -94,7 +94,8 @@ nsContentSecurityManager::AllowTopLevelNavigationToDataURI(nsIChannel* aChannel)
dataSpec.Truncate(50);
dataSpec.AppendLiteral("...");
}
nsCOMPtr<nsITabChild> tabChild = do_QueryInterface(loadInfo->ContextForTopLevelLoad());
nsCOMPtr<nsISupports> context = loadInfo->ContextForTopLevelLoad();
nsCOMPtr<nsITabChild> tabChild = do_QueryInterface(context);
nsCOMPtr<nsIDocument> doc;
if (tabChild) {
doc = static_cast<mozilla::dom::TabChild*>(tabChild.get())->GetDocument();

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

@ -642,7 +642,7 @@ LoadInfo::LoadingNode()
return node;
}
nsISupports*
already_AddRefed<nsISupports>
LoadInfo::ContextForTopLevelLoad()
{
// Most likely you want to query LoadingNode() instead of
@ -650,7 +650,7 @@ LoadInfo::ContextForTopLevelLoad()
MOZ_ASSERT(mInternalContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT,
"should only query this context for top level document loads");
nsCOMPtr<nsISupports> context = do_QueryReferent(mContextForTopLevelLoad);
return context;
return context.forget();
}
already_AddRefed<nsISupports>

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

@ -369,7 +369,7 @@ interface nsILoadInfo : nsISupports
* ContextForTopLevelLoad will always return null.
*/
[noscript, notxpcom, nostdcall, binaryname(ContextForTopLevelLoad)]
nsISupports binaryContextForTopLevelLoad();
LoadContextRef binaryContextForTopLevelLoad();
/**
* For all loads except loads of TYPE_DOCUMENT, the loadingContext

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

@ -34,8 +34,8 @@ nsWebBrowserContentPolicy::ShouldLoad(nsIURI* aContentLocation,
*aShouldLoad = nsIContentPolicy::ACCEPT;
nsIDocShell* shell =
NS_CP_GetDocShellFromContext(aLoadInfo->GetLoadingContext());
nsCOMPtr<nsISupports> context = aLoadInfo->GetLoadingContext();
nsIDocShell* shell = NS_CP_GetDocShellFromContext(context);
/* We're going to dereference shell, so make sure it isn't null */
if (!shell) {
return NS_OK;
@ -92,8 +92,8 @@ nsWebBrowserContentPolicy::ShouldProcess(nsIURI* aContentLocation,
return NS_OK;
}
nsIDocShell* shell =
NS_CP_GetDocShellFromContext(aLoadInfo->GetLoadingContext());
nsCOMPtr<nsISupports> context = aLoadInfo->GetLoadingContext();
nsIDocShell* shell = NS_CP_GetDocShellFromContext(context);
if (shell && (!shell->PluginsAllowedInCurrentDoc())) {
*aShouldProcess = nsIContentPolicy::REJECT_TYPE;
}

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

@ -132,8 +132,9 @@ AddonContentPolicy::ShouldLoad(nsIURI* aContentLocation,
NS_SUCCEEDED(mimeParser.GetParameter("version", version))) {
*aShouldLoad = nsIContentPolicy::REJECT_REQUEST;
nsCOMPtr<nsISupports> context = aLoadInfo->GetLoadingContext();
LogMessage(NS_LITERAL_STRING(VERSIONED_JS_BLOCKED_MESSAGE),
requestOrigin, typeString, aLoadInfo->GetLoadingContext());
requestOrigin, typeString, context);
return NS_OK;
}
}