#include "components/user_education/common/feature_promo_specification.h"
#include <string>
#include <variant>
#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/functional/callback_forward.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/l10n/l10n_util.h"
namespace user_education {
namespace {
bool IsAllowedLegalNotice(const base::Feature& promo_feature) { … }
bool IsAllowedActionableAlert(const base::Feature& promo_feature) { … }
bool IsAllowedKeyedNotice(const base::Feature& promo_feature) { … }
bool IsAllowedRotatingPromo(const base::Feature& promo_feature) { … }
bool IsAllowedLegacyPromo(const base::Feature& promo_feature) { … }
bool IsAllowedToastWithoutScreenreaderText(const base::Feature& promo_feature) { … }
void CheckReshowAllowedFor(FeaturePromoSpecification::PromoSubtype subtype) { … }
base::TimeDelta GetMinReshowDelay(
FeaturePromoSpecification::PromoType type,
FeaturePromoSpecification::PromoSubtype subtype) { … }
}
FeaturePromoSpecification::AdditionalConditions::AdditionalConditions() =
default;
FeaturePromoSpecification::AdditionalConditions::AdditionalConditions(
AdditionalConditions&&) noexcept = default;
FeaturePromoSpecification::AdditionalConditions&
FeaturePromoSpecification::AdditionalConditions::operator=(
AdditionalConditions&&) noexcept = default;
FeaturePromoSpecification::AdditionalConditions::~AdditionalConditions() =
default;
FeaturePromoSpecification::AdditionalConditions&
FeaturePromoSpecification::AdditionalConditions::AddAdditionalCondition(
const AdditionalCondition& additional_condition) { … }
void FeaturePromoSpecification::AdditionalConditions::AddAdditionalCondition(
const char* event_name,
Constraint constraint,
uint32_t count,
std::optional<uint32_t> in_days) { … }
FeaturePromoSpecification::AcceleratorInfo::AcceleratorInfo() = default;
FeaturePromoSpecification::AcceleratorInfo::AcceleratorInfo(
const AcceleratorInfo& other) = default;
FeaturePromoSpecification::AcceleratorInfo::AcceleratorInfo(ValueType value)
: … { … }
FeaturePromoSpecification::AcceleratorInfo&
FeaturePromoSpecification::AcceleratorInfo::operator=(
const AcceleratorInfo& other) = default;
FeaturePromoSpecification::AcceleratorInfo::~AcceleratorInfo() = default;
FeaturePromoSpecification::AcceleratorInfo&
FeaturePromoSpecification::AcceleratorInfo::operator=(ValueType value) { … }
operator bool()
ui::Accelerator FeaturePromoSpecification::AcceleratorInfo::GetAccelerator(
const ui::AcceleratorProvider* provider) const { … }
FeaturePromoSpecification::RotatingPromos::RotatingPromos() = default;
FeaturePromoSpecification::RotatingPromos::RotatingPromos(
RotatingPromos&&) noexcept = default;
FeaturePromoSpecification::RotatingPromos&
FeaturePromoSpecification::RotatingPromos::operator=(
RotatingPromos&&) noexcept = default;
FeaturePromoSpecification::RotatingPromos::~RotatingPromos() = default;
constexpr HelpBubbleArrow FeaturePromoSpecification::kDefaultBubbleArrow;
FeaturePromoSpecification::FeaturePromoSpecification() = default;
FeaturePromoSpecification::FeaturePromoSpecification(
FeaturePromoSpecification&& other) noexcept = default;
FeaturePromoSpecification::FeaturePromoSpecification(
const base::Feature* feature,
PromoType promo_type,
ui::ElementIdentifier anchor_element_id,
int bubble_body_string_id)
: … { … }
FeaturePromoSpecification& FeaturePromoSpecification::operator=(
FeaturePromoSpecification&& other) noexcept = default;
FeaturePromoSpecification::~FeaturePromoSpecification() = default;
std::u16string FeaturePromoSpecification::FormatString(
int string_id,
const FormatParameters& format_params) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForToastPromo(
const base::Feature& feature,
ui::ElementIdentifier anchor_element_id,
int body_text_string_id,
int accessible_text_string_id,
AcceleratorInfo accessible_accelerator) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForSnoozePromo(
const base::Feature& feature,
ui::ElementIdentifier anchor_element_id,
int body_text_string_id) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForSnoozePromo(
const base::Feature& feature,
ui::ElementIdentifier anchor_element_id,
int body_text_string_id,
int accessible_text_string_id,
AcceleratorInfo accessible_accelerator) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForTutorialPromo(
const base::Feature& feature,
ui::ElementIdentifier anchor_element_id,
int body_text_string_id,
TutorialIdentifier tutorial_id) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForCustomAction(
const base::Feature& feature,
ui::ElementIdentifier anchor_element_id,
int body_text_string_id,
int custom_action_string_id,
CustomActionCallback custom_action_callback) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForRotatingPromo(
const base::Feature& feature,
RotatingPromos rotating_promos) { … }
FeaturePromoSpecification FeaturePromoSpecification::CreateForLegacyPromo(
const base::Feature* feature,
ui::ElementIdentifier anchor_element_id,
int body_text_string_id) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetBubbleTitleText(
int title_text_string_id) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetBubbleIcon(
const gfx::VectorIcon* bubble_icon) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetBubbleArrow(
HelpBubbleArrow bubble_arrow) { … }
FeaturePromoSpecification& FeaturePromoSpecification::OverrideFocusOnShow(
bool focus_on_show) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetPromoSubtype(
PromoSubtype promo_subtype) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetReshowPolicy(
base::TimeDelta reshow_delay,
std::optional<int> max_show_count) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetAnchorElementFilter(
AnchorElementFilter anchor_element_filter) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetInAnyContext(
bool in_any_context) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetAdditionalConditions(
AdditionalConditions additional_conditions) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetMetadata(
Metadata metadata) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetCustomActionIsDefault(
bool custom_action_is_default) { … }
FeaturePromoSpecification&
FeaturePromoSpecification::SetCustomActionDismissText(
int custom_action_dismiss_string_id) { … }
FeaturePromoSpecification& FeaturePromoSpecification::SetHighlightedMenuItem(
const ui::ElementIdentifier highlighted_menu_identifier) { … }
ui::TrackedElement* FeaturePromoSpecification::GetAnchorElement(
ui::ElementContext context) const { … }
FeaturePromoSpecification
FeaturePromoSpecification::CreateRotatingPromoForTesting(
const base::Feature& feature,
RotatingPromos rotating_promos) { … }
std::ostream& operator<<(std::ostream& oss,
FeaturePromoSpecification::PromoType promo_type) { … }
std::ostream& operator<<(
std::ostream& oss,
FeaturePromoSpecification::PromoSubtype promo_subtype) { … }
}