OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 {%- if use_new_js_bindings %} | 5 {%- if use_new_js_bindings %} |
6 | 6 |
7 "use strict"; | 7 'use strict'; |
8 | 8 |
9 (function() { | 9 (function() { |
| 10 var mojomId = '{{module.path}}'; |
| 11 if (mojo.internal.isMojomLoaded(mojomId)) { |
| 12 console.warn('The following mojom is loaded multiple times: ' + mojomId); |
| 13 return; |
| 14 } |
| 15 mojo.internal.markMojomLoaded(mojomId); |
| 16 |
10 // TODO(yzshen): Define these aliases to minimize the differences between the | 17 // TODO(yzshen): Define these aliases to minimize the differences between the |
11 // old/new modes. Remove them when the old mode goes away. | 18 // old/new modes. Remove them when the old mode goes away. |
12 var bindings = mojo; | 19 var bindings = mojo; |
13 var codec = mojo.internal; | 20 var codec = mojo.internal; |
14 var validator = mojo.internal; | 21 var validator = mojo.internal; |
| 22 |
15 {%- for import in imports %} | 23 {%- for import in imports %} |
16 var {{import.unique_name}} = {{import.module.namespace}}; | 24 var {{import.unique_name}} = |
| 25 mojo.internal.exposeNamespace('{{import.module.namespace}}'); |
| 26 if (mojo.config.autoLoadMojomDeps) { |
| 27 mojo.internal.loadMojomIfNecessary( |
| 28 '{{import.module.path}}', |
| 29 new URL( |
| 30 '{{import.module|get_relative_path(module)}}.js', |
| 31 document.currentScript.src).href); |
| 32 } |
17 {%- endfor %} | 33 {%- endfor %} |
18 | 34 |
19 {% include "module_definition.tmpl" %} | 35 {% include "module_definition.tmpl" %} |
20 })(); | 36 })(); |
21 | 37 |
22 {%- else %} | 38 {%- else %} |
23 | 39 |
24 define("{{module.path}}", [ | 40 define("{{module.path}}", [ |
25 {%- if module.path != | 41 {%- if module.path != |
26 "mojo/public/interfaces/bindings/interface_control_messages.mojom" and | 42 "mojo/public/interfaces/bindings/interface_control_messages.mojom" and |
(...skipping 18 matching lines...) Expand all Loading... |
45 , {{import.unique_name}} | 61 , {{import.unique_name}} |
46 {%- endfor -%} | 62 {%- endfor -%} |
47 ) { | 63 ) { |
48 | 64 |
49 {%- include "module_definition.tmpl" %} | 65 {%- include "module_definition.tmpl" %} |
50 | 66 |
51 return exports; | 67 return exports; |
52 }); | 68 }); |
53 | 69 |
54 {%- endif %} | 70 {%- endif %} |
OLD | NEW |