| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Presubmit script for Chromium browser code. | 5 """Presubmit script for Chromium browser code. |
| 6 | 6 |
| 7 This script currently checks HTML/CSS/JS files in resources/ and ui/webui/. | 7 This script currently checks HTML/CSS/JS files in resources/ and ui/webui/. |
| 8 | 8 |
| 9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 9 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 10 for more details about the presubmit API built into depot_tools, and see | 10 for more details about the presubmit API built into depot_tools, and see |
| 11 http://www.chromium.org/developers/web-development-style-guide for the rules | 11 http://www.chromium.org/developers/web-development-style-guide for the rules |
| 12 checked for here. | 12 checked for here. |
| 13 """ | 13 """ |
| 14 | 14 |
| 15 | |
| 16 def CheckChangeOnUpload(input_api, output_api): | 15 def CheckChangeOnUpload(input_api, output_api): |
| 17 return _CommonChecks(input_api, output_api) | 16 return _CommonChecks(input_api, output_api) |
| 18 | 17 |
| 19 | 18 |
| 20 def CheckChangeOnCommit(input_api, output_api): | 19 def CheckChangeOnCommit(input_api, output_api): |
| 21 return _CommonChecks(input_api, output_api) | 20 return _CommonChecks(input_api, output_api) |
| 22 | 21 |
| 23 def _RunHistogramChecks(input_api, output_api, histogram_name): | 22 def _RunHistogramChecks(input_api, output_api, histogram_name): |
| 24 try: | 23 try: |
| 25 # Setup sys.path so that we can call histrogram code | 24 # Setup sys.path so that we can call histrogram code |
| 26 import sys | 25 import sys |
| 27 original_sys_path = sys.path | 26 original_sys_path = sys.path |
| 28 sys.path = sys.path + [input_api.os_path.join( | 27 sys.path = sys.path + [input_api.os_path.join( |
| 29 input_api.change.RepositoryRoot(), | 28 input_api.change.RepositoryRoot(), |
| 30 'tools', 'metrics', 'histograms')] | 29 'tools', 'metrics', 'histograms')] |
| 31 | 30 |
| 31 results = [] |
| 32 |
| 32 import presubmit_bad_message_reasons | 33 import presubmit_bad_message_reasons |
| 33 return presubmit_bad_message_reasons.PrecheckBadMessage(input_api, | 34 results.extend(presubmit_bad_message_reasons.PrecheckBadMessage(input_api, |
| 34 output_api, histogram_name) | 35 output_api, histogram_name)) |
| 36 |
| 37 import presubmit_scheme_histograms |
| 38 results.extend(presubmit_scheme_histograms. |
| 39 PrecheckShouldAllowOpenURLEnums(input_api, output_api)) |
| 40 |
| 41 return results |
| 35 except: | 42 except: |
| 36 return [output_api.PresubmitError('Could not verify histogram!')] | 43 return [output_api.PresubmitError('Could not verify histogram!')] |
| 37 finally: | 44 finally: |
| 38 sys.path = original_sys_path | 45 sys.path = original_sys_path |
| 39 | 46 |
| 40 | 47 |
| 41 def _CommonChecks(input_api, output_api): | 48 def _CommonChecks(input_api, output_api): |
| 42 """Checks common to both upload and commit.""" | 49 """Checks common to both upload and commit.""" |
| 43 results = [] | 50 results = [] |
| 44 | 51 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 results.extend(html_checker.HtmlChecker( | 98 results.extend(html_checker.HtmlChecker( |
| 92 input_api, output_api, file_filter=is_resource).RunChecks()) | 99 input_api, output_api, file_filter=is_resource).RunChecks()) |
| 93 results.extend(js_checker.JSChecker( | 100 results.extend(js_checker.JSChecker( |
| 94 input_api, output_api, file_filter=is_resource).RunChecks()) | 101 input_api, output_api, file_filter=is_resource).RunChecks()) |
| 95 results.extend(_RunHistogramChecks(input_api, output_api, | 102 results.extend(_RunHistogramChecks(input_api, output_api, |
| 96 "BadMessageReasonChrome")) | 103 "BadMessageReasonChrome")) |
| 97 finally: | 104 finally: |
| 98 sys.path = old_path | 105 sys.path = old_path |
| 99 | 106 |
| 100 return results | 107 return results |
| OLD | NEW |