| 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 js_bindings_mode == "both" or js_bindings_mode == "new" %} |
| 6 {{"new"|set_current_mode}} |
| 6 | 7 |
| 7 'use strict'; | 8 'use strict'; |
| 8 | 9 |
| 10 {%- if js_bindings_mode == "both" %} |
| 11 if (mojo && mojo.internal && mojo.config) { |
| 12 {%- endif %} |
| 13 |
| 9 (function() { | 14 (function() { |
| 10 var mojomId = '{{module.path}}'; | 15 var mojomId = '{{module.path}}'; |
| 11 if (mojo.internal.isMojomLoaded(mojomId)) { | 16 if (mojo.internal.isMojomLoaded(mojomId)) { |
| 12 console.warn('The following mojom is loaded multiple times: ' + mojomId); | 17 console.warn('The following mojom is loaded multiple times: ' + mojomId); |
| 13 return; | 18 return; |
| 14 } | 19 } |
| 15 mojo.internal.markMojomLoaded(mojomId); | 20 mojo.internal.markMojomLoaded(mojomId); |
| 16 | 21 |
| 17 // TODO(yzshen): Define these aliases to minimize the differences between the | 22 // TODO(yzshen): Define these aliases to minimize the differences between the |
| 18 // old/new modes. Remove them when the old mode goes away. | 23 // old/new modes. Remove them when the old mode goes away. |
| 19 var bindings = mojo; | 24 var bindings = mojo; |
| 20 var associatedBindings = mojo; | 25 var associatedBindings = mojo; |
| 21 var codec = mojo.internal; | 26 var codec = mojo.internal; |
| 22 var validator = mojo.internal; | 27 var validator = mojo.internal; |
| 23 | 28 |
| 24 {%- for import in imports %} | 29 {%- for import in imports %} |
| 25 var {{import.unique_name}} = | 30 var {{import.unique_name}} = |
| 26 mojo.internal.exposeNamespace('{{import.namespace}}'); | 31 mojo.internal.exposeNamespace('{{import.namespace}}'); |
| 27 if (mojo.config.autoLoadMojomDeps) { | 32 if (mojo.config.autoLoadMojomDeps) { |
| 28 mojo.internal.loadMojomIfNecessary( | 33 mojo.internal.loadMojomIfNecessary( |
| 29 '{{import.path}}', | 34 '{{import.path}}', |
| 30 new URL('{{import|get_relative_url(module)}}.js', | 35 new URL('{{import|get_relative_url(module)}}.js', |
| 31 document.currentScript.src).href); | 36 document.currentScript.src).href); |
| 32 } | 37 } |
| 33 {%- endfor %} | 38 {%- endfor %} |
| 34 | 39 |
| 35 {% include "module_definition.tmpl" %} | 40 {% include "module_definition.tmpl" %} |
| 36 })(); | 41 })(); |
| 37 | 42 |
| 38 {%- else %} | 43 {%- if js_bindings_mode == "both" %} |
| 44 } |
| 45 {%- endif %} |
| 46 |
| 47 {%- endif %} |
| 48 |
| 49 {%- if js_bindings_mode == "both" or js_bindings_mode == "old" %} |
| 50 {{"old"|set_current_mode}} |
| 51 |
| 52 {%- if js_bindings_mode == "both" %} |
| 53 if (!mojo || !mojo.internal || !mojo.config) { |
| 54 {%- endif %} |
| 39 | 55 |
| 40 define("{{module.path}}", [ | 56 define("{{module.path}}", [ |
| 41 {%- if module.path != | 57 {%- if module.path != |
| 42 "mojo/public/interfaces/bindings/interface_control_messages.mojom" and | 58 "mojo/public/interfaces/bindings/interface_control_messages.mojom" and |
| 43 module.path != | 59 module.path != |
| 44 "mojo/public/interfaces/bindings/pipe_control_messages.mojom" %} | 60 "mojo/public/interfaces/bindings/pipe_control_messages.mojom" %} |
| 45 "mojo/public/js/associated_bindings", | 61 "mojo/public/js/associated_bindings", |
| 46 "mojo/public/js/bindings", | 62 "mojo/public/js/bindings", |
| 47 {%- endif %} | 63 {%- endif %} |
| 48 "mojo/public/js/codec", | 64 "mojo/public/js/codec", |
| (...skipping 12 matching lines...) Expand all Loading... |
| 61 {%- for import in imports -%} | 77 {%- for import in imports -%} |
| 62 , {{import.unique_name}} | 78 , {{import.unique_name}} |
| 63 {%- endfor -%} | 79 {%- endfor -%} |
| 64 ) { | 80 ) { |
| 65 | 81 |
| 66 {%- include "module_definition.tmpl" %} | 82 {%- include "module_definition.tmpl" %} |
| 67 | 83 |
| 68 return exports; | 84 return exports; |
| 69 }); | 85 }); |
| 70 | 86 |
| 87 {%- if js_bindings_mode == "both" %} |
| 88 } |
| 89 {%- endif %} |
| 90 |
| 71 {%- endif %} | 91 {%- endif %} |
| OLD | NEW |