#include "third_party/blink/public/common/permissions_policy/permissions_policy.h"
#include "base/containers/contains.h"
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h"
#include "third_party/blink/public/common/client_hints/client_hints.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/fenced_frame_permissions_policies.h"
#include "third_party/blink/public/common/permissions_policy/permissions_policy_features.h"
#include "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom.h"
namespace blink {
PermissionsPolicy::Allowlist::Allowlist() = default;
PermissionsPolicy::Allowlist::Allowlist(const Allowlist& rhs) = default;
PermissionsPolicy::Allowlist::~Allowlist() = default;
PermissionsPolicy::Allowlist PermissionsPolicy::Allowlist::FromDeclaration(
const ParsedPermissionsPolicyDeclaration& parsed_declaration) { … }
void PermissionsPolicy::Allowlist::Add(
const blink::OriginWithPossibleWildcards& origin) { … }
void PermissionsPolicy::Allowlist::AddSelf(std::optional<url::Origin> self) { … }
void PermissionsPolicy::Allowlist::AddAll() { … }
void PermissionsPolicy::Allowlist::AddOpaqueSrc() { … }
bool PermissionsPolicy::Allowlist::Contains(const url::Origin& origin) const { … }
const std::optional<url::Origin>& PermissionsPolicy::Allowlist::SelfIfMatches()
const { … }
bool PermissionsPolicy::Allowlist::MatchesAll() const { … }
void PermissionsPolicy::Allowlist::RemoveMatchesAll() { … }
bool PermissionsPolicy::Allowlist::MatchesOpaqueSrc() const { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFromParentPolicy(
const PermissionsPolicy* parent_policy,
const ParsedPermissionsPolicy& header_policy,
const ParsedPermissionsPolicy& container_policy,
const url::Origin& origin) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CopyStateFrom(
const PermissionsPolicy* source) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFromParsedPolicy(
const ParsedPermissionsPolicy& parsed_policy,
const std::optional<ParsedPermissionsPolicy>& base_policy,
const url::Origin& origin) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFromParsedPolicy(
const ParsedPermissionsPolicy& parsed_policy,
const std::optional<ParsedPermissionsPolicy>&
parsed_policy_for_isolated_app,
const url::Origin& origin,
const PermissionsPolicyFeatureList& features) { … }
bool PermissionsPolicy::IsFeatureEnabledByInheritedPolicy(
mojom::PermissionsPolicyFeature feature) const { … }
bool PermissionsPolicy::IsFeatureEnabled(
mojom::PermissionsPolicyFeature feature) const { … }
bool PermissionsPolicy::IsFeatureEnabledForOrigin(
mojom::PermissionsPolicyFeature feature,
const url::Origin& origin) const { … }
bool PermissionsPolicy::IsFeatureEnabledForSubresourceRequest(
mojom::PermissionsPolicyFeature feature,
const url::Origin& origin,
const network::ResourceRequest& request) const { … }
bool PermissionsPolicy::GetFeatureValueForOrigin(
mojom::PermissionsPolicyFeature feature,
const url::Origin& origin) const { … }
const PermissionsPolicy::Allowlist PermissionsPolicy::GetAllowlistForDevTools(
mojom::PermissionsPolicyFeature feature) const { … }
const PermissionsPolicy::Allowlist PermissionsPolicy::GetAllowlistForFeature(
mojom::PermissionsPolicyFeature feature) const { … }
std::optional<const PermissionsPolicy::Allowlist>
PermissionsPolicy::GetAllowlistForFeatureIfExists(
mojom::PermissionsPolicyFeature feature) const { … }
std::optional<std::string> PermissionsPolicy::GetEndpointForFeature(
mojom::PermissionsPolicyFeature feature) const { … }
PermissionsPolicy::AllowlistsAndReportingEndpoints
PermissionsPolicy::CreateAllowlistsAndReportingEndpoints(
const ParsedPermissionsPolicy& parsed_header) { … }
PermissionsPolicy::AllowlistsAndReportingEndpoints
PermissionsPolicy::CombinePolicies(
const ParsedPermissionsPolicy& base_policy,
const ParsedPermissionsPolicy& second_policy) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::WithClientHints(
const ParsedPermissionsPolicy& parsed_header) const { … }
const mojom::PermissionsPolicyFeature
PermissionsPolicy::defined_opt_in_features_[] = …;
PermissionsPolicy::PermissionsPolicy(
url::Origin origin,
AllowlistsAndReportingEndpoints allow_lists_and_reporting_endpoints,
PermissionsPolicyFeatureState inherited_policies,
const PermissionsPolicyFeatureList& feature_list)
: … { … }
PermissionsPolicy::~PermissionsPolicy() = default;
std::unique_ptr<PermissionsPolicy>
PermissionsPolicy::CreateFlexibleForFencedFrame(
const PermissionsPolicy* parent_policy,
const ParsedPermissionsPolicy& header_policy,
const ParsedPermissionsPolicy& container_policy,
const url::Origin& subframe_origin) { … }
std::unique_ptr<PermissionsPolicy>
PermissionsPolicy::CreateFlexibleForFencedFrame(
const PermissionsPolicy* parent_policy,
const ParsedPermissionsPolicy& header_policy,
const ParsedPermissionsPolicy& container_policy,
const url::Origin& subframe_origin,
const PermissionsPolicyFeatureList& features) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFixedForFencedFrame(
const url::Origin& origin,
const ParsedPermissionsPolicy& header_policy,
base::span<const blink::mojom::PermissionsPolicyFeature>
effective_enabled_permissions) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFixedForFencedFrame(
const url::Origin& origin,
const ParsedPermissionsPolicy& header_policy,
const PermissionsPolicyFeatureList& features,
base::span<const blink::mojom::PermissionsPolicyFeature>
effective_enabled_permissions) { … }
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFromParentPolicy(
const PermissionsPolicy* parent_policy,
const ParsedPermissionsPolicy& header_policy,
const ParsedPermissionsPolicy& container_policy,
const url::Origin& origin,
const PermissionsPolicyFeatureList& features) { … }
bool PermissionsPolicy::IsFeatureEnabledForOriginImpl(
mojom::PermissionsPolicyFeature feature,
const url::Origin& origin,
const std::set<mojom::PermissionsPolicyFeature>& opt_in_features) const { … }
bool PermissionsPolicy::IsFeatureEnabledForSubresourceRequestAssumingOptIn(
mojom::PermissionsPolicyFeature feature,
const url::Origin& origin) const { … }
bool PermissionsPolicy::InheritedValueForFeature(
const url::Origin& origin,
const PermissionsPolicy* parent_policy,
std::pair<mojom::PermissionsPolicyFeature, PermissionsPolicyFeatureDefault>
feature,
const ParsedPermissionsPolicy& container_policy) { … }
const PermissionsPolicyFeatureList& PermissionsPolicy::GetFeatureList() const { … }
}