#include "services/network/orb/orb_impl.h"
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/metrics/histogram_functions.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "net/base/mime_sniffer.h"
#include "net/http/http_util.h"
#include "net/url_request/url_request.h"
#include "services/network/orb/orb_mimetypes.h"
#include "services/network/orb/orb_sniffers.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
Decision;
namespace network::orb {
namespace {
bool IsNonSniffableImageMimeType(std::string_view mime_type) { … }
bool IsAudioOrVideoMimeType(std::string_view mime_type) { … }
bool IsTextCssMimeType(std::string_view mime_type) { … }
bool IsOpaqueSafelistedMimeType(std::string_view mime_type) { … }
bool IsOpaqueSafelistedMimeTypeThatWeSniffAnyway(std::string_view mime_type) { … }
bool IsOkayHttpStatus(const mojom::URLResponseHead& response) { … }
bool IsHttpStatus(const mojom::URLResponseHead& response,
int expected_status_code) { … }
bool IsRangeResponseWithMiddleOfResource(
const mojom::URLResponseHead& response) { … }
bool IsOpaqueResponse(const std::optional<url::Origin>& request_initiator,
mojom::RequestMode request_mode,
const mojom::URLResponseHead& response) { … }
bool HasNoSniff(
const mojom::URLResponseHead& response) { … }
}
OpaqueResponseBlockingAnalyzer::OpaqueResponseBlockingAnalyzer(
PerFactoryState* state)
: … { … }
OpaqueResponseBlockingAnalyzer::~OpaqueResponseBlockingAnalyzer() { … }
Decision OpaqueResponseBlockingAnalyzer::Init(
const GURL& request_url,
const std::optional<url::Origin>& request_initiator,
mojom::RequestMode request_mode,
mojom::RequestDestination request_destination_from_renderer,
const network::mojom::URLResponseHead& response) { … }
Decision OpaqueResponseBlockingAnalyzer::Sniff(std::string_view data) { … }
Decision OpaqueResponseBlockingAnalyzer::HandleEndOfSniffableResponseBody() { … }
bool OpaqueResponseBlockingAnalyzer::ShouldReportBlockedResponse() const { … }
ResponseAnalyzer::BlockedResponseHandling
OpaqueResponseBlockingAnalyzer::ShouldHandleBlockedResponseAs() const { … }
void OpaqueResponseBlockingAnalyzer::StoreAllowedAudioVideoRequest(
const GURL& media_url) { … }
bool OpaqueResponseBlockingAnalyzer::IsAllowedAudioVideoRequest(
const GURL& media_url) { … }
}