1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
// 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PREFERENCES_PREFERENCE_OBJECT_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PREFERENCES_PREFERENCE_OBJECT_H_
#include "third_party/blink/public/mojom/css/preferred_color_scheme.mojom-blink-forward.h"
#include "third_party/blink/public/mojom/css/preferred_contrast.mojom-blink-forward.h"
#include "third_party/blink/renderer/bindings/core/v8/idl_types.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/core/dom/events/event_target.h"
#include "third_party/blink/renderer/core/execution_context/execution_context_lifecycle_observer.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
namespace blink {
class Document;
class ExecutionContext;
template <typename IDLType>
class FrozenArray;
class MediaValues;
// Spec: https://wicg.github.io/web-preferences-api/#preferenceobject-interface
class CORE_EXPORT PreferenceObject final
: public EventTarget,
public ExecutionContextLifecycleObserver {
DEFINE_WRAPPERTYPEINFO();
public:
PreferenceObject(ExecutionContext*, AtomicString name);
~PreferenceObject() override;
AtomicString override(ScriptState*);
AtomicString value(ScriptState*);
void clearOverride(ScriptState*);
ScriptPromise<IDLUndefined> requestOverride(ScriptState*,
std::optional<AtomicString>);
const FrozenArray<IDLString>& validValues();
void PreferenceMaybeChanged();
DEFINE_ATTRIBUTE_EVENT_LISTENER(change, kChange)
void Trace(Visitor* visitor) const override;
// From ExecutionContextLifecycleObserver
void ContextDestroyed() override;
const AtomicString& InterfaceName() const override;
ExecutionContext* GetExecutionContext() const override;
private:
AtomicString name_;
Member<FrozenArray<IDLString>> valid_values_;
Member<const MediaValues> media_values_;
mojom::blink::PreferredColorScheme preferred_color_scheme_;
mojom::blink::PreferredContrast preferred_contrast_;
bool prefers_reduced_data_;
bool prefers_reduced_motion_;
bool prefers_reduced_transparency_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_PREFERENCES_PREFERENCE_OBJECT_H_
|