mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
ace6d1063f
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/D55442 --HG-- extra : moz-landing-system : lando
73 lines
2.9 KiB
C++
73 lines
2.9 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/. */
|
|
|
|
/*
|
|
* Content policy implementation that prevents all loads of images,
|
|
* subframes, etc from protocols that don't return data but rather open
|
|
* applications (such as mailto).
|
|
*/
|
|
|
|
#include "nsNoDataProtocolContentPolicy.h"
|
|
#include "nsString.h"
|
|
#include "nsIProtocolHandler.h"
|
|
#include "nsIURI.h"
|
|
#include "nsNetUtil.h"
|
|
#include "nsContentUtils.h"
|
|
|
|
NS_IMPL_ISUPPORTS(nsNoDataProtocolContentPolicy, nsIContentPolicy)
|
|
|
|
NS_IMETHODIMP
|
|
nsNoDataProtocolContentPolicy::ShouldLoad(nsIURI* aContentLocation,
|
|
nsILoadInfo* aLoadInfo,
|
|
const nsACString& aMimeGuess,
|
|
int16_t* aDecision) {
|
|
uint32_t contentType = aLoadInfo->GetExternalContentPolicyType();
|
|
|
|
MOZ_ASSERT(contentType == nsContentUtils::InternalContentPolicyTypeToExternal(
|
|
contentType),
|
|
"We should only see external content policy types here.");
|
|
|
|
*aDecision = nsIContentPolicy::ACCEPT;
|
|
|
|
// Don't block for TYPE_OBJECT since such URIs are sometimes loaded by the
|
|
// plugin, so they don't necessarily open external apps
|
|
// TYPE_WEBSOCKET loads can only go to ws:// or wss://, so we don't need to
|
|
// concern ourselves with them.
|
|
if (contentType != TYPE_DOCUMENT && contentType != TYPE_SUBDOCUMENT &&
|
|
contentType != TYPE_OBJECT && contentType != TYPE_WEBSOCKET) {
|
|
// The following are just quick-escapes for the most common cases
|
|
// where we would allow the content to be loaded anyway.
|
|
nsAutoCString scheme;
|
|
aContentLocation->GetScheme(scheme);
|
|
if (scheme.EqualsLiteral("http") || scheme.EqualsLiteral("https") ||
|
|
scheme.EqualsLiteral("ftp") || scheme.EqualsLiteral("file") ||
|
|
scheme.EqualsLiteral("chrome")) {
|
|
return NS_OK;
|
|
}
|
|
|
|
bool shouldBlock;
|
|
nsresult rv = NS_URIChainHasFlags(
|
|
aContentLocation, nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
|
|
&shouldBlock);
|
|
if (NS_SUCCEEDED(rv) && shouldBlock) {
|
|
NS_SetRequestBlockingReason(
|
|
aLoadInfo,
|
|
nsILoadInfo::BLOCKING_REASON_CONTENT_POLICY_NO_DATA_PROTOCOL);
|
|
*aDecision = nsIContentPolicy::REJECT_REQUEST;
|
|
}
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsNoDataProtocolContentPolicy::ShouldProcess(nsIURI* aContentLocation,
|
|
nsILoadInfo* aLoadInfo,
|
|
const nsACString& aMimeGuess,
|
|
int16_t* aDecision) {
|
|
return ShouldLoad(aContentLocation, aLoadInfo, aMimeGuess, aDecision);
|
|
}
|