#include "components/user_education/common/tutorial.h"
#include <optional>
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/time/time.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_education/common/help_bubble.h"
#include "components/user_education/common/help_bubble_factory.h"
#include "components/user_education/common/help_bubble_factory_registry.h"
#include "components/user_education/common/help_bubble_params.h"
#include "components/user_education/common/tutorial_description.h"
#include "components/user_education/common/tutorial_service.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/interaction_sequence.h"
#include "ui/base/l10n/l10n_util.h"
namespace user_education {
namespace {
int CountProgress(const std::vector<TutorialDescription::Step>& steps) { … }
void CommonStepBuilderSetup(ui::InteractionSequence::StepBuilder& builder,
const TutorialDescription::Step& step) { … }
void AddStepBuilderSubsequence(
ui::InteractionSequence::StepBuilder& builder,
ui::InteractionSequence::SubsequenceCondition condition,
const std::vector<TutorialDescription::Step>& steps,
int max_progress,
int& current_progress,
bool is_terminal,
bool can_be_restarted,
int complete_button_text_id,
TutorialService* tutorial_service) { … }
}
namespace internal {
class TutorialStepBuilder { … };
std::unique_ptr<ui::InteractionSequence::Step> TutorialStepBuilder::Build(
TutorialService* tutorial_service) { … }
ui::InteractionSequence::StepStartCallback
TutorialStepBuilder::BuildStartCallback(TutorialService* tutorial_service) { … }
ui::InteractionSequence::StepStartCallback
TutorialStepBuilder::BuildMaybeShowBubbleCallback(
TutorialService* tutorial_service) { … }
ui::InteractionSequence::StepEndCallback
TutorialStepBuilder::BuildHideBubbleCallback(
TutorialService* tutorial_service) { … }
}
std::unique_ptr<ui::InteractionSequence::Step>
Tutorial::Builder::BuildFromDescriptionStep(
const TutorialDescription::Step& step,
int max_progress,
int& current_progress,
bool is_terminal,
bool can_be_restarted,
int complete_button_text_id,
TutorialService* tutorial_service) { … }
Tutorial::Builder::Builder()
: … { … }
Tutorial::Builder::~Builder() = default;
std::unique_ptr<Tutorial> Tutorial::Builder::BuildFromDescription(
const TutorialDescription& description,
TutorialService* tutorial_service,
ui::ElementContext context) { … }
Tutorial::Builder& Tutorial::Builder::AddStep(
std::unique_ptr<ui::InteractionSequence::Step> step) { … }
Tutorial::Builder& Tutorial::Builder::SetAbortedCallback(
ui::InteractionSequence::AbortedCallback callback) { … }
Tutorial::Builder& Tutorial::Builder::SetCompletedCallback(
ui::InteractionSequence::CompletedCallback callback) { … }
Tutorial::Builder& Tutorial::Builder::SetContext(
ui::ElementContext element_context) { … }
std::unique_ptr<Tutorial> Tutorial::Builder::Build() { … }
Tutorial::Tutorial(
std::unique_ptr<ui::InteractionSequence> interaction_sequence)
: … { … }
Tutorial::~Tutorial() = default;
void Tutorial::Start() { … }
void Tutorial::Abort() { … }
void Tutorial::SetState(std::unique_ptr<ScopedTutorialState> tutorial_state) { … }
}