Jan Keitel | 3bea193 | 2023-03-20 13:35:39 | [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 | """Chromium presubmit script for src/components/android_autofill. |
| 6 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 | for more details on the presubmit API built into depot_tools. |
| 9 | """ |
| 10 | |
Jan Keitel | 3bea193 | 2023-03-20 13:35:39 | [diff] [blame] | 11 | PRESUBMIT_VERSION = '2.0.0' |
| 12 | |
| 13 | def IsComponentsAndroidAutofillFile(f, name_suffix): |
| 14 | return (f.LocalPath().startswith('components/android_autofill/') and |
| 15 | f.LocalPath().endswith(name_suffix)) |
| 16 | |
| 17 | def AnyAffectedFileMatches(input_api, matcher): |
| 18 | return any(matcher(f) for f in input_api.change.AffectedTestableFiles()) |
| 19 | |
| 20 | def IsComponentsAndroidAutofillFileAffected(input_api, name_suffix): |
| 21 | return AnyAffectedFileMatches( |
| 22 | input_api, lambda f: IsComponentsAndroidAutofillFile(f, name_suffix)) |
| 23 | |
| 24 | def CheckWebViewExposedExperiments(input_api, output_api): |
| 25 | """Checks that changes to android autofill features are exposed to webview.""" |
| 26 | |
| 27 | _PRODUCTION_SUPPORT_FILE = ('android_webview/java/src/org/chromium/' + |
| 28 | 'android_webview/common/ProductionSupportedFlagList.java') |
| 29 | |
| 30 | warnings = [] |
| 31 | if (IsComponentsAndroidAutofillFileAffected(input_api, 'features.cc') and |
| 32 | not AnyAffectedFileMatches( |
| 33 | input_api, lambda f: f.LocalPath() == _PRODUCTION_SUPPORT_FILE)): |
| 34 | warnings += [ |
| 35 | output_api.PresubmitPromptWarning( |
| 36 | ( |
| 37 | 'You may need to modify {} instructions if your feature affects' |
| 38 | ' WebView.' |
| 39 | ).format(_PRODUCTION_SUPPORT_FILE) |
| 40 | ) |
| 41 | ] |
| 42 | |
| 43 | return warnings |