forked from mirrors/gecko-dev
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55444
--HG--
extra : moz-landing-system : lando
102 lines
3.6 KiB
C++
102 lines
3.6 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
#include "nsWebBrowserContentPolicy.h"
|
|
#include "nsIDocShell.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsContentPolicyUtils.h"
|
|
#include "nsNetUtil.h"
|
|
|
|
nsWebBrowserContentPolicy::nsWebBrowserContentPolicy() {}
|
|
|
|
nsWebBrowserContentPolicy::~nsWebBrowserContentPolicy() {}
|
|
|
|
NS_IMPL_ISUPPORTS(nsWebBrowserContentPolicy, nsIContentPolicy)
|
|
|
|
NS_IMETHODIMP
|
|
nsWebBrowserContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
|
nsILoadInfo* aLoadInfo,
|
|
const nsACString& aMimeGuess,
|
|
int16_t* aShouldLoad) {
|
|
MOZ_ASSERT(aShouldLoad, "Null out param");
|
|
|
|
uint32_t contentType = aLoadInfo->GetExternalContentPolicyType();
|
|
MOZ_ASSERT(contentType == nsContentUtils::InternalContentPolicyTypeToExternal(
|
|
contentType),
|
|
"We should only see external content policy types here.");
|
|
|
|
*aShouldLoad = nsIContentPolicy::ACCEPT;
|
|
|
|
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;
|
|
}
|
|
|
|
nsresult rv;
|
|
bool allowed = true;
|
|
|
|
switch (contentType) {
|
|
case nsIContentPolicy::TYPE_SCRIPT:
|
|
rv = shell->GetAllowJavascript(&allowed);
|
|
break;
|
|
case nsIContentPolicy::TYPE_SUBDOCUMENT:
|
|
rv = shell->GetAllowSubframes(&allowed);
|
|
break;
|
|
#if 0
|
|
/* XXXtw: commented out in old code; add during conpol phase 2 */
|
|
case nsIContentPolicy::TYPE_REFRESH:
|
|
rv = shell->GetAllowMetaRedirects(&allowed); /* meta _refresh_ */
|
|
break;
|
|
#endif
|
|
case nsIContentPolicy::TYPE_IMAGE:
|
|
case nsIContentPolicy::TYPE_IMAGESET:
|
|
rv = shell->GetAllowImages(&allowed);
|
|
break;
|
|
default:
|
|
return NS_OK;
|
|
}
|
|
|
|
if (NS_SUCCEEDED(rv) && !allowed) {
|
|
NS_SetRequestBlockingReason(
|
|
aLoadInfo, nsILoadInfo::BLOCKING_REASON_CONTENT_POLICY_WEB_BROWSER);
|
|
*aShouldLoad = nsIContentPolicy::REJECT_TYPE;
|
|
}
|
|
return rv;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsWebBrowserContentPolicy::ShouldProcess(nsIURI* aContentLocation,
|
|
nsILoadInfo* aLoadInfo,
|
|
const nsACString& aMimeGuess,
|
|
int16_t* aShouldProcess) {
|
|
MOZ_ASSERT(aShouldProcess, "Null out param");
|
|
|
|
uint32_t contentType = aLoadInfo->GetExternalContentPolicyType();
|
|
MOZ_ASSERT(contentType == nsContentUtils::InternalContentPolicyTypeToExternal(
|
|
contentType),
|
|
"We should only see external content policy types here.");
|
|
|
|
*aShouldProcess = nsIContentPolicy::ACCEPT;
|
|
|
|
// Object tags will always open channels with TYPE_OBJECT, but may end up
|
|
// loading with TYPE_IMAGE or TYPE_DOCUMENT as their final type, so we block
|
|
// actual-plugins at the process stage
|
|
if (contentType != nsIContentPolicy::TYPE_OBJECT) {
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsISupports> context = aLoadInfo->GetLoadingContext();
|
|
nsIDocShell* shell = NS_CP_GetDocShellFromContext(context);
|
|
if (shell && (!shell->PluginsAllowedInCurrentDoc())) {
|
|
NS_SetRequestBlockingReason(
|
|
aLoadInfo, nsILoadInfo::BLOCKING_REASON_CONTENT_POLICY_WEB_BROWSER);
|
|
*aShouldProcess = nsIContentPolicy::REJECT_TYPE;
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|