summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhansmuller <hansmuller@chromium.org>2014-10-07 10:03:47 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-07 17:04:10 +0000
commit39b01de0b16d731ce3fe33d0f7f5a0973d98729f (patch)
tree33f226ab6456fc47b47fb5c2c4660179d9c36988
parent4e85c87d5af985dce6c9d3b3cda865e818adac76 (diff)
downloadchromium_src-39b01de0b16d731ce3fe33d0f7f5a0973d98729f.zip
chromium_src-39b01de0b16d731ce3fe33d0f7f5a0973d98729f.tar.gz
chromium_src-39b01de0b16d731ce3fe33d0f7f5a0973d98729f.tar.bz2
Mojo JS bindings: simplify mojo.connectToService() usage - Part 1
This is an incremental step towards the goals listed in crbug.com/419160 The Mojo JS bindings now export an object for each interface. The object itemizes the interface values needed at runtime. Here's an example: exports.Service = { name: 'sample::Service', proxyClass: ServiceProxy, stubClass: ServiceStub, validateRequest: validateServiceRequest, validateResponse: null, }; I've removed the individual exports of the proxy and stub class names as well as the interface "NAME_" property that was added to proxy and stub classes. When possible, the object for an interface's client is added. For example: exports.Service.client = exports.ServiceClient; The next step (next patch) will automatically create a stub client object that delegates to a user supplied object. BUG=419160 Review URL: https://codereview.chromium.org/628763002 Cr-Commit-Position: refs/heads/master@{#298509}
-rw-r--r--chrome/browser/resources/omnibox/omnibox.js7
-rw-r--r--content/test/data/web_ui_mojo.js7
-rw-r--r--extensions/renderer/resources/data_receiver.js4
-rw-r--r--extensions/renderer/resources/data_sender.js4
-rw-r--r--extensions/renderer/resources/serial_service.js7
-rw-r--r--extensions/test/data/data_receiver_unittest.js2
-rw-r--r--extensions/test/data/data_sender_unittest.js2
-rw-r--r--mojo/apps/js/bindings/connection_unittests.js27
-rw-r--r--mojo/apps/js/bindings/sample_service_unittests.js8
-rw-r--r--mojo/apps/js/main.js21
-rw-r--r--mojo/apps/js/test/js_to_cpp_unittest.js5
-rw-r--r--mojo/public/interfaces/bindings/tests/test_structs.mojom26
-rw-r--r--mojo/public/js/bindings/connection.js1
-rw-r--r--mojo/public/js/bindings/struct_unittests.js22
-rw-r--r--mojo/public/js/bindings/validation_unittests.js8
-rw-r--r--mojo/public/tools/bindings/generators/js_templates/enum_definition.tmpl3
-rw-r--r--mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl40
-rw-r--r--mojo/public/tools/bindings/generators/js_templates/module.js.tmpl10
-rw-r--r--mojo/public/tools/bindings/generators/js_templates/struct_definition.tmpl2
-rw-r--r--ui/keyboard/resources/keyboard_mojo.js7
20 files changed, 139 insertions, 74 deletions
diff --git a/chrome/browser/resources/omnibox/omnibox.js b/chrome/browser/resources/omnibox/omnibox.js
index 3e570c7..89f9dd9 100644
--- a/chrome/browser/resources/omnibox/omnibox.js
+++ b/chrome/browser/resources/omnibox/omnibox.js
@@ -426,7 +426,7 @@ define('main', [
}
OmniboxPageImpl.prototype =
- Object.create(browser.OmniboxPageStub.prototype);
+ Object.create(browser.OmniboxPage.stubClass.prototype);
OmniboxPageImpl.prototype.handleNewAutocompleteResult = function(result) {
progressiveAutocompleteResults.push(result);
@@ -435,10 +435,9 @@ define('main', [
return function() {
connection = new connector.Connection(
- // TODO(sammc): Avoid using NAME_ directly.
serviceProvider.connectToService(
- browser.OmniboxUIHandlerMojoProxy.NAME_),
+ browser.OmniboxUIHandlerMojo.name),
OmniboxPageImpl,
- browser.OmniboxUIHandlerMojoProxy);
+ browser.OmniboxUIHandlerMojo.proxyClass);
};
});
diff --git a/content/test/data/web_ui_mojo.js b/content/test/data/web_ui_mojo.js
index 7289c66..cac2eb7 100644
--- a/content/test/data/web_ui_mojo.js
+++ b/content/test/data/web_ui_mojo.js
@@ -18,7 +18,7 @@ define('main', [
// the client side of the interface. Since JS is loosely typed, we do not need
// a separate base class to inherit from to receive callbacks.
RendererTargetTest.prototype =
- Object.create(bindings.RendererTargetStub.prototype);
+ Object.create(bindings.RendererTarget.stubClass.prototype);
RendererTargetTest.prototype.ping = function () {
this.bindings_.pingResponse();
@@ -26,9 +26,8 @@ define('main', [
return function() {
retainedConnection = new connection.Connection(
- // TODO(sammc): Avoid using NAME_ directly.
- serviceProvider.connectToService(bindings.BrowserTargetProxy.NAME_),
+ serviceProvider.connectToService(bindings.BrowserTarget.name),
RendererTargetTest,
- bindings.BrowserTargetProxy);
+ bindings.BrowserTarget.proxyClass);
};
});
diff --git a/extensions/renderer/resources/data_receiver.js b/extensions/renderer/resources/data_receiver.js
index 38d0567..b4fc543 100644
--- a/extensions/renderer/resources/data_receiver.js
+++ b/extensions/renderer/resources/data_receiver.js
@@ -107,7 +107,7 @@ define('data_receiver', [
}
DataReceiver.prototype =
- $Object.create(dataStream.DataSourceClientStub.prototype);
+ $Object.create(dataStream.DataSourceClient.stubClass.prototype);
/**
* Closes this DataReceiver.
@@ -154,7 +154,7 @@ define('data_receiver', [
* The connection to the DataSource.
* @private
*/
- this.source_ = new dataStream.DataSourceProxy(this.router_);
+ this.source_ = new dataStream.DataSource.proxyClass(this.router_);
this.router_.setIncomingReceiver(this);
/**
* The handle to the data pipe to use for receiving data.
diff --git a/extensions/renderer/resources/data_sender.js b/extensions/renderer/resources/data_sender.js
index b95cd0b..63c97c0 100644
--- a/extensions/renderer/resources/data_sender.js
+++ b/extensions/renderer/resources/data_sender.js
@@ -182,7 +182,7 @@ define('data_sender', [
}
DataSender.prototype =
- $Object.create(dataStreamMojom.DataSinkClientStub.prototype);
+ $Object.create(dataStreamMojom.DataSinkClient.stubClass.prototype);
/**
* Closes this DataSender.
@@ -242,7 +242,7 @@ define('data_sender', [
* The connection to the DataSink.
* @private
*/
- this.sink_ = new dataStreamMojom.DataSinkProxy(this.router_);
+ this.sink_ = new dataStreamMojom.DataSink.proxyClass(this.router_);
this.router_.setIncomingReceiver(this);
/**
* The async waiter used to wait for
diff --git a/extensions/renderer/resources/serial_service.js b/extensions/renderer/resources/serial_service.js
index aa53eb4..6d57cee 100644
--- a/extensions/renderer/resources/serial_service.js
+++ b/extensions/renderer/resources/serial_service.js
@@ -26,8 +26,9 @@ define('serial_service', [
* Mojo types.
*/
- var service = new serialMojom.SerialServiceProxy(new routerModule.Router(
- serviceProvider.connectToService(serialMojom.SerialServiceProxy.NAME_)));
+ var service = new serialMojom.SerialService.proxyClass(
+ new routerModule.Router(
+ serviceProvider.connectToService(serialMojom.SerialService.name)));
function getDevices() {
return service.getDevices().then(function(response) {
@@ -193,7 +194,7 @@ define('serial_service', [
sendPipe.handle0,
receivePipe.handle0);
var router = new routerModule.Router(pipe.handle1);
- var connection = new serialMojom.ConnectionProxy(router);
+ var connection = new serialMojom.Connection.proxyClass(router);
return connection.getInfo().then(convertServiceInfo).then(function(info) {
return Promise.all([info, allocateConnectionId()]);
}).catch(function(e) {
diff --git a/extensions/test/data/data_receiver_unittest.js b/extensions/test/data/data_receiver_unittest.js
index d47b581..e4fad3e 100644
--- a/extensions/test/data/data_receiver_unittest.js
+++ b/extensions/test/data/data_receiver_unittest.js
@@ -21,7 +21,7 @@ function createReceiver() {
var dataReceiver = modules[1];
var dataStream = modules[2];
return new dataReceiver.DataReceiver(
- serviceProvider.connectToService(dataStream.DataSourceProxy.NAME_),
+ serviceProvider.connectToService(dataStream.DataSource.name),
BUFFER_SIZE,
FATAL_ERROR);
});
diff --git a/extensions/test/data/data_sender_unittest.js b/extensions/test/data/data_sender_unittest.js
index 46db710..0b6a5cf 100644
--- a/extensions/test/data/data_sender_unittest.js
+++ b/extensions/test/data/data_sender_unittest.js
@@ -32,7 +32,7 @@ function createSender() {
var dataSender = modules[1];
var dataStream = modules[2];
return new dataSender.DataSender(
- serviceProvider.connectToService(dataStream.DataSinkProxy.NAME_),
+ serviceProvider.connectToService(dataStream.DataSink.name),
BUFFER_SIZE,
FATAL_ERROR);
});
diff --git a/mojo/apps/js/bindings/connection_unittests.js b/mojo/apps/js/bindings/connection_unittests.js
index 0b0a71b..258192d 100644
--- a/mojo/apps/js/bindings/connection_unittests.js
+++ b/mojo/apps/js/bindings/connection_unittests.js
@@ -85,13 +85,14 @@ define([
var receivedFrobinate = false;
var receivedDidFrobinate = false;
- // ServiceImpl -------------------------------------------------------------
+ // ServiceImpl ------------------------------------------------------------
function ServiceImpl(peer) {
this.peer = peer;
}
- ServiceImpl.prototype = Object.create(sample_service.ServiceStub.prototype);
+ ServiceImpl.prototype = Object.create(
+ sample_service.Service.stubClass.prototype);
ServiceImpl.prototype.frobinate = function(foo, baz, port) {
receivedFrobinate = true;
@@ -103,14 +104,14 @@ define([
this.peer.didFrobinate(42);
};
- // ServiceImpl -------------------------------------------------------------
+ // ServiceClientImpl ------------------------------------------------------
function ServiceClientImpl(peer) {
this.peer = peer;
}
ServiceClientImpl.prototype =
- Object.create(sample_service.ServiceClientStub.prototype);
+ Object.create(sample_service.ServiceClient.stubClass.prototype);
ServiceClientImpl.prototype.didFrobinate = function(result) {
receivedDidFrobinate = true;
@@ -123,10 +124,10 @@ define([
var sourcePipe = core.createMessagePipe();
var connection0 = new connection.Connection(
- pipe.handle0, ServiceImpl, sample_service.ServiceClientProxy);
+ pipe.handle0, ServiceImpl, sample_service.ServiceClient.proxyClass);
var connection1 = new connection.Connection(
- pipe.handle1, ServiceClientImpl, sample_service.ServiceProxy);
+ pipe.handle1, ServiceClientImpl, sample_service.Service.proxyClass);
var foo = new sample_service.Foo();
foo.bar = new sample_service.Bar();
@@ -163,7 +164,7 @@ define([
var pipe = core.createMessagePipe();
var connection1 = new connection.Connection(
- pipe.handle1, function() {}, sample_service.ServiceProxy);
+ pipe.handle1, function() {}, sample_service.Service.proxyClass);
// Close the other end of the pipe.
core.close(pipe.handle0);
@@ -196,7 +197,7 @@ define([
}
ProviderImpl.prototype =
- Object.create(sample_interfaces.ProviderStub.prototype);
+ Object.create(sample_interfaces.Provider.stubClass.prototype);
ProviderImpl.prototype.echoString = function(a) {
mockSupport.queuePump(core.RESULT_OK);
@@ -215,15 +216,19 @@ define([
}
ProviderClientImpl.prototype =
- Object.create(sample_interfaces.ProviderClientStub.prototype);
+ Object.create(sample_interfaces.ProviderClient.stubClass.prototype);
var pipe = core.createMessagePipe();
var connection0 = new connection.Connection(
- pipe.handle0, ProviderImpl, sample_interfaces.ProviderClientProxy);
+ pipe.handle0,
+ ProviderImpl,
+ sample_interfaces.ProviderClient.proxyClass);
var connection1 = new connection.Connection(
- pipe.handle1, ProviderClientImpl, sample_interfaces.ProviderProxy);
+ pipe.handle1,
+ ProviderClientImpl,
+ sample_interfaces.Provider.proxyClass);
var origReadMessage = core.readMessage;
// echoString
diff --git a/mojo/apps/js/bindings/sample_service_unittests.js b/mojo/apps/js/bindings/sample_service_unittests.js
index 2b8c31c..8030f44 100644
--- a/mojo/apps/js/bindings/sample_service_unittests.js
+++ b/mojo/apps/js/bindings/sample_service_unittests.js
@@ -133,11 +133,11 @@ define([
function ServiceImpl() {
}
- ServiceImpl.prototype = Object.create(sample.ServiceStub.prototype);
+ ServiceImpl.prototype = Object.create(sample.Service.stubClass.prototype);
ServiceImpl.prototype.frobinate = function(foo, baz, port) {
checkFoo(foo);
- expect(baz).toBe(sample.ServiceStub.BazOptions.EXTRA);
+ expect(baz).toBe(sample.Service.BazOptions.EXTRA);
expect(port).toBe(10);
global.result = "PASS";
};
@@ -156,7 +156,7 @@ define([
};
var receiver = new SimpleMessageReceiver();
- var serviceProxy = new sample.ServiceProxy(receiver);
+ var serviceProxy = new sample.Service.proxyClass(receiver);
checkDefaultValues();
@@ -164,5 +164,5 @@ define([
checkFoo(foo);
var port = 10;
- serviceProxy.frobinate(foo, sample.ServiceProxy.BazOptions.EXTRA, port);
+ serviceProxy.frobinate(foo, sample.Service.BazOptions.EXTRA, port);
});
diff --git a/mojo/apps/js/main.js b/mojo/apps/js/main.js
index c8eaac5..e2562cf 100644
--- a/mojo/apps/js/main.js
+++ b/mojo/apps/js/main.js
@@ -22,19 +22,24 @@ define("test", [
], function(core, connection, support, net, loader, mojo, console) {
var netServiceHandle = mojo.connectToService(
- "mojo:mojo_network_service", "mojo::NetworkService");
+ "mojo:mojo_network_service", net.NetworkService.name);
var netConnection = new connection.Connection(
- netServiceHandle, net.NetworkServiceStub, net.NetworkServiceProxy);
+ netServiceHandle,
+ net.NetworkService.stubClass,
+ net.NetworkService.proxyClass);
- var urlLoaderPipe = new core.createMessagePipe();
+ var urlLoaderPipe = core.createMessagePipe();
netConnection.remote.createURLLoader(urlLoaderPipe.handle1);
var urlLoaderConnection = new connection.Connection(
- urlLoaderPipe.handle0, loader.URLLoaderStub, loader.URLLoaderProxy);
+ urlLoaderPipe.handle0,
+ loader.URLLoader.stubClass,
+ loader.URLLoader.proxyClass);
- var urlRequest = new loader.URLRequest();
- urlRequest.url = "http://www.cnn.com";
- urlRequest.method = "GET";
- urlRequest.auto_follow_redirects = true;
+ var urlRequest = new loader.URLRequest({
+ url: "http://www.cnn.com",
+ method: "GET",
+ auto_follow_redirects: true
+ });
var urlRequestPromise = urlLoaderConnection.remote.start(urlRequest);
urlRequestPromise.then(function(result) {
diff --git a/mojo/apps/js/test/js_to_cpp_unittest.js b/mojo/apps/js/test/js_to_cpp_unittest.js
index b1073c8..ed57603 100644
--- a/mojo/apps/js/test/js_to_cpp_unittest.js
+++ b/mojo/apps/js/test/js_to_cpp_unittest.js
@@ -24,7 +24,8 @@ define('mojo/apps/js/test/js_to_cpp_unittest', [
cppSide.startTest();
}
- JsSideConnection.prototype = Object.create(jsToCpp.JsSideStub.prototype);
+ JsSideConnection.prototype =
+ Object.create(jsToCpp.JsSide.stubClass.prototype);
JsSideConnection.prototype.ping = function (arg) {
this.cppSide_.pingResponse();
@@ -215,6 +216,6 @@ define('mojo/apps/js/test/js_to_cpp_unittest', [
sampleMessage[i] = 255 - i;
}
retainedConnection = new connection.Connection(handle, JsSideConnection,
- jsToCpp.CppSideProxy);
+ jsToCpp.CppSide.proxyClass);
};
});
diff --git a/mojo/public/interfaces/bindings/tests/test_structs.mojom b/mojo/public/interfaces/bindings/tests/test_structs.mojom
index d361da7..6af0086 100644
--- a/mojo/public/interfaces/bindings/tests/test_structs.mojom
+++ b/mojo/public/interfaces/bindings/tests/test_structs.mojom
@@ -82,4 +82,30 @@ struct DefaultFieldValues {
Rect? f16 = default;
};
+
+// Used to verify that the code generated for enum and const values defined
+// within a struct is correct. Assuming that a constant's value can be a literal
+// or another constant and that enum values can either be an integer constant or
+// another value from the same enum type.
+
+struct ScopedConstants {
+ const int32 TEN = 10;
+ const int32 ALSO_TEN = TEN;
+ enum EType {
+ E0,
+ E1,
+ E2 = 10,
+ E3 = E2,
+ E4,
+ };
+ const int32 TEN_TOO = EType.E2;
+ EType f0 = E0; // 0
+ EType f1 = E1; // 1
+ EType f2 = E2; // 10
+ EType f3 = E3; // 10
+ EType f4 = E4; // 11
+ int32 f5 = TEN;
+ int32 f6 = ALSO_TEN;
+};
+
}
diff --git a/mojo/public/js/bindings/connection.js b/mojo/public/js/bindings/connection.js
index 31cf2aa..01e33e9 100644
--- a/mojo/public/js/bindings/connection.js
+++ b/mojo/public/js/bindings/connection.js
@@ -16,6 +16,7 @@ define("mojo/public/js/bindings/connection", [
this.local = new localFactory(this.remote);
this.router_.setIncomingReceiver(this.local);
+ // Validate incoming messages: remote responses and local requests.
var validateRequest = localFactory.prototype.validator;
var validateResponse = remoteFactory.prototype.validator;
var payloadValidators = [];
diff --git a/mojo/public/js/bindings/struct_unittests.js b/mojo/public/js/bindings/struct_unittests.js
index b9948a9..2d7abe5 100644
--- a/mojo/public/js/bindings/struct_unittests.js
+++ b/mojo/public/js/bindings/struct_unittests.js
@@ -72,8 +72,30 @@ define([
expect(s.f16).toEqual(r);
}
+ function testScopedConstants() {
+ expect(testStructs.ScopedConstants.TEN).toEqual(10);
+ expect(testStructs.ScopedConstants.ALSO_TEN).toEqual(10);
+ expect(testStructs.ScopedConstants.TEN_TOO).toEqual(10);
+
+ expect(testStructs.ScopedConstants.EType.E0).toEqual(0);
+ expect(testStructs.ScopedConstants.EType.E1).toEqual(1);
+ expect(testStructs.ScopedConstants.EType.E2).toEqual(10);
+ expect(testStructs.ScopedConstants.EType.E3).toEqual(10);
+ expect(testStructs.ScopedConstants.EType.E4).toEqual(11);
+
+ var s = new testStructs.ScopedConstants();
+ expect(s.f0).toEqual(0);
+ expect(s.f1).toEqual(1);
+ expect(s.f2).toEqual(10);
+ expect(s.f3).toEqual(10);
+ expect(s.f4).toEqual(11);
+ expect(s.f5).toEqual(10);
+ expect(s.f6).toEqual(10);
+ }
+
testConstructors();
testNoDefaultFieldValues();
testDefaultFieldValues();
+ testScopedConstants();
this.result = "PASS";
}); \ No newline at end of file
diff --git a/mojo/public/js/bindings/validation_unittests.js b/mojo/public/js/bindings/validation_unittests.js
index 73fd9c7..59aeb59 100644
--- a/mojo/public/js/bindings/validation_unittests.js
+++ b/mojo/public/js/bindings/validation_unittests.js
@@ -246,12 +246,12 @@ define([
function testConformanceMessageValidation() {
testMessageValidation("conformance_", [
- testInterface.ConformanceTestInterfaceStub.prototype.validator]);
+ testInterface.ConformanceTestInterface.validateRequest]);
}
function testNotImplementedMessageValidation() {
testMessageValidation("not_implemented_", [
- testInterface.ConformanceTestInterfaceStub.prototype.validator]);
+ testInterface.ConformanceTestInterface.validateRequest]);
}
function testIntegratedMessageValidation() {
@@ -279,8 +279,8 @@ define([
var testConnection = new connection.TestConnection(
testMessagePipe.handle1,
- testInterface.IntegrationTestInterface1Stub,
- testInterface.IntegrationTestInterface2Proxy);
+ testInterface.IntegrationTestInterface1.stubClass,
+ testInterface.IntegrationTestInterface2.proxyClass);
var validationError = noError;
testConnection.router_.validationErrorHandler = function(err) {
diff --git a/mojo/public/tools/bindings/generators/js_templates/enum_definition.tmpl b/mojo/public/tools/bindings/generators/js_templates/enum_definition.tmpl
index 795116d..4ae0a9b 100644
--- a/mojo/public/tools/bindings/generators/js_templates/enum_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/enum_definition.tmpl
@@ -1,6 +1,5 @@
-{%- macro enum_def(enum_name, enum, module) -%}
+{%- macro enum_def(enum_name, enum) -%}
{{enum_name}} = {};
-
{%- set prev_enum = 0 %}
{%- for field in enum.fields %}
{%- if field.value %}
diff --git a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
index b41929c..391d375e 100644
--- a/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/interface_definition.tmpl
@@ -1,4 +1,3 @@
-{%- set namespace_as_string = namespace|replace(".","::") %}
{%- for method in interface.methods %}
var k{{interface.name}}_{{method.name}}_Name = {{method.ordinal}};
{%- endfor %}
@@ -7,8 +6,6 @@
this.receiver_ = receiver;
}
- {{interface.name}}Proxy.NAME_ = '{{namespace_as_string}}::{{interface.name}}';
-
{%- for method in interface.methods %}
{{interface.name}}Proxy.prototype.{{method.name|stylize_method}} = function(
{%- for parameter in method.parameters -%}
@@ -54,8 +51,6 @@
function {{interface.name}}Stub() {
}
- {{interface.name}}Stub.NAME_ = '{{namespace_as_string}}::{{interface.name}}';
-
{{interface.name}}Stub.prototype.accept = function(message) {
var reader = new codec.MessageReader(message);
switch (reader.messageName) {
@@ -157,22 +152,29 @@ params.{{parameter.name}}{% if not loop.last %}, {% endif -%}
{%- endif %}
}
+ var {{interface.name}} = {
+ name: '{{namespace|replace(".","::")}}::{{interface.name}}',
+ proxyClass: {{interface.name}}Proxy,
+ stubClass: {{interface.name}}Stub,
+ validateRequest: validate{{interface.name}}Request,
+{%- if interface|has_callbacks %}
+ validateResponse: validate{{interface.name}}Response,
+{%- else %}
+ validateResponse: null,
+{%- endif %}
+ };
+{#--- Interface Constants #}
+{%- for constant in interface.constants %}
+ {{interface.name}}.{{constant.name}} = {{constant.value|expression_to_text}},
+{%- endfor %}
+{#--- Interface Enums #}
+{%- from "enum_definition.tmpl" import enum_def -%}
+{%- for enum in interface.enums %}
+ {{ enum_def("%s.%s"|format(interface.name, enum.name), enum) }}
+{%- endfor %}
{{interface.name}}Stub.prototype.validator = validate{{interface.name}}Request;
{%- if interface|has_callbacks %}
{{interface.name}}Proxy.prototype.validator = validate{{interface.name}}Response;
{%- else %}
{{interface.name}}Proxy.prototype.validator = null;
-{%- endif -%}
-
-{#--- Enums #}
-{% from "enum_definition.tmpl" import enum_def -%}
-{% for enum in interface.enums %}
- {{enum_def("%sProxy.%s"|format(interface.name, enum.name), enum, module)}}
- {{interface.name}}Stub.{{enum.name}} = {{interface.name}}Proxy.{{enum.name}};
-{%- endfor %}
-
-{#--- Constants. #}
-{% for constant in interface.constants %}
- {{interface.name}}Proxy.{{constant.name}} = {{constant.value|expression_to_text}};
- {{interface.name}}Stub.{{constant.name}} = {{interface.name}}Proxy.{{constant.name}};
-{%- endfor %}
+{%- endif %}
diff --git a/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl b/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
index 93fa537..397a120 100644
--- a/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/module.js.tmpl
@@ -22,7 +22,7 @@ define("{{module.path}}", [
{#--- Enums #}
{%- from "enum_definition.tmpl" import enum_def %}
{%- for enum in enums %}
- var {{ enum_def(enum.name, enum, module) }}
+ var {{ enum_def(enum.name, enum) }}
{%- endfor %}
{#--- Struct definitions #}
@@ -46,8 +46,12 @@ define("{{module.path}}", [
exports.{{struct.name}} = {{struct.name}};
{%- endfor %}
{%- for interface in interfaces %}
- exports.{{interface.name}}Proxy = {{interface.name}}Proxy;
- exports.{{interface.name}}Stub = {{interface.name}}Stub;
+ exports.{{interface.name}} = {{interface.name}};
+{#--- Interface Client #}
+{%- if interface.client in interfaces|map(attribute='name') %}
+ exports.{{interface.name}}.client = {{interface.client}};
+{%- endif %}
{%- endfor %}
+
return exports;
});
diff --git a/mojo/public/tools/bindings/generators/js_templates/struct_definition.tmpl b/mojo/public/tools/bindings/generators/js_templates/struct_definition.tmpl
index d77b28b..c0d8793 100644
--- a/mojo/public/tools/bindings/generators/js_templates/struct_definition.tmpl
+++ b/mojo/public/tools/bindings/generators/js_templates/struct_definition.tmpl
@@ -7,7 +7,7 @@
{#--- Enums #}
{%- from "enum_definition.tmpl" import enum_def %}
{% for enum in struct.enums %}
- {{enum_def("%s.%s"|format(struct.name, enum.name), enum, module)}}
+ {{enum_def("%s.%s"|format(struct.name, enum.name), enum)}}
{%- endfor %}
{#--- Constants #}
diff --git a/ui/keyboard/resources/keyboard_mojo.js b/ui/keyboard/resources/keyboard_mojo.js
index eddf866..ea681c7 100644
--- a/ui/keyboard/resources/keyboard_mojo.js
+++ b/ui/keyboard/resources/keyboard_mojo.js
@@ -18,7 +18,8 @@ if (!chrome.virtualKeyboardPrivate) {
mojo_api = this;
}
- KeyboardImpl.prototype = Object.create(keyboard.KeyboardAPIStub.prototype);
+ KeyboardImpl.prototype = Object.create(
+ keyboard.KeyboardAPI.stubClass.prototype);
KeyboardImpl.prototype.onTextInputTypeChanged = function(input_type) {
console.log('Text input changed: ' + input_type);
@@ -30,9 +31,9 @@ if (!chrome.virtualKeyboardPrivate) {
return function() {
connection = new connector.Connection(
serviceProvider.connectToService(
- keyboard.KeyboardUIHandlerMojoProxy.NAME_),
+ keyboard.KeyboardUIHandlerMojo.name),
KeyboardImpl,
- keyboard.KeyboardUIHandlerMojoProxy);
+ keyboard.KeyboardUIHandlerMojo.proxyClass);
};
});