| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_PUBLIC_FEATURE_LIST_H_ | 5 #ifndef COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_PUBLIC_FEATURE_LIST_H_ |
| 6 #define COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_PUBLIC_FEATURE_LIST_H_ | 6 #define COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_PUBLIC_FEATURE_LIST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "components/feature_engagement_tracker/public/feature_constants.h" | 12 #include "components/feature_engagement_tracker/public/feature_constants.h" |
| 13 #include "components/flags_ui/feature_entry.h" | 13 #include "components/flags_ui/feature_entry.h" |
| 14 | 14 |
| 15 namespace feature_engagement_tracker { | 15 namespace feature_engagement_tracker { |
| 16 using FeatureVector = std::vector<const base::Feature*>; | 16 using FeatureVector = std::vector<const base::Feature*>; |
| 17 | 17 |
| 18 // The param name for the FeatureVariation configuration, which is used by | 18 // The param name for the FeatureVariation configuration, which is used by |
| 19 // chrome://flags to set the variable name for the selected feature. The | 19 // chrome://flags to set the variable name for the selected feature. The |
| 20 // FeatureEngagementTracker backend will then read this to figure out which | 20 // FeatureEngagementTracker backend will then read this to figure out which |
| 21 // feature (if any) was selected by the end user. | 21 // feature (if any) was selected by the end user. |
| 22 extern const char kIPHDemoModeFeatureChoiceParam[]; | 22 extern const char kIPHDemoModeFeatureChoiceParam[]; |
| 23 | 23 |
| 24 // The command-line flag used to enable media download IPH feature in the |
| 25 // renderer. |
| 26 extern const char kEnableMediaDownloadIPH[]; |
| 27 |
| 24 namespace { | 28 namespace { |
| 25 | 29 |
| 26 // Defines a const flags_ui::FeatureEntry::FeatureParam for the given | 30 // Defines a const flags_ui::FeatureEntry::FeatureParam for the given |
| 27 // base::Feature. The constant name will be on the form | 31 // base::Feature. The constant name will be on the form |
| 28 // kFooFeature --> kFooFeatureVariation. The |feature_name| argument must | 32 // kFooFeature --> kFooFeatureVariation. The |feature_name| argument must |
| 29 // match the base::Feature::name member of the |base_feature|. | 33 // match the base::Feature::name member of the |base_feature|. |
| 30 // This is intended to be used with VARIATION_ENTRY below to be able to insert | 34 // This is intended to be used with VARIATION_ENTRY below to be able to insert |
| 31 // it into an array of flags_ui::FeatureEntry::FeatureVariation. | 35 // it into an array of flags_ui::FeatureEntry::FeatureVariation. |
| 32 #define DEFINE_VARIATION_PARAM(base_feature, feature_name) \ | 36 #define DEFINE_VARIATION_PARAM(base_feature, feature_name) \ |
| 33 constexpr flags_ui::FeatureEntry::FeatureParam base_feature##Variation[] = { \ | 37 constexpr flags_ui::FeatureEntry::FeatureParam base_feature##Variation[] = { \ |
| 34 {kIPHDemoModeFeatureChoiceParam, feature_name}} | 38 {kIPHDemoModeFeatureChoiceParam, feature_name}} |
| 35 | 39 |
| 36 // Defines a single flags_ui::FeatureEntry::FeatureVariation entry, fully | 40 // Defines a single flags_ui::FeatureEntry::FeatureVariation entry, fully |
| 37 // enclosed. This is intended to be used with the declaration of | 41 // enclosed. This is intended to be used with the declaration of |
| 38 // |kIPHDemoModeChoiceVariations| below. | 42 // |kIPHDemoModeChoiceVariations| below. |
| 39 #define VARIATION_ENTRY(base_feature) \ | 43 #define VARIATION_ENTRY(base_feature) \ |
| 40 { \ | 44 { \ |
| 41 base_feature##Variation[0].param_value, base_feature##Variation, \ | 45 base_feature##Variation[0].param_value, base_feature##Variation, \ |
| 42 arraysize(base_feature##Variation), nullptr \ | 46 arraysize(base_feature##Variation), nullptr \ |
| 43 } | 47 } |
| 44 | 48 |
| 45 // Defines a flags_ui::FeatureEntry::FeatureParam for each feature. | 49 // Defines a flags_ui::FeatureEntry::FeatureParam for each feature. |
| 46 DEFINE_VARIATION_PARAM(kIPHDummyFeature, "IPH_Dummy"); | 50 DEFINE_VARIATION_PARAM(kIPHDummyFeature, "IPH_Dummy"); |
| 47 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 48 DEFINE_VARIATION_PARAM(kIPHDataSaverPreviewFeature, "IPH_DataSaverPreview"); | 52 DEFINE_VARIATION_PARAM(kIPHDataSaverPreviewFeature, "IPH_DataSaverPreview"); |
| 49 DEFINE_VARIATION_PARAM(kIPHDataSaverDetailFeature, "IPH_DataSaverDetail"); | 53 DEFINE_VARIATION_PARAM(kIPHDataSaverDetailFeature, "IPH_DataSaverDetail"); |
| 50 DEFINE_VARIATION_PARAM(kIPHDownloadPageFeature, "IPH_DownloadPage"); | 54 DEFINE_VARIATION_PARAM(kIPHDownloadPageFeature, "IPH_DownloadPage"); |
| 51 DEFINE_VARIATION_PARAM(kIPHDownloadHomeFeature, "IPH_DownloadHome"); | 55 DEFINE_VARIATION_PARAM(kIPHDownloadHomeFeature, "IPH_DownloadHome"); |
| 56 DEFINE_VARIATION_PARAM(kIPHMediaDownloadFeature, "IPH_MediaDownload"); |
| 52 #endif // OS_ANDROID | 57 #endif // OS_ANDROID |
| 53 | 58 |
| 54 } // namespace | 59 } // namespace |
| 55 | 60 |
| 56 // Defines the array of which features should be listed in the chrome://flags | 61 // Defines the array of which features should be listed in the chrome://flags |
| 57 // UI to be able to select them alone for demo-mode. The features listed here | 62 // UI to be able to select them alone for demo-mode. The features listed here |
| 58 // are possible to enable on their own in demo mode. | 63 // are possible to enable on their own in demo mode. |
| 59 constexpr flags_ui::FeatureEntry::FeatureVariation | 64 constexpr flags_ui::FeatureEntry::FeatureVariation |
| 60 kIPHDemoModeChoiceVariations[] = { | 65 kIPHDemoModeChoiceVariations[] = { |
| 61 #if defined(OS_ANDROID) | 66 #if defined(OS_ANDROID) |
| 62 VARIATION_ENTRY(kIPHDataSaverPreviewFeature), | 67 VARIATION_ENTRY(kIPHDataSaverPreviewFeature), |
| 63 VARIATION_ENTRY(kIPHDataSaverDetailFeature), | 68 VARIATION_ENTRY(kIPHDataSaverDetailFeature), |
| 64 VARIATION_ENTRY(kIPHDownloadPageFeature), | 69 VARIATION_ENTRY(kIPHDownloadPageFeature), |
| 65 VARIATION_ENTRY(kIPHDownloadHomeFeature), | 70 VARIATION_ENTRY(kIPHDownloadHomeFeature), |
| 71 VARIATION_ENTRY(kIPHMediaDownloadFeature), |
| 66 #else | 72 #else |
| 67 VARIATION_ENTRY(kIPHDummyFeature), // Ensures non-empty array. | 73 VARIATION_ENTRY(kIPHDummyFeature), // Ensures non-empty array. |
| 68 #endif // OS_ANDROID | 74 #endif // OS_ANDROID |
| 69 }; | 75 }; |
| 70 | 76 |
| 71 #undef DEFINE_VARIATION_PARAM | 77 #undef DEFINE_VARIATION_PARAM |
| 72 #undef VARIATION_ENTRY | 78 #undef VARIATION_ENTRY |
| 73 | 79 |
| 74 // Returns all the features that are in use for engagement tracking. | 80 // Returns all the features that are in use for engagement tracking. |
| 75 FeatureVector GetAllFeatures(); | 81 FeatureVector GetAllFeatures(); |
| 76 | 82 |
| 77 } // namespace feature_engagement_tracker | 83 } // namespace feature_engagement_tracker |
| 78 | 84 |
| 79 #endif // COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_PUBLIC_FEATURE_LIST_H_ | 85 #endif // COMPONENTS_FEATURE_ENGAGEMENT_TRACKER_PUBLIC_FEATURE_LIST_H_ |
| OLD | NEW |