0

[mojo] Add presubmit warning for renderer-side GetInterfaceProvider

This change adds a warning for new uses of GetInterfaceProvider() and
suggests using GetBrowserInterfaceBroker() instead.

Bug: 718652
Change-Id: I2e99ba36a8cdb198200967d27a64931a32adcdc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1967759
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Oksana Zhuravlova <oksamyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726462}
This commit is contained in:
Oksana Zhuravlova
2019-12-19 19:21:16 +00:00
committed by Commit Bot
parent c4c470a3ad
commit c8222d2c5a
2 changed files with 20 additions and 4 deletions

@ -1080,6 +1080,16 @@ _BANNED_CPP_FUNCTIONS = (
r'^content/renderer/.*\.(cc|h)$',
),
),
(
'GetInterfaceProvider',
(
'InterfaceProvider is deprecated.',
'Please use ExecutionContext::GetBrowserInterfaceBroker and overrides',
'or Platform::GetBrowserInterfaceBroker.'
),
False,
(),
),
(
'CComPtr',
(

@ -1979,14 +1979,20 @@ class BannedTypeCheckTest(unittest.TestCase):
input_api.files = [
MockFile('some/cpp/problematic/file.cc',
['using namespace std;']),
MockFile('third_party/blink/problematic/file.cc',
['GetInterfaceProvider()']),
MockFile('some/cpp/ok/file.cc',
['using std::string;']),
]
errors = PRESUBMIT._CheckNoBannedFunctions(input_api, MockOutputApi())
self.assertEqual(1, len(errors))
self.assertTrue('some/cpp/problematic/file.c' in errors[0].message)
self.assertTrue('some/cpp/ok/file.cc' not in errors[0].message)
results = PRESUBMIT._CheckNoBannedFunctions(input_api, MockOutputApi())
# warnings are results[0], errors are results[1]
self.assertEqual(2, len(results))
self.assertTrue('some/cpp/problematic/file.cc' in results[1].message)
self.assertTrue(
'third_party/blink/problematic/file.cc' in results[0].message)
self.assertTrue('some/cpp/ok/file.cc' not in results[1].message)
def testBannedBlinkDowncastHelpers(self):
input_api = MockInputApi()