blob: ea9dd20aa31245527e7b7e240392e9870689ff4d [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
Arthur Sonzognife132ee2024-01-15 11:01:048#include <optional>
9
Dana Friedcb6b1572023-08-18 21:32:0110#include "components/feature_engagement/public/configuration.h"
11#include "components/feature_engagement/public/configuration_provider.h"
12#include "components/feature_engagement/public/feature_list.h"
13#include "components/feature_engagement/public/group_list.h"
Dana Fried154c57f2024-10-23 17:21:5814#include "components/user_education/common/feature_promo/feature_promo_registry.h"
Dana Friedcb6b1572023-08-18 21:32:0115
16// Provides feature engagement configuration based on IPH registered in the
17// browser.
18class UserEducationConfigurationProvider
19 : public feature_engagement::ConfigurationProvider {
20 public:
21 UserEducationConfigurationProvider();
Dana Fried2bb75162023-08-18 21:39:0622 explicit UserEducationConfigurationProvider(
23 user_education::FeaturePromoRegistry registry_for_testing);
Dana Friedcb6b1572023-08-18 21:32:0124 ~UserEducationConfigurationProvider() override;
25
26 // feature_engagement::ConfigurationProvider:
27 bool MaybeProvideFeatureConfiguration(
28 const base::Feature& feature,
29 feature_engagement::FeatureConfig& config,
30 const feature_engagement::FeatureVector& known_features,
31 const feature_engagement::GroupVector& known_groups) const override;
32 const char* GetConfigurationSourceDescription() const override;
33
Dana Fried2bb75162023-08-18 21:39:0634 // For automatic configuration of triggers, derive default "trigger" and
35 // "used" names. The default "used" name, in turn, will be used to ensure that
36 // teams using IPH will be able to call a method that says "this feature was
37 // used" while specifying only the associated `base::Feature`.
38 static std::string GetDefaultTriggerName(const base::Feature& feature);
39 static std::string GetDefaultUsedName(const base::Feature& feature);
40
Dana Friedcb6b1572023-08-18 21:32:0141 private:
42 user_education::FeaturePromoRegistry registry_;
Dana Friedcb6b1572023-08-18 21:32:0143};
44
45#endif // CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_CONFIGURATION_PROVIDER_H_