#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 = …;
constexpr int kMinMargin = …;
constexpr float kIntersectionThreshold = …;
PermissionDescriptorPtr CreatePermissionDescriptor(PermissionName name) { … }
Vector<PermissionDescriptorPtr> ParsePermissionDescriptorsFromString(
const AtomicString& type) { … }
int GetMessageIDSinglePermission(PermissionName name, bool granted) { … }
int GetMessageIDMultiplePermissions(bool granted) { … }
mojom::blink::PermissionsPolicyFeature PermissionNameToPermissionsPolicyFeature(
PermissionName permission_name) { … }
String PermissionNameToString(PermissionName permission_name) { … }
float ContrastBetweenColorAndBackgroundColor(const ComputedStyle* style) { … }
bool AreColorsNonOpaque(const ComputedStyle* style) { … }
scoped_refptr<const CalculationExpressionNode> BuildFitContentExpr(
float factor) { … }
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) { … }
}
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 { … }
Vector<PermissionDescriptorPtr>
HTMLPermissionElement::ParsePermissionDescriptorsForTesting(
const AtomicString& type) { … }
String HTMLPermissionElement::DisableReasonToString(DisableReason reason) { … }
HTMLPermissionElement::UserInteractionDeniedReason
HTMLPermissionElement::DisableReasonToUserInteractionDeniedReason(
DisableReason reason) { … }
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 { … }
}