blob: 7772b207030a7ffbbc24455842521a6ccac3b965 [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{%- if js_bindings_mode == "both" or js_bindings_mode == "new" %}
{{"new"|set_current_mode}}
'use strict';
{%- if js_bindings_mode == "both" %}
if ((typeof mojo !== 'undefined') && mojo.internal && mojo.config) {
{%- endif %}
(function() {
var mojomId = '{{module.path}}';
if (mojo.internal.isMojomLoaded(mojomId)) {
console.warn('The following mojom is loaded multiple times: ' + mojomId);
return;
}
mojo.internal.markMojomLoaded(mojomId);
// TODO(yzshen): Define these aliases to minimize the differences between the
// old/new modes. Remove them when the old mode goes away.
var bindings = mojo;
var associatedBindings = mojo;
var codec = mojo.internal;
var validator = mojo.internal;
var exports = mojo.internal.exposeNamespace('{{module.namespace}}');
{%- for import in imports %}
var {{import.unique_name}} =
mojo.internal.exposeNamespace('{{import.namespace}}');
if (mojo.config.autoLoadMojomDeps) {
mojo.internal.loadMojomIfNecessary(
'{{import.path}}',
new URL('{{import|get_relative_url(module)}}.js',
document.currentScript.src).href);
}
{%- endfor %}
{% include "module_definition.tmpl" %}
})();
{%- if js_bindings_mode == "both" %}
}
{%- endif %}
{%- endif %}
{%- if js_bindings_mode == "both" or js_bindings_mode == "old" %}
{{"old"|set_current_mode}}
{%- if js_bindings_mode == "both" %}
if ((typeof mojo === 'undefined') || !mojo.internal || !mojo.config) {
{%- endif %}
define("{{module.path}}", [
{%- if module.path !=
"mojo/public/interfaces/bindings/interface_control_messages.mojom" and
module.path !=
"mojo/public/interfaces/bindings/pipe_control_messages.mojom" %}
"mojo/public/js/associated_bindings",
"mojo/public/js/bindings",
{%- endif %}
"mojo/public/js/codec",
"mojo/public/js/core",
"mojo/public/js/validator",
{%- for import in imports %}
"{{import.path}}",
{%- endfor %}
], function(
{%- if module.path !=
"mojo/public/interfaces/bindings/interface_control_messages.mojom" and
module.path !=
"mojo/public/interfaces/bindings/pipe_control_messages.mojom" -%}
associatedBindings, bindings, {% endif -%}
codec, core, validator
{%- for import in imports -%}
, {{import.unique_name}}
{%- endfor -%}
) {
var exports = {};
{%- include "module_definition.tmpl" %}
return exports;
});
{%- if js_bindings_mode == "both" %}
}
{%- endif %}
{%- endif %}