Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Unified Diff: examples/js/hello.js

Issue 757703002: Creates a JavaScript Applicaiton (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Changes per review feedback Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: examples/js/hello.js
diff --git a/examples/js/hello.js b/examples/js/hello.js
new file mode 100644
index 0000000000000000000000000000000000000000..92ac3e89798b60868aa21e05f84d64fbe16bf0bf
--- /dev/null
+++ b/examples/js/hello.js
@@ -0,0 +1,34 @@
+#!mojo:js_content_handler
+// Demonstrate one JS Mojo application connecting to another to emit "hello
+// world". To run this application with mojo_shell, set DIR to be the absolute
+// path for this directory, then:
+// mojo_shell "file://$DIR/hello.js file://$DIR/world.js"
+// Launches the Mojo hello.js application which connects to the application
+// URL specified as a Mojo application argument, world.js in this case.
+
+define("main", [
+ "console",
+ "mojo/public/interfaces/application/service_provider.mojom",
+], function(console, sp) {
+
+ function Application(shell, url) {
+ this.shell = shell;
+ console.log(url + ": Hello");
+ }
+
+ Application.prototype.initialize = function(args) {
+ if (args.length != 2) {
+ console.log("Expected hello.js URL argument");
+ return;
+ }
+ var serviceProvider = new sp.ServiceProvider.proxyClass();
+ // TODO(hansmuller): the following step shouldn't be necessary.
+ var handle = serviceProvider.getConnection$().messagePipeHandle;
+ this.shell.connectToApplication(args[1], handle);
+ }
+
+ Application.prototype.acceptConnection = function(url, serviceProvider) {
+ }
+
+ return Application;
+});
« no previous file with comments | « examples/js/README.md ('k') | examples/js/main.js » ('j') | services/js/js_app_shell.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698