blob: bd8120c379934cda0260213e2fd625fe1eefde78 [file] [log] [blame]
Jan Keitel3bea1932023-03-20 13:35:391# 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
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8for more details on the presubmit API built into depot_tools.
9"""
10
Jan Keitel3bea1932023-03-20 13:35:3911PRESUBMIT_VERSION = '2.0.0'
12
13def IsComponentsAndroidAutofillFile(f, name_suffix):
14 return (f.LocalPath().startswith('components/android_autofill/') and
15 f.LocalPath().endswith(name_suffix))
16
17def AnyAffectedFileMatches(input_api, matcher):
18 return any(matcher(f) for f in input_api.change.AffectedTestableFiles())
19
20def IsComponentsAndroidAutofillFileAffected(input_api, name_suffix):
21 return AnyAffectedFileMatches(
22 input_api, lambda f: IsComponentsAndroidAutofillFile(f, name_suffix))
23
24def 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