1# Copyright 2013 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. 4 5"""Presubmit script for changes affecting chrome/app/ 6 7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 8for more details about the presubmit API built into gcl. 9""" 10 11import os 12 13def _CheckNoProductNameInGeneratedResources(input_api, output_api): 14 """Check that no PRODUCT_NAME placeholders are found in resources files. 15 16 These kinds of strings prevent proper localization in some languages. For 17 more information, see the following chromium-dev thread: 18 https://groups.google.com/a/chromium.org/forum/#!msg/chromium-dev/PBs5JfR0Aoc/NOcIHII9u14J 19 """ 20 21 problems = [] 22 filename_filter = lambda x: x.LocalPath().endswith('.grd') 23 24 for f, line_num, line in input_api.RightHandSideLines(filename_filter): 25 if 'PRODUCT_NAME' in line: 26 problems.append('%s:%d' % (f.LocalPath(), line_num)) 27 28 if problems: 29 return [output_api.PresubmitPromptWarning( 30 "Don't use PRODUCT_NAME placeholders in string resources. Instead, add " 31 "separate strings to google_chrome_strings.grd and " 32 "chromium_strings.grd. See http://goo.gl/6614MQ for more information." 33 "Problems with this check? Contact dubroy@chromium.org.", 34 items=problems)] 35 return [] 36 37def _CommonChecks(input_api, output_api): 38 """Checks common to both upload and commit.""" 39 results = [] 40 results.extend(_CheckNoProductNameInGeneratedResources(input_api, output_api)) 41 return results 42 43def CheckChangeOnUpload(input_api, output_api): 44 return _CommonChecks(input_api, output_api) 45 46def CheckChangeOnCommit(input_api, output_api): 47 return _CommonChecks(input_api, output_api) 48