Dana Fried | cb6b157 | 2023-08-18 21:32:01 | [diff] [blame] | 1 | // 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 Sonzogni | fe132ee | 2024-01-15 11:01:04 | [diff] [blame] | 8 | #include <optional> |
| 9 | |
Dana Fried | cb6b157 | 2023-08-18 21:32:01 | [diff] [blame] | 10 | #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 Fried | 154c57f | 2024-10-23 17:21:58 | [diff] [blame] | 14 | #include "components/user_education/common/feature_promo/feature_promo_registry.h" |
Dana Fried | cb6b157 | 2023-08-18 21:32:01 | [diff] [blame] | 15 | |
| 16 | // Provides feature engagement configuration based on IPH registered in the |
| 17 | // browser. |
| 18 | class UserEducationConfigurationProvider |
| 19 | : public feature_engagement::ConfigurationProvider { |
| 20 | public: |
| 21 | UserEducationConfigurationProvider(); |
Dana Fried | 2bb7516 | 2023-08-18 21:39:06 | [diff] [blame] | 22 | explicit UserEducationConfigurationProvider( |
| 23 | user_education::FeaturePromoRegistry registry_for_testing); |
Dana Fried | cb6b157 | 2023-08-18 21:32:01 | [diff] [blame] | 24 | ~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 Fried | 2bb7516 | 2023-08-18 21:39:06 | [diff] [blame] | 34 | // 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 Fried | cb6b157 | 2023-08-18 21:32:01 | [diff] [blame] | 41 | private: |
| 42 | user_education::FeaturePromoRegistry registry_; |
Dana Fried | cb6b157 | 2023-08-18 21:32:01 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | #endif // CHROME_BROWSER_USER_EDUCATION_USER_EDUCATION_CONFIGURATION_PROVIDER_H_ |