components/autofill/content/renderer/PRESUBMIT.py
def _CheckNoDirectPasswordCalls(input_api, output_api):
  """Checks that no files call IsPasswordField() or FormControlType()."""
  pattern = input_api.re.compile(
      r'(IsPasswordField|FormControlType)\(\)',
      input_api.re.MULTILINE)
  files = []
  for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
    if (f.LocalPath().startswith('components/autofill/content/renderer/') and
        not f.LocalPath().endswith("PRESUBMIT.py")):
      contents = input_api.ReadFile(f)
      if pattern.search(contents):
        files.append(f)

  if len(files):
    return [ output_api.PresubmitPromptWarning(
        'Consider to not call IsPasswordField() or FormControlType() directly ' +
        'but use IsPasswordFieldForAutofill() and FormControlTypeForAutofill() ' +
        'respectively. These declare text input fields as password fields ' +
        'if they have been password fields in the past. This is relevant ' +
        'for websites that allow to reveal passwords with a button that ' +
        'triggers a change of the type attribute of an <input> element.',
        files) ]
  return []
Checks that no files call IsPasswordField() or FormControlType().
Checks that no files call IsPasswordField() or FormControlType().
Checks that no files call IsPasswordField () or FormControlType () .
def _CheckNoDirectPasswordCalls(input_api, output_api):
  pattern = input_api.re.compile(
      r'(IsPasswordField|FormControlType)\(\)',
      input_api.re.MULTILINE)
  files = []
  for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
    if (f.LocalPath().startswith('components/autofill/content/renderer/') and
        not f.LocalPath().endswith("PRESUBMIT.py")):
      contents = input_api.ReadFile(f)
      if pattern.search(contents):
        files.append(f)
  if len(files):
    return [ output_api.PresubmitPromptWarning(
        'Consider to not call IsPasswordField() or FormControlType() directly ' +
        'but use IsPasswordFieldForAutofill() and FormControlTypeForAutofill() ' +
        'respectively. These declare text input fields as password fields ' +
        'if they have been password fields in the past. This is relevant ' +
        'for websites that allow to reveal passwords with a button that ' +
        'triggers a change of the type attribute of an <input> element.',
        files) ]
  return []
def _CheckNoDirectPasswordCalls ( input_api , output_api ) : pattern = input_api . re . compile ( r'(IsPasswordField|FormControlType)\(\)' , input_api . re . MULTILINE ) files = [ ] for f in input_api . AffectedSourceFiles ( input_api . FilterSourceFile ) : if ( f . LocalPath ( ) . startswith ( 'components/autofill/content/renderer/' ) and not f . LocalPath ( ) . endswith ( "PRESUBMIT.py" ) ) : contents = input_api . ReadFile ( f ) if pattern . search ( contents ) : files . append ( f ) if len ( files ) : return [ output_api . PresubmitPromptWarning ( 'Consider to not call IsPasswordField() or FormControlType() directly ' + 'but use IsPasswordFieldForAutofill() and FormControlTypeForAutofill() ' + 'respectively. These declare text input fields as password fields ' + 'if they have been password fields in the past. This is relevant ' + 'for websites that allow to reveal passwords with a button that ' + 'triggers a change of the type attribute of an <input> element.' , files ) ] return [ ]
Checks that no files call IsPasswordField() or FormControlType().
Checks that no files call IsPasswordField () or FormControlType () .
"""Checks that no files call IsPasswordField() or FormControlType()."""
input_api
output_api