| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 """Check to see if the ShouldAllowOpenURLFailureScheme enum in histograms.xml | 5 """Check to see if the ShouldAllowOpenURLFailureScheme enum in histograms.xml |
| 6 needs to be updated. This can be called from a chromium PRESUBMIT.py to ensure | 6 needs to be updated. This can be called from a chromium PRESUBMIT.py to ensure |
| 7 updates to the enum in chrome_content_browser_client_extensions_part.cc also | 7 updates to the enum in chrome_content_browser_client_extensions_part.cc also |
| 8 include the generated changes to histograms.xml. | 8 include the generated changes to histograms.xml. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import update_histogram_enum | 11 import update_histogram_enum |
| 12 | 12 |
| 13 def PrecheckShouldAllowOpenURLEnums(input_api, output_api): | 13 def PrecheckShouldAllowOpenURLEnums(input_api, output_api): |
| 14 source_file = 'chrome/browser/extensions/' \ | 14 source_file = 'chrome/browser/extensions/' \ |
| 15 'chrome_content_browser_client_extensions_part.cc' | 15 'chrome_content_browser_client_extensions_part.cc' |
| 16 | 16 |
| 17 affected_files = (f.LocalPath() for f in input_api.AffectedFiles()) | 17 affected_files = (f.LocalPath() for f in input_api.AffectedFiles()) |
| 18 if source_file not in affected_files: | 18 if source_file not in affected_files: |
| 19 return [] | 19 return [] |
| 20 | 20 |
| 21 if update_histogram_enum.HistogramNeedsUpdate( | 21 presubmit_error = update_histogram_enum.CheckPresubmitErrors( |
| 22 histogram_enum_name='ShouldAllowOpenURLFailureScheme', | 22 histogram_enum_name='ShouldAllowOpenURLFailureScheme', |
| 23 update_script_name='update_should_allow_open_url_histograms.py', |
| 23 source_enum_path=source_file, | 24 source_enum_path=source_file, |
| 24 start_marker='^enum ShouldAllowOpenURLFailureScheme {', | 25 start_marker='^enum ShouldAllowOpenURLFailureScheme {', |
| 25 end_marker='^SCHEME_LAST'): | 26 end_marker='^SCHEME_LAST') |
| 26 return [output_api.PresubmitPromptWarning( | 27 if presubmit_error: |
| 27 'ShouldAllowOpenURLFailureScheme has been updated but histogram.xml ' | 28 return [output_api.PresubmitPromptWarning(presubmit_error, |
| 28 'does not appear to be updated.\nPlease run:\n' | 29 items=[source_file])] |
| 29 ' python tools/metrics/histograms/' | |
| 30 'update_should_allow_open_url_histograms.py\n')] | |
| 31 return [] | 30 return [] |
| OLD | NEW |