chromium/third_party/blink/common/permissions_policy/permissions_policy.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {}

// static
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFromParentPolicy(
    const PermissionsPolicy* parent_policy,
    const ParsedPermissionsPolicy& header_policy,
    const ParsedPermissionsPolicy& container_policy,
    const url::Origin& origin) {}

// static
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CopyStateFrom(
    const PermissionsPolicy* source) {}

// static
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFromParsedPolicy(
    const ParsedPermissionsPolicy& parsed_policy,
    const std::optional<ParsedPermissionsPolicy>& base_policy,
    const url::Origin& origin) {}

// static
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 {}

// Implements Permissions Policy 9.8: Get feature value for origin.
// Version https://www.w3.org/TR/2023/WD-permissions-policy-1-20231218/
bool PermissionsPolicy::GetFeatureValueForOrigin(
    mojom::PermissionsPolicyFeature feature,
    const url::Origin& origin) const {}

const PermissionsPolicy::Allowlist PermissionsPolicy::GetAllowlistForDevTools(
    mojom::PermissionsPolicyFeature feature) const {}

// TODO(crbug.com/937131): Use |PermissionsPolicy::GetAllowlistForDevTools|
// to replace this method. This method uses legacy |default_allowlist|
// calculation method.
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 {}

// static
PermissionsPolicy::AllowlistsAndReportingEndpoints
PermissionsPolicy::CreateAllowlistsAndReportingEndpoints(
    const ParsedPermissionsPolicy& parsed_header) {}

// static
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;

// static
std::unique_ptr<PermissionsPolicy>
PermissionsPolicy::CreateFlexibleForFencedFrame(
    const PermissionsPolicy* parent_policy,
    const ParsedPermissionsPolicy& header_policy,
    const ParsedPermissionsPolicy& container_policy,
    const url::Origin& subframe_origin) {}

// static
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) {}

// static
std::unique_ptr<PermissionsPolicy> PermissionsPolicy::CreateFixedForFencedFrame(
    const url::Origin& origin,
    const ParsedPermissionsPolicy& header_policy,
    base::span<const blink::mojom::PermissionsPolicyFeature>
        effective_enabled_permissions) {}

// static
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) {}

// static
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) {}

// Implements Permissions Policy 9.9: Is feature enabled in document for origin?
// Version https://www.w3.org/TR/2023/WD-permissions-policy-1-20230717/
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 {}

// Implements Permissions Policy 9.7: Define an inherited policy for
// feature in container at origin.
// Version https://www.w3.org/TR/2023/WD-permissions-policy-1-20230717/
// static
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 {}

}  // namespace blink