Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / ui / PRESUBMIT.py
blob97d09319975ef01975ab1ef08e48a9f2fc6ae7c9
1 # Copyright 2015 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 """Presubmit script for ui.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools.
9 """
11 INCLUDE_CPP_FILES_ONLY = (
12 r'.*\.(cc|h|mm)$',
15 def CheckScopedPtr(input_api, output_api,
16 white_list=INCLUDE_CPP_FILES_ONLY, black_list=None):
17 black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
18 source_file_filter = lambda x: input_api.FilterSourceFile(x,
19 white_list,
20 black_list)
21 errors = []
22 for f in input_api.AffectedSourceFiles(source_file_filter):
23 for line_number, line in f.ChangedContents():
24 # Disallow:
25 # return scoped_ptr<T>(foo);
26 # bar = scoped_ptr<T>(foo);
27 # But allow:
28 # return scoped_ptr<T[]>(foo);
29 # bar = scoped_ptr<T[]>(foo);
30 if input_api.re.search(
31 r'(=|\breturn)\s*scoped_ptr<[^\[\]>]+>\([^)]+\)', line):
32 errors.append(output_api.PresubmitError(
33 ('%s:%d uses explicit scoped_ptr constructor. ' +
34 'Use make_scoped_ptr() instead.') % (f.LocalPath(), line_number)))
35 # Disallow:
36 # scoped_ptr<T>()
37 if input_api.re.search(r'\bscoped_ptr<.*?>\(\)', line):
38 errors.append(output_api.PresubmitError(
39 '%s:%d uses scoped_ptr<T>(). Use nullptr instead.' %
40 (f.LocalPath(), line_number)))
41 return errors
44 def CheckChange(input_api, output_api):
45 results = []
46 results += CheckScopedPtr(input_api, output_api)
47 return results
50 def CheckChangeOnUpload(input_api, output_api):
51 return CheckChange(input_api, output_api)
54 def CheckChangeOnCommit(input_api, output_api):
55 return CheckChange(input_api, output_api)