Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / web_dev_style / html_checker.py
blob408ff909bd0cef2d3cfdc8cd7bb9b226c4d001dc
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """
6 Presubmit for Chromium HTML resources. See chrome/browser/PRESUBMIT.py.
7 """
9 import regex_check
12 class HtmlChecker(object):
13 def __init__(self, input_api, output_api, file_filter=None):
14 self.input_api = input_api
15 self.output_api = output_api
16 self.file_filter = file_filter
18 def LabelCheck(self, line_number, line):
19 return regex_check.RegexCheck(self.input_api.re, line_number, line,
20 r"(?:^|\s)(for=)",
21 "Avoid 'for' attribute on <label>. Place the input within the <label>, "
22 "or use aria-labelledby for <select>.")
24 def RunChecks(self):
25 """Check for violations of the Chromium web development style guide. See
26 http://chromium.org/developers/web-development-style-guide
27 """
28 results = []
30 affected_files = self.input_api.change.AffectedFiles(
31 file_filter=self.file_filter, include_deletes=False)
33 for f in affected_files:
34 errors = []
36 for line_number, line in f.ChangedContents():
37 error = self.LabelCheck(line_number, line)
38 if error:
39 errors.append(error)
41 if errors:
42 abs_local_path = f.AbsoluteLocalPath()
43 file_indicator = 'Found HTML style issues in %s' % abs_local_path
44 prompt_msg = file_indicator + '\n\n' + '\n'.join(errors) + '\n'
45 results.append(self.output_api.PresubmitPromptWarning(prompt_msg))
47 return results