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