#include "components/user_education/common/feature_promo_lifecycle.h"
#include <optional>
#include <string_view>
#include "base/containers/contains.h"
#include "base/containers/map_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "components/user_education/common/feature_promo_data.h"
#include "components/user_education/common/feature_promo_result.h"
#include "components/user_education/common/feature_promo_specification.h"
#include "components/user_education/common/feature_promo_storage_service.h"
#include "components/user_education/common/help_bubble.h"
#include "components/user_education/common/user_education_features.h"
namespace user_education {
namespace {
class ScopedPromoData { … };
}
FeaturePromoLifecycle::FeaturePromoLifecycle(
FeaturePromoStorageService* storage_service,
std::string_view promo_key,
const base::Feature* iph_feature,
PromoType promo_type,
PromoSubtype promo_subtype,
int num_rotating_entries = 0)
: … { … }
FeaturePromoLifecycle::~FeaturePromoLifecycle() { … }
FeaturePromoLifecycle& FeaturePromoLifecycle::SetReshowPolicy(
base::TimeDelta reshow_delay,
std::optional<int> max_show_count) { … }
FeaturePromoResult FeaturePromoLifecycle::CanShow() const { … }
bool FeaturePromoLifecycle::CanSnooze() const { … }
int FeaturePromoLifecycle::GetPromoIndex() const { … }
void FeaturePromoLifecycle::SetPromoIndex(int new_index) { … }
void FeaturePromoLifecycle::OnPromoShown(
std::unique_ptr<HelpBubble> help_bubble,
feature_engagement::Tracker* tracker) { … }
void FeaturePromoLifecycle::OnPromoShownForDemo(
std::unique_ptr<HelpBubble> help_bubble) { … }
bool FeaturePromoLifecycle::OnPromoBubbleClosed(
HelpBubble::CloseReason reason) { … }
void FeaturePromoLifecycle::OnPromoEnded(FeaturePromoClosedReason close_reason,
bool continue_promo) { … }
void FeaturePromoLifecycle::OnContinuedPromoEnded(bool completed_successfully) { … }
bool FeaturePromoLifecycle::MaybeEndPromo() { … }
FeaturePromoResult FeaturePromoLifecycle::CanShowSnoozePromo(
const FeaturePromoData& promo_data) const { … }
base::Time FeaturePromoLifecycle::GetCurrentTime() const { … }
void FeaturePromoLifecycle::MaybeCachePromoIndex(
const FeaturePromoData* data) const { … }
FeaturePromoResult FeaturePromoLifecycle::GetReshowResult(
base::Time last_shown,
int show_count) const { … }
void FeaturePromoLifecycle::MaybeWriteClosedPromoData(
FeaturePromoClosedReason close_reason) { … }
void FeaturePromoLifecycle::RecordShown() { … }
void FeaturePromoLifecycle::MaybeRecordClosedReason(
FeaturePromoClosedReason close_reason) { … }
}