blob: b9bab7c1eecb0da618a7de41e0a517073e0d9760 [file] [log] [blame]
Dana Friedcb6b1572023-08-18 21:32:011// Copyright 2023 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_CONFIGURATION_PROVIDER_H_
6#define CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_CONFIGURATION_PROVIDER_H_
7
8#include "components/feature_engagement/public/configuration.h"
9#include "components/feature_engagement/public/configuration_provider.h"
10#include "components/feature_engagement/public/feature_list.h"
11#include "components/feature_engagement/public/group_list.h"
12#include "components/user_education/common/feature_promo_registry.h"
Dana Fried68baeb002023-09-18 20:25:0413#include "third_party/abseil-cpp/absl/types/optional.h"
Dana Friedcb6b1572023-08-18 21:32:0114
15// Provides feature engagement configuration based on IPH registered in the
16// browser.
17class UserEducationConfigurationProvider
18 : public feature_engagement::ConfigurationProvider {
19 public:
20 UserEducationConfigurationProvider();
Dana Fried2bb75162023-08-18 21:39:0621 explicit UserEducationConfigurationProvider(
22 user_education::FeaturePromoRegistry registry_for_testing);
Dana Friedcb6b1572023-08-18 21:32:0123 ~UserEducationConfigurationProvider() override;
24
25 // feature_engagement::ConfigurationProvider:
26 bool MaybeProvideFeatureConfiguration(
27 const base::Feature& feature,
28 feature_engagement::FeatureConfig& config,
29 const feature_engagement::FeatureVector& known_features,
30 const feature_engagement::GroupVector& known_groups) const override;
31 const char* GetConfigurationSourceDescription() const override;
32
Dana Fried2bb75162023-08-18 21:39:0633 // For automatic configuration of triggers, derive default "trigger" and
34 // "used" names. The default "used" name, in turn, will be used to ensure that
35 // teams using IPH will be able to call a method that says "this feature was
36 // used" while specifying only the associated `base::Feature`.
37 static std::string GetDefaultTriggerName(const base::Feature& feature);
38 static std::string GetDefaultUsedName(const base::Feature& feature);
39
Dana Friedcb6b1572023-08-18 21:32:0140 private:
41 user_education::FeaturePromoRegistry registry_;
Dana Fried3d34131d2024-01-12 23:44:1742 const bool use_v2_behavior_;
Dana Friedcb6b1572023-08-18 21:32:0143};
44
45#endif // CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_CONFIGURATION_PROVIDER_H_