2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Embeds standalone JavaScript snippets in C++ code.
8 The script requires the OverridesView file from WebKit that lists the known
9 mobile devices to be passed in as the only argument. The list of known devices
10 will be written to a C-style string to be parsed with JSONReader.
21 parser = optparse.OptionParser()
23 '', '--directory', type='string', default='.',
24 help='Path to directory where the cc/h files should be created')
25 options, args = parser.parse_args()
30 with open(file_name, 'r') as f:
33 if 'WebInspector.OverridesUI._phones = [' in line or \
34 'WebInspector.OverridesUI._tablets = [' in line:
37 if line.strip() == '];':
40 devices += line.strip()
43 cpp_source.WriteSource('mobile_device_list',
44 'chrome/test/chromedriver/chrome',
45 options.directory, {'kMobileDevices': devices})
48 if __name__ == '__main__':