| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 from string import Template | 5 from string import Template |
| 6 | 6 |
| 7 import optparse | 7 import optparse |
| 8 import os | 8 import os |
| 9 import sys | 9 import sys |
| 10 | 10 |
| 11 try: | 11 try: |
| 12 grit_module_path = os.path.join( | 12 grit_module_path = os.path.join( |
| 13 os.path.dirname(__file__), '..', '..', '..', 'tools', 'grit') | 13 os.path.dirname(__file__), '..', '..', 'tools', 'grit') |
| 14 sys.path.insert(0, grit_module_path) | 14 sys.path.insert(0, grit_module_path) |
| 15 from grit.format import data_pack as DataPack | 15 from grit.format import data_pack as DataPack |
| 16 except ImportError, e: | 16 except ImportError, e: |
| 17 print 'ImportError: ', e | 17 print 'ImportError: ', e |
| 18 sys.exit(-1) | 18 sys.exit(-1) |
| 19 | 19 |
| 20 header_template = \ | 20 header_template = \ |
| 21 """// Copyright 2015 The Chromium Authors. All rights reserved. | 21 """// Copyright 2015 The Chromium Authors. All rights reserved. |
| 22 // Use of this source code is governed by a BSD-style license that can be | 22 // Use of this source code is governed by a BSD-style license that can be |
| 23 // found in the LICENSE file. | 23 // found in the LICENSE file. |
| 24 | 24 |
| 25 #ifndef MOJO_SERVICES_HTML_VIEWER_BLINK_RESOURCE_MAP_H_ | 25 #ifndef COMPONENTS_HTML_VIEWER_BLINK_RESOURCE_MAP_H_ |
| 26 #define MOJO_SERVICES_HTML_VIEWER_BLINK_RESOURCE_MAP_H_ | 26 #define COMPONENTS_HTML_VIEWER_BLINK_RESOURCE_MAP_H_ |
| 27 | 27 |
| 28 #include <map> | 28 #include <map> |
| 29 | 29 |
| 30 namespace html_viewer { | 30 namespace html_viewer { |
| 31 | 31 |
| 32 class BlinkResourceMap { | 32 class BlinkResourceMap { |
| 33 public: | 33 public: |
| 34 BlinkResourceMap(); | 34 BlinkResourceMap(); |
| 35 const unsigned char* GetResource(int id, int* length); | 35 const unsigned char* GetResource(int id, int* length); |
| 36 | 36 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 47 ResourceEntry(const unsigned char* data, int length) | 47 ResourceEntry(const unsigned char* data, int length) |
| 48 : data(data) | 48 : data(data) |
| 49 , length(length) { | 49 , length(length) { |
| 50 } | 50 } |
| 51 }; | 51 }; |
| 52 typedef std::map<int, ResourceEntry> ResourceMap; | 52 typedef std::map<int, ResourceEntry> ResourceMap; |
| 53 ResourceMap resources_; | 53 ResourceMap resources_; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace html_viewer | 56 } // namespace html_viewer |
| 57 #endif // MOJO_SERVICES_HTML_VIEWER_BLINK_RESOURCE_MAP_H_""" | 57 #endif // COMPONENTS_HTML_VIEWER_BLINK_RESOURCE_MAP_H_""" |
| 58 | 58 |
| 59 cpp_template = \ | 59 cpp_template = \ |
| 60 """// Copyright 2015 The Chromium Authors. All rights reserved. | 60 """// Copyright 2015 The Chromium Authors. All rights reserved. |
| 61 // Use of this source code is governed by a BSD-style license that can be | 61 // Use of this source code is governed by a BSD-style license that can be |
| 62 // found in the LICENSE file. | 62 // found in the LICENSE file. |
| 63 | 63 |
| 64 #include "$header_file_name" | 64 #include "$header_file_name" |
| 65 | 65 |
| 66 #include "base/macros.h" | 66 #include "base/macros.h" |
| 67 | 67 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 137 |
| 138 cpp_contents['definitions']= '\n'.join(definitions) | 138 cpp_contents['definitions']= '\n'.join(definitions) |
| 139 cpp_contents['header_file_name'] = os.path.basename(options.header_file) | 139 cpp_contents['header_file_name'] = os.path.basename(options.header_file) |
| 140 cpp_contents['map_initializer'] = '\n '.join(map_initializer) | 140 cpp_contents['map_initializer'] = '\n '.join(map_initializer) |
| 141 cpp_file_contents = Template(cpp_template).substitute(cpp_contents) | 141 cpp_file_contents = Template(cpp_template).substitute(cpp_contents) |
| 142 cpp_file.write(cpp_file_contents) | 142 cpp_file.write(cpp_file_contents) |
| 143 cpp_file.close() | 143 cpp_file.close() |
| 144 | 144 |
| 145 if __name__ == '__main__': | 145 if __name__ == '__main__': |
| 146 main() | 146 main() |
| OLD | NEW |