1 // Copyright 2020 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.
5 #include "components/permissions/features.h"
6 #include "base/feature_list.h"
7 #include "base/time/time.h"
9 namespace permissions {
12 // Enables or disables whether pages with pending permission requests will
13 // go into back/forward cache.
14 BASE_FEATURE(kBackForwardCacheUnblockPermissionRequest,
15 "BackForwardCacheUnblockPermissionRequest",
16 base::FEATURE_DISABLED_BY_DEFAULT);
18 // Enables or disables whether permission prompts are automatically blocked
19 // after the user has explicitly dismissed them too many times.
20 BASE_FEATURE(kBlockPromptsIfDismissedOften,
21 "BlockPromptsIfDismissedOften",
22 base::FEATURE_ENABLED_BY_DEFAULT);
24 // Enables or disables whether permission prompts are automatically blocked
25 // after the user has ignored them too many times.
26 BASE_FEATURE(kBlockPromptsIfIgnoredOften,
27 "BlockPromptsIfIgnoredOften",
28 base::FEATURE_ENABLED_BY_DEFAULT);
30 // Once the user has auto re-authenticated, automatically block subsequent auto
31 // re-authn prompts within the next 10 minutes.
32 BASE_FEATURE(kBlockRepeatedAutoReauthnPrompts,
33 "BlockRepeatedAutoReauthnPrompts",
34 base::FEATURE_ENABLED_BY_DEFAULT);
36 // Once the user declines a notification permission prompt in a WebContents,
37 // automatically dismiss subsequent prompts in the same WebContents, from any
38 // origin, until the next user-initiated navigation.
39 BASE_FEATURE(kBlockRepeatedNotificationPermissionPrompts,
40 "BlockRepeatedNotificationPermissionPrompts",
41 base::FEATURE_ENABLED_BY_DEFAULT);
43 BASE_FEATURE(kConfirmationChip,
45 base::FEATURE_ENABLED_BY_DEFAULT);
47 BASE_FEATURE(kChipLocationBarIconOverride,
48 "ChipLocationIconOverride",
49 base::FEATURE_ENABLED_BY_DEFAULT);
51 BASE_FEATURE(kPermissionElement,
53 base::FEATURE_DISABLED_BY_DEFAULT);
55 BASE_FEATURE(kNotificationInteractionHistory,
56 "NotificationInteractionHistory",
57 base::FEATURE_ENABLED_BY_DEFAULT);
59 BASE_FEATURE(kOneTimePermission,
61 base::FEATURE_DISABLED_BY_DEFAULT);
63 // Enables a faster permission request finalization if it is displayed as a
65 BASE_FEATURE(kFailFastQuietChip,
67 base::FEATURE_ENABLED_BY_DEFAULT);
69 // When enabled, use the value of the `service_url` FeatureParam as the url
70 // for the Web Permission Predictions Service.
71 BASE_FEATURE(kPermissionPredictionServiceUseUrlOverride,
72 "kPermissionPredictionServiceUseUrlOverride",
73 base::FEATURE_DISABLED_BY_DEFAULT);
75 BASE_FEATURE(kPermissionOnDeviceNotificationPredictions,
76 "PermissionOnDeviceNotificationPredictions",
77 base::FEATURE_ENABLED_BY_DEFAULT);
79 BASE_FEATURE(kPermissionOnDeviceGeolocationPredictions,
80 "PermissionOnDeviceGeolocationPredictions",
81 base::FEATURE_ENABLED_BY_DEFAULT);
83 BASE_FEATURE(kPermissionDedicatedCpssSetting,
84 "PermissionDedicatedCpssSettings",
85 base::FEATURE_DISABLED_BY_DEFAULT);
87 BASE_FEATURE(kPermissionPredictionsV2,
88 "PermissionPredictionsV2",
89 base::FEATURE_DISABLED_BY_DEFAULT);
91 #if BUILDFLAG(IS_ANDROID)
93 // When enabled, blocks notifications permission prompt when Chrome doesn't
94 // have app level Notification permission.
95 BASE_FEATURE(kBlockNotificationPromptsIfDisabledOnAppLevel,
96 "BlockNotificationPromptsIfDisabledOnAppLevel",
97 base::FEATURE_ENABLED_BY_DEFAULT);
101 // Controls whether to trigger showing a HaTS survey, with the given
102 // `probability` and `trigger_id`. The `probability` parameter is defined and
103 // handled by the HatsService itself. If the parameter
104 // `kPermissionsPromptSurveyDisplayTime` is set to `OnPromptResolved` (default),
105 // the survey is shown immediately after the user has taken the action specified
106 // in `action_filter` on a permission prompt for the capability specified in
107 // `request_type_filter`. If, on the other hand, the
108 // `kPermissionsPromptSurveyDisplayTime` is set to `OnPromptAppearing`, the
109 // survey is shown when the prompt is first shown to the user. Note, that
110 // configuring `PermissionAction` does not make sense in that case, since the
111 // user has not yet taken an action. Therefore, that parameter is ignored in
113 BASE_FEATURE(kPermissionsPromptSurvey,
114 "PermissionsPromptSurvey",
115 base::FEATURE_DISABLED_BY_DEFAULT);
117 // When enabled, permissions grants with a durable session model will have
118 // an expiration date set. The interpretation of the expiration date
119 // is not handled by this component, but left to the embedding browser.
120 BASE_FEATURE(kRecordPermissionExpirationTimestamps,
121 "RecordPermissionExpirationTimestamps",
122 base::FEATURE_ENABLED_BY_DEFAULT);
124 // Kill switch for the mitigation for https://crbug.com/1462709
125 BASE_FEATURE(kMitigateUnpartitionedWebviewPermissions,
126 "MitigateUnpartitionedWebviewPermissions",
127 base::FEATURE_ENABLED_BY_DEFAULT);
129 #endif // BUILDFLAG(IS_ANDROID)
131 // When enabled, permission grants for Storage Access API will be enabled.
132 // This includes enabling prompts, a new settings page and page info and
133 // omnibox integration.
134 BASE_FEATURE(kPermissionStorageAccessAPI,
135 "PermissionStorageAccessAPI",
136 #if BUILDFLAG(IS_ANDROID)
137 base::FEATURE_DISABLED_BY_DEFAULT
139 base::FEATURE_ENABLED_BY_DEFAULT
143 // When enabled "window-placement" may be used as an alias for
144 // "window-management". Additionally, reverse mappings (i.e. enum to string)
145 // will default to the legacy strings ("window-placement").
146 BASE_FEATURE(kWindowPlacementPermissionAlias,
147 "WindowPlacementPermissionAlias",
148 base::FEATURE_ENABLED_BY_DEFAULT);
150 // When enabled, blocks condition to exclude auto granted permissions for
151 // storage access exceptions. This will allow RWS permission grants to be
152 // visible in the Embedded content settings page.
153 BASE_FEATURE(kShowRelatedWebsiteSetsPermissionGrants,
154 "ShowRelatedWebsiteSetsPermissionGrants",
155 base::FEATURE_DISABLED_BY_DEFAULT);
157 // Enables disallowing MIDI permission by default.
158 BASE_FEATURE(kBlockMidiByDefault,
159 "BlockMidiByDefault",
160 base::FEATURE_DISABLED_BY_DEFAULT);
162 } // namespace features
163 namespace feature_params {
165 const base::FeatureParam<bool> kUseStrongerPromptLanguage{
166 &features::kOneTimePermission, "use_stronger_prompt_language", false};
168 const base::FeatureParam<base::TimeDelta> kOneTimePermissionTimeout{
169 &features::kOneTimePermission, "one_time_permission_timeout",
172 const base::FeatureParam<base::TimeDelta> kOneTimePermissionLongTimeout{
173 &features::kOneTimePermission, "one_time_permission_long_timeout",
176 const base::FeatureParam<std::string> kPermissionPredictionServiceUrlOverride{
177 &permissions::features::kPermissionPredictionServiceUseUrlOverride,
180 const base::FeatureParam<double>
181 kPermissionOnDeviceGeolocationPredictionsHoldbackChance(
182 &features::kPermissionOnDeviceGeolocationPredictions,
186 const base::FeatureParam<double>
187 kPermissionOnDeviceNotificationPredictionsHoldbackChance(
188 &features::kPermissionOnDeviceNotificationPredictions,
192 const base::FeatureParam<double> kPermissionPredictionsV2HoldbackChance(
193 &features::kPermissionPredictionsV2,
197 #if !BUILDFLAG(IS_ANDROID)
198 // Specifies the `trigger_id` of the HaTS survey to trigger immediately after
199 // the user has interacted with a permission prompt. Multiple values can be
200 // configured by providing a comma separated list. If this is done, a
201 // corresponding probability_vector and request_type_filter of equal length must
202 // be configured. If this is done, each trigger_id applies to the request type
203 // at the corresponding position in the request_type_filter and has probability
204 // of probability p * hats_p of triggering, where p is the probability at the
205 // corresponding position in the probability_vector and hats_p is the
206 // probability configured for the HaTS survey.
207 const base::FeatureParam<std::string> kPermissionsPromptSurveyTriggerId{
208 &permissions::features::kPermissionsPromptSurvey, "trigger_id", ""};
210 // If multiple trigger ids are configured, the trigger id at position p only
211 // triggers for the request type at position p of the request type filter,
212 // and calls the HaTS service with the probability at position p in the
213 // probability vector. The HaTS service also has a feature parameter called
214 // probability. The probability vector is a secondary probability to
215 // distribute surveys among the multiple triggers, while the HaTS service
216 // probability is the probability of triggering overall.
217 const base::FeatureParam<std::string> kProbabilityVector{
218 &permissions::features::kPermissionsPromptSurvey, "probability_vector",
221 // Specifies the type of permission request for which the prompt HaTS
222 // survey is triggered (as long as other filters are also satisfied). Valid
223 // values are the return values of `GetPermissionRequestString`. An empty value
224 // will result in all request types matching (no filtering on request types).
225 // Use caution when configuring multiple values. Each study can only specify one
226 // probability value. Some request types have a vastly different number of
227 // occurrences then others, which likely makes them a bad match for combining
228 // them in the same study.
229 const base::FeatureParam<std::string> kPermissionsPromptSurveyRequestTypeFilter{
230 &permissions::features::kPermissionsPromptSurvey, "request_type_filter",
233 // A survey can either be triggered when the prompt is shown or afterwards.
234 // Valid configuration values are `OnPromptAppearing` and `OnPromptResolved`.
235 const base::FeatureParam<std::string> kPermissionsPromptSurveyDisplayTime{
236 &permissions::features::kPermissionsPromptSurvey, "survey_display_time",
239 // Specifies the actions for which the prompt HaTS survey is triggered (as
240 // long as other filters are also satisfied). Multiple values can be configured
241 // by providing a comma separated list. Valid values are those listed in
242 // PermissionUmaUtil::GetPermissionActionString. An empty value will result in
243 // all actions matching (no filtering on actions). Note, that this parameter is
244 // ignored if `SurveyDisplayTime` is set to `OnPromptAppearing`.
245 const base::FeatureParam<std::string> kPermissionsPromptSurveyActionFilter{
246 &permissions::features::kPermissionsPromptSurvey, "action_filter", ""};
248 // Specifies whether the prompt HaTS survey is triggered for permission
249 // requests with or without user gesture (as long as other filters are also
250 // satisfied). Valid values are 'true' and 'false'. An empty value or
251 // 'true,false' will result in all requests matching (no filtering on user
253 const base::FeatureParam<std::string> kPermissionsPromptSurveyHadGestureFilter{
254 &permissions::features::kPermissionsPromptSurvey, "had_gesture_filter", ""};
256 // Specifies the prompt disposition(s) for which the prompt HaTS
257 // survey is triggered (as long as other filters are also satisfied). Multiple
258 // values can be configured by providing a comma separated list. Valid values
259 // are those listed in PermissionUmaUtil::GetPromptDispositionString. An empty
260 // value will result in all prompt dispositions matching (no filtering on prompt
262 const base::FeatureParam<std::string>
263 kPermissionsPromptSurveyPromptDispositionFilter{
264 &permissions::features::kPermissionsPromptSurvey,
265 "prompt_disposition_filter", ""};
267 // Specifies the prompt disposition reason(s) for which the prompt HaTS
268 // survey is triggered (as long as other filters are also satisfied). Multiple
269 // values can be configured by providing a comma separated list. Valid values
270 // are those listed in PermissionUmaUtil::GetPromptDispositionReasonString. An
271 // empty value will result in all prompt disposition reasons matching (no
272 // filtering on prompt disposition reasons).
273 const base::FeatureParam<std::string>
274 kPermissionsPromptSurveyPromptDispositionReasonFilter{
275 &permissions::features::kPermissionsPromptSurvey,
276 "prompt_disposition_reason_filter", ""};
278 // Specifies the browser channel(s) for which the prompt HaTS survey is
279 // triggered (as long as other filters are also satisfied). Multiple values can
280 // be configured by providing a comma separated list. Valid values are those
281 // listed in version_info::GetChannelString. An empty value will result in all
282 // channels matching (no filtering on channels within HaTS). This filter allows
283 // restriction to specific channels (typically to stable). Inform Finch team
284 // when configuring this filter, as it will effectively disable this feature on
286 const base::FeatureParam<std::string>
287 kPermissionPromptSurveyReleaseChannelFilter{
288 &permissions::features::kPermissionsPromptSurvey,
289 "release_channel_filter", ""};
291 // Some prompts stay open for a long time. This parameter allows specifying an
292 // upper bound on how long a prompt that has been ignored can have been
293 // showing and still trigger a survey if all other filters match. Prompts that
294 // have been open longer before being ignored do not trigger a survey anymore.
295 const base::FeatureParam<base::TimeDelta>
296 kPermissionPromptSurveyIgnoredPromptsMaximumAge{
297 &permissions::features::kPermissionsPromptSurvey,
298 "ignored_prompts_maximum_age", base::Minutes(10)};
300 // We count the number of one time permission prompt impressions that a user has
301 // seen. This parameter specifies the buckets to which a user needs to belong to
302 // in order for a HaTS survey to be triggered. Multiple values can be configured
303 // by providing a comma separated list. Valid values are the return values of
304 // `PermissionUtil::GetOneTimePromptsDecidedBucketString`. An empty value will
305 // result in all buckets matching (no filtering).
306 const base::FeatureParam<std::string>
307 kPermissionPromptSurveyOneTimePromptsDecidedBucket{
308 &permissions::features::kPermissionsPromptSurvey,
309 "one_time_prompts_decided_bucket", ""};
310 #endif // !BUILDFLAG(IS_ANDROID)
312 } // namespace feature_params
313 } // namespace permissions