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. 5 6 """Embeds Chrome user data files in C++ code.""" 7 8 import base64 9 import optparse 10 import os 11 import StringIO 12 import sys 13 import zipfile 14 15 import cpp_source 16 17 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() 24 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() 34 35 cpp_source.WriteSource('embedded_automation_extension', 36 'chrome/test/chromedriver/chrome', 37 options.directory, global_string_map) 38 39 40 if __name__ == '__main__': 41 sys.exit(main()) 42