Merge html-office-public repo into src
[chromium-blink-merge.git] / chrome / test / chromedriver / embed_extension_in_cpp.py
blobd529650d5bfbdc2f243ea84f2d79093d4a20ee5e
1 #!/usr/bin/env python
2 # Copyright 2013 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 Chrome user data files in C++ code."""
8 import base64
9 import optparse
10 import os
11 import StringIO
12 import sys
13 import zipfile
15 import cpp_source
18 def main():
19 parser = optparse.OptionParser()
20 parser.add_option(
21 '', '--directory', type='string', default='.',
22 help='Path to directory where the cc/h file should be created')
23 options, args = parser.parse_args()
25 global_string_map = {}
26 string_buffer = StringIO.StringIO()
27 zipper = zipfile.ZipFile(string_buffer, 'w')
28 for f in args:
29 zipper.write(f, os.path.basename(f), zipfile.ZIP_STORED)
30 zipper.close()
31 global_string_map['kAutomationExtension'] = base64.b64encode(
32 string_buffer.getvalue())
33 string_buffer.close()
35 cpp_source.WriteSource('embedded_automation_extension',
36 'chrome/test/chromedriver/chrome',
37 options.directory, global_string_map)
40 if __name__ == '__main__':
41 sys.exit(main())