chromium/third_party/blink/renderer/core/html/html_permission_element.cc

// Copyright 2023 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/renderer/core/html/html_permission_element.h"

#include <optional>

#include "base/functional/bind.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "third_party/blink/public/common/input/web_pointer_properties.h"
#include "third_party/blink/public/mojom/permissions/permission.mojom-blink.h"
#include "third_party/blink/public/strings/grit/blink_strings.h"
#include "third_party/blink/renderer/core/css/css_selector.h"
#include "third_party/blink/renderer/core/css/font_size_functions.h"
#include "third_party/blink/renderer/core/css/properties/css_property_instances.h"
#include "third_party/blink/renderer/core/css/properties/longhand.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/dom/focus_params.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/space_split_string.h"
#include "third_party/blink/renderer/core/events/mouse_event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/csp/content_security_policy.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_ukm_aggregator.h"
#include "third_party/blink/renderer/core/frame/visual_viewport.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/html_div_element.h"
#include "third_party/blink/renderer/core/html/html_span_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/intersection_observer/intersection_observer_entry.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/style/computed_style_base_constants.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/fonts/font_selection_types.h"
#include "third_party/blink/renderer/platform/geometry/calculation_expression_node.h"
#include "third_party/blink/renderer/platform/geometry/calculation_value.h"
#include "third_party/blink/renderer/platform/geometry/length.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/text/platform_locale.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/rect_conversions.h"

namespace blink {

EmbeddedPermissionControlResult;
EmbeddedPermissionRequestDescriptor;
PermissionDescriptor;
PermissionDescriptorPtr;
PermissionName;
PermissionObserver;
PermissionService;
MojoPermissionStatus;

namespace {

const base::TimeDelta kDefaultDisableTimeout =;
constexpr FontSelectionValue kMinimumFontWeight =;
constexpr float kMaximumWordSpacingToFontSizeRatio =;
constexpr float kMinimumAllowedContrast =;
constexpr float kMaximumLetterSpacingToFontSizeRatio =;
constexpr float kMinimumLetterSpacingToFontSizeRatio =;
constexpr int kMaxLengthToFontSizeRatio =;
constexpr int kMinLengthToFontSizeRatio =;
constexpr int kMaxVerticalPaddingToFontSizeRatio =;
constexpr int kMaxHorizontalPaddingToFontSizeRatio =;
// Needed to avoid IntersectionObserver false-positives caused by other elements
// being too close.
constexpr int kMinMargin =;
constexpr float kIntersectionThreshold =;

PermissionDescriptorPtr CreatePermissionDescriptor(PermissionName name) {}

// To support group permissions, the `type` attribute of permission element
// would contain a list of permissions (type is a space-separated string, for
// example <permission type=”camera microphone”>).
// This helper converts the type string to a list of `PermissionDescriptor`. If
// any of the splitted strings is invalid or not supported, return an empty
// list.
Vector<PermissionDescriptorPtr> ParsePermissionDescriptorsFromString(
    const AtomicString& type) {}

// Helper to get permission text resource ID for the given map which has only
// one element.
int GetMessageIDSinglePermission(PermissionName name, bool granted) {}

// Helper to get permission text resource ID for the given map which has
// multiple elements. Currently we only support "camera microphone" grouped
// permissions.
int GetMessageIDMultiplePermissions(bool granted) {}

// Helper to get `PermissionsPolicyFeature` from permission name
mojom::blink::PermissionsPolicyFeature PermissionNameToPermissionsPolicyFeature(
    PermissionName permission_name) {}

// Helper to translate permission names into strings, primarily used for logging
// console messages.
String PermissionNameToString(PermissionName permission_name) {}

float ContrastBetweenColorAndBackgroundColor(const ComputedStyle* style) {}

// Returns true if the 'color' or 'background-color' properties have the
// alphas set to anything else except fully opaque.
bool AreColorsNonOpaque(const ComputedStyle* style) {}

// Build an expression that is equivalent to `size * |factor|)`. To be used
// inside a `calc-size` expression.
scoped_refptr<const CalculationExpressionNode> BuildFitContentExpr(
    float factor) {}

// Builds an expression that takes a |length| and bounds it lower, higher, or on
// both sides with the provided expressions.
scoped_refptr<const CalculationExpressionNode> BuildLengthBoundExpr(
    const Length& length,
    std::optional<scoped_refptr<const CalculationExpressionNode>>
        lower_bound_expr,
    std::optional<scoped_refptr<const CalculationExpressionNode>>
        upper_bound_expr) {}

}  // namespace

HTMLPermissionElement::HTMLPermissionElement(Document& document)
    :{}

HTMLPermissionElement::~HTMLPermissionElement() = default;

const AtomicString& HTMLPermissionElement::GetType() const {}

String HTMLPermissionElement::invalidReason() const {}

bool HTMLPermissionElement::isValid() const {}

void HTMLPermissionElement::Trace(Visitor* visitor) const {}

void HTMLPermissionElement::AttachLayoutTree(AttachContext& context) {}

void HTMLPermissionElement::DetachLayoutTree(bool performing_reattach) {}

void HTMLPermissionElement::Focus(const FocusParams& params) {}

FocusableState HTMLPermissionElement::SupportsFocus(UpdateBehavior) const {}

int HTMLPermissionElement::DefaultTabIndex() const {}

CascadeFilter HTMLPermissionElement::GetCascadeFilter() const {}

bool HTMLPermissionElement::CanGeneratePseudoElement(PseudoId id) const {}

// static
Vector<PermissionDescriptorPtr>
HTMLPermissionElement::ParsePermissionDescriptorsForTesting(
    const AtomicString& type) {}

// static
String HTMLPermissionElement::DisableReasonToString(DisableReason reason) {}

// static
HTMLPermissionElement::UserInteractionDeniedReason
HTMLPermissionElement::DisableReasonToUserInteractionDeniedReason(
    DisableReason reason) {}

// static
AtomicString HTMLPermissionElement::DisableReasonToInvalidReasonString(
    DisableReason reason) {}

PermissionService* HTMLPermissionElement::GetPermissionService() {}

void HTMLPermissionElement::OnPermissionServiceConnectionFailed() {}

void HTMLPermissionElement::AttributeChanged(
    const AttributeModificationParams& params) {}

void HTMLPermissionElement::DidAddUserAgentShadowRoot(ShadowRoot& root) {}

void HTMLPermissionElement::AdjustStyle(ComputedStyleBuilder& builder) {}

void HTMLPermissionElement::DidRecalcStyle(const StyleRecalcChange change) {}

void HTMLPermissionElement::DefaultEventHandler(Event& event) {}

void HTMLPermissionElement::RequestPageEmbededPermissions() {}

void HTMLPermissionElement::RegisterPermissionObserver(
    const PermissionDescriptorPtr& descriptor,
    MojoPermissionStatus current_status) {}

void HTMLPermissionElement::OnPermissionStatusChange(
    MojoPermissionStatus status) {}

void HTMLPermissionElement::OnEmbeddedPermissionControlRegistered(
    bool allowed,
    const std::optional<Vector<MojoPermissionStatus>>& statuses) {}

void HTMLPermissionElement::OnEmbeddedPermissionsDecided(
    EmbeddedPermissionControlResult result) {}

void HTMLPermissionElement::DisableReasonExpireTimerFired(TimerBase* timer) {}

void HTMLPermissionElement::MaybeDispatchValidationChangeEvent() {}

scoped_refptr<base::SingleThreadTaskRunner>
HTMLPermissionElement::GetTaskRunner() {}

bool HTMLPermissionElement::IsClickingEnabled() {}

void HTMLPermissionElement::DisableClickingIndefinitely(DisableReason reason) {}

void HTMLPermissionElement::DisableClickingTemporarily(
    DisableReason reason,
    const base::TimeDelta& duration) {}

void HTMLPermissionElement::EnableClicking(DisableReason reason) {}

void HTMLPermissionElement::EnableClickingAfterDelay(
    DisableReason reason,
    const base::TimeDelta& delay) {}

HTMLPermissionElement::ClickingEnabledState
HTMLPermissionElement::GetClickingEnabledState() const {}

void HTMLPermissionElement::RefreshDisableReasonsAndUpdateTimer() {}

void HTMLPermissionElement::UpdateAppearance() {}

void HTMLPermissionElement::UpdateText() {}

void HTMLPermissionElement::AddConsoleError(String error) {}

void HTMLPermissionElement::AddConsoleWarning(String warning) {}

void HTMLPermissionElement::OnIntersectionChanged(
    const HeapVector<Member<IntersectionObserverEntry>>& entries) {}

bool HTMLPermissionElement::IsStyleValid() {}

Length HTMLPermissionElement::AdjustedBoundedLength(
    const Length& length,
    std::optional<float> lower_bound,
    std::optional<float> upper_bound,
    bool should_multiply_by_content_size) {}

void HTMLPermissionElement::DidFinishLifecycleUpdate(
    const LocalFrameView& local_frame_view) {}

gfx::Rect HTMLPermissionElement::ComputeIntersectionRectWithViewport(
    const Page* page) {}

std::optional<base::TimeDelta>
HTMLPermissionElement::GetRecentlyAttachedTimeoutRemaining() const {}

}  // namespace blink