chromium/ui/base/interaction/interaction_sequence.cc

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

#include "base/containers/map_util.h"
#include "base/notreached.h"
#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include <list>
#include <memory>
#include <optional>
#include <string_view>
#include <utility>
#include <variant>
#include <vector>

#include "base/callback_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/weak_auto_reset.h"
#include "base/memory/weak_ptr.h"
#include "base/not_fatal_until.h"
#include "base/observer_list_internal.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/interaction_sequence.h"

namespace ui {

namespace {

// Runs |callback| if it is valid.
// We have a lot of callbacks that can be null, so calling through this method
// prevents accidentally trying to run a null callback.
template <typename Signature, typename... Args>
void RunIfValid(base::OnceCallback<Signature> callback, Args... args) {}

// Insert an unused argument `Arg` in the front of the argument list for
// `callback`, and return the new callback with the dummy argument.
template <typename Arg, typename Ret, typename... Args>
base::OnceCallback<Ret(Arg, Args...)> PushUnusedArg(
    base::OnceCallback<Ret(Args...)> callback) {}

// Insert two unused arguments `Arg1` and `Arg2` in the front of the argument
// list for `callback`, and return the new callback with the dummy arguments.
template <typename Arg1, typename Arg2, typename Ret, typename... Args>
base::OnceCallback<Ret(Arg1, Arg2, Args...)> PushUnusedArgs2(
    base::OnceCallback<Ret(Args...)> callback) {}

// Sets step->must_remain_visible if it does not have a value.
void SetDefaultMustRemainVisibleValue(InteractionSequence::Step* step,
                                      const InteractionSequence::Step* next) {}

// Some step types allow the target element to become hidden between being
// triggered and the start callback being called, others do not.
bool AllowNullElementInStartCallback(InteractionSequence::StepType step_type) {}

}  // anonymous namespace

InteractionSequence::AbortedData::AbortedData() = default;
InteractionSequence::AbortedData::~AbortedData() = default;
InteractionSequence::AbortedData::AbortedData(const AbortedData&) = default;
InteractionSequence::AbortedData& InteractionSequence::AbortedData::operator=(
    const AbortedData&) = default;

struct InteractionSequence::SubsequenceData {};

InteractionSequence::Step::Step() = default;
InteractionSequence::Step::~Step() = default;

struct InteractionSequence::Configuration {};

InteractionSequence::Builder::Builder()
    :{}
InteractionSequence::Builder::Builder(Builder&& other) = default;
InteractionSequence::Builder& InteractionSequence::Builder::operator=(
    Builder&& other) = default;
InteractionSequence::Builder::~Builder() = default;

InteractionSequence::Builder& InteractionSequence::Builder::SetAbortedCallback(
    AbortedCallback callback) {}

InteractionSequence::Builder&
InteractionSequence::Builder::SetCompletedCallback(CompletedCallback callback) {}

InteractionSequence::Builder& InteractionSequence::Builder::AddStep(
    std::unique_ptr<Step> step) {}

InteractionSequence::Builder& InteractionSequence::Builder::AddStep(
    StepBuilder& step_builder) {}

InteractionSequence::Builder& InteractionSequence::Builder::AddStep(
    StepBuilder&& step_builder) {}

InteractionSequence::Builder& InteractionSequence::Builder::SetContext(
    ElementContext context) {}

InteractionSequence::Builder&
InteractionSequence::Builder::SetDefaultStepStartMode(
    StepStartMode step_start_mode) {}

std::unique_ptr<InteractionSequence> InteractionSequence::Builder::Build() {}

std::unique_ptr<InteractionSequence>
InteractionSequence::Builder::BuildSubsequence(
    const Configuration* reference_config,
    const Step* reference_step) {}

InteractionSequence::StepBuilder::StepBuilder()
    :{}
InteractionSequence::StepBuilder::StepBuilder(StepBuilder&& other) = default;
InteractionSequence::StepBuilder& InteractionSequence::StepBuilder::operator=(
    StepBuilder&& other) = default;
InteractionSequence::StepBuilder::~StepBuilder() = default;

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetElementID(ElementIdentifier element_id) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetElementName(std::string_view name) {}

InteractionSequence::StepBuilder& InteractionSequence::StepBuilder::SetContext(
    StepContext context) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetMustBeVisibleAtStart(
    bool must_be_visible) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetMustRemainVisible(
    bool must_remain_visible) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetTransitionOnlyOnEvent(
    bool transition_only_on_event) {}

InteractionSequence::StepBuilder& InteractionSequence::StepBuilder::SetType(
    StepType step_type,
    CustomElementEventType event_type) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetSubsequenceMode(
    SubsequenceMode subsequence_mode) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::AddSubsequence(
    Builder subsequence,
    SubsequenceCondition condition) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetStartCallback(
    StepStartCallback start_callback) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetStartCallback(
    base::OnceCallback<void(TrackedElement*)> start_callback) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetStartCallback(
    base::OnceClosure start_callback) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetStepStartMode(
    StepStartMode step_start_mode) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetEndCallback(StepEndCallback end_callback) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetEndCallback(
    base::OnceClosure end_callback) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::SetDescription(std::string_view description) {}

InteractionSequence::StepBuilder&
InteractionSequence::StepBuilder::FormatDescription(
    std::string_view format_string) {}

std::unique_ptr<InteractionSequence::Step>
InteractionSequence::StepBuilder::Build() {}

InteractionSequence::InteractionSequence(
    std::unique_ptr<Configuration> configuration,
    const Step* reference_step)
    :{}

// static
InteractionSequence::SubsequenceCondition InteractionSequence::AlwaysRun() {}

// static
std::unique_ptr<InteractionSequence::Step>
InteractionSequence::WithInitialElement(TrackedElement* element,
                                        StepStartCallback start_callback,
                                        StepEndCallback end_callback) {}

InteractionSequence::~InteractionSequence() {}

void InteractionSequence::Start() {}

void InteractionSequence::RunSynchronouslyForTesting() {}

bool InteractionSequence::IsCurrentStepInAnyContextForTesting() const {}

void InteractionSequence::FailForTesting() {}

void InteractionSequence::NameElement(TrackedElement* element,
                                      std::string_view name) {}

TrackedElement* InteractionSequence::GetNamedElement(const std::string& name) {}

const TrackedElement* InteractionSequence::GetNamedElement(
    const std::string& name) const {}

InteractionSequence::AbortedData InteractionSequence::BuildAbortedData(
    AbortedReason reason) const {}

base::WeakPtr<InteractionSequence> InteractionSequence::AsWeakPtr() {}

void InteractionSequence::OnElementShown(TrackedElement* element) {}

void InteractionSequence::OnElementActivated(TrackedElement* element) {}

void InteractionSequence::OnCustomEvent(TrackedElement* element) {}

void InteractionSequence::OnElementHidden(TrackedElement* element) {}

void InteractionSequence::OnTriggerDuringStepTransition(
    TrackedElement* element) {}

void InteractionSequence::OnElementHiddenDuringStepTransition(
    TrackedElement* element) {}

void InteractionSequence::OnElementHiddenWaitingForEvent(
    TrackedElement* element) {}

void InteractionSequence::MaybeWatchForEarlyTrigger(const Step* current_step) {}

void InteractionSequence::StartStepTransition(TrackedElement* element) {}

void InteractionSequence::CompleteStepTransition() {}

void InteractionSequence::StageNextStep() {}

void InteractionSequence::Abort(AbortedReason reason) {}

bool InteractionSequence::MatchesNameIfSpecified(
    const TrackedElement* element,
    const std::string& name) const {}

ElementContext InteractionSequence::UpdateNextStepContext(
    const Step* current_step) {}

InteractionSequence::SubsequenceData* InteractionSequence::FindSubsequenceData(
    SubsequenceHandle subsequence) {}

void InteractionSequence::OnSubsequenceCompleted(
    SubsequenceHandle subsequence) {}

void InteractionSequence::OnSubsequenceAborted(
    SubsequenceHandle subsequence,
    const AbortedData& aborted_data) {}

void InteractionSequence::BuildSubsequences(const Step* current_step) {}

InteractionSequence::Step* InteractionSequence::next_step() {}

const InteractionSequence::Step* InteractionSequence::next_step() const {}

ElementContext InteractionSequence::context() const {}

void PrintTo(InteractionSequence::StepType step_type, std::ostream* os) {}

void PrintTo(InteractionSequence::AbortedReason reason, std::ostream* os) {}

void PrintTo(InteractionSequence::SubsequenceMode mode, std::ostream* os) {}

void PrintTo(InteractionSequence::StepStartMode mode, std::ostream* os) {}

void PrintTo(const InteractionSequence::AbortedData& data, std::ostream* os) {}

extern std::ostream& operator<<(std::ostream& os,
                                InteractionSequence::StepType step_type) {}

extern std::ostream& operator<<(std::ostream& os,
                                InteractionSequence::AbortedReason reason) {}

extern std::ostream& operator<<(std::ostream& os,
                                InteractionSequence::StepStartMode mode) {}

extern std::ostream& operator<<(std::ostream& os,
                                InteractionSequence::SubsequenceMode mode) {}

extern std::ostream& operator<<(std::ostream& os,
                                const InteractionSequence::AbortedData& data) {}

}  // namespace ui