// 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. #ifndef COMPONENTS_USER_EDUCATION_COMMON_TUTORIAL_DESCRIPTION_H_ #define COMPONENTS_USER_EDUCATION_COMMON_TUTORIAL_DESCRIPTION_H_ #include <optional> #include <string> #include <utility> #include <variant> #include <vector> #include "base/functional/callback_helpers.h" #include "base/metrics/histogram_macros.h" #include "components/strings/grit/components_strings.h" #include "components/user_education/common/help_bubble_params.h" #include "components/user_education/common/user_education_metadata.h" #include "ui/base/interaction/element_identifier.h" #include "ui/base/interaction/element_tracker.h" #include "ui/base/interaction/interaction_sequence.h" namespace user_education { // Holds the data required to properly store histograms for a given tutorial. // Abstract base class because best practice is to statically declare // histograms and so we need some compile-time polymorphism to actually // implement the RecordXXX() calls. // // Use MakeTutorialHistograms() below to create a concrete instance of this // class. class TutorialHistograms { … }; namespace internal { constexpr char kTutorialHistogramPrefix[] = …; template <const char histogram_name[]> class TutorialHistogramsImpl : public TutorialHistograms { … }; } // namespace internal // Call to create a tutorial-specific histograms object for use with the // tutorial. The template parameter should be a reference to a const char[] // that is a compile-time constant. Also remember to add a matching entry to // the "TutorialID" variant in histograms.xml corresponding to your tutorial. // // Example: // const char kMyTutorialName[] = "MyTutorial"; // tutorial_descriptions.histograms = // MakeTutorialHistograms<kMyTutorialName>( // tutorial_description.steps.size()); template <const char* histogram_name> std::unique_ptr<TutorialHistograms> MakeTutorialHistograms(int max_steps) { … } // A class that manages a temporary state associated with the tutorial. // A new object via the temporary setup callback when a new tutorial is started // and maintained through the lifetime of the tutorial. class ScopedTutorialState { … }; // A Struct that provides all of the data necessary to construct a Tutorial. // A Tutorial Description is a list of Steps for a tutorial. Each step has info // for constructing the InteractionSequence::Step from the // TutorialDescription::Step. struct TutorialDescription { … }; } // namespace user_education #endif // COMPONENTS_USER_EDUCATION_COMMON_TUTORIAL_DESCRIPTION_H_