| 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 (mojoBindings.internal.isMojomLoaded(mojomId)) { | |
| 12 console.warn('The following mojom is loaded multiple times: ' + mojomId); | |
| 13 return; | |
| 14 } | |
| 15 mojoBindings.internal.markMojomLoaded(mojomId); | |
| 16 | |
| 17 // TODO(yzshen): Define these aliases to minimize the differences between the | 10 // TODO(yzshen): Define these aliases to minimize the differences between the |
| 18 // old/new modes. Remove them when the old mode goes away. | 11 // old/new modes. Remove them when the old mode goes away. |
| 19 var bindings = mojoBindings; | 12 var bindings = mojoBindings; |
| 20 var codec = mojoBindings.internal; | 13 var codec = mojoBindings.internal; |
| 21 var validator = mojoBindings.internal; | 14 var validator = mojoBindings.internal; |
| 22 | |
| 23 {%- for import in imports %} | 15 {%- for import in imports %} |
| 24 var {{import.unique_name}} = | 16 var {{import.unique_name}} = {{import.module.namespace}}; |
| 25 mojoBindings.internal.exposeNamespace('{{import.module.namespace}}'); | |
| 26 if (mojoBindings.config.autoLoadMojomDeps) { | |
| 27 mojoBindings.internal.loadMojomIfNecessary( | |
| 28 '{{import.module.path}}', | |
| 29 new URL( | |
| 30 '{{import.module|get_relative_path(module)}}.js', | |
| 31 document.currentScript.src).href); | |
| 32 } | |
| 33 {%- endfor %} | 17 {%- endfor %} |
| 34 | 18 |
| 35 {% include "module_definition.tmpl" %} | 19 {% include "module_definition.tmpl" %} |
| 36 })(); | 20 })(); |
| 37 | 21 |
| 38 {%- else %} | 22 {%- else %} |
| 39 | 23 |
| 40 define("{{module.path}}", [ | 24 define("{{module.path}}", [ |
| 41 {%- if module.path != "mojo/public/interfaces/bindings/interface_control_messa
ges.mojom" %} | 25 {%- if module.path != "mojo/public/interfaces/bindings/interface_control_messa
ges.mojom" %} |
| 42 "mojo/public/js/bindings", | 26 "mojo/public/js/bindings", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 54 {%- for import in imports -%} | 38 {%- for import in imports -%} |
| 55 , {{import.unique_name}} | 39 , {{import.unique_name}} |
| 56 {%- endfor -%} | 40 {%- endfor -%} |
| 57 ) { | 41 ) { |
| 58 | 42 |
| 59 {%- include "module_definition.tmpl" %} | 43 {%- include "module_definition.tmpl" %} |
| 60 | 44 |
| 61 return exports; | 45 return exports; |
| 62 }); | 46 }); |
| 63 | 47 |
| 64 {%- endif %} | 48 {%- endif %} |
| OLD | NEW |