| 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 define("mojo/services/public/js/application", [ | 5 define("mojo/services/public/js/application", [ |
| 6 "services/js/app_bridge", | 6 "services/js/app_bridge", |
| 7 "mojo/public/interfaces/application/service_provider.mojom", | |
| 8 "mojo/services/public/js/service_provider", | 7 "mojo/services/public/js/service_provider", |
| 9 "mojo/services/public/js/shell", | 8 "mojo/services/public/js/shell", |
| 10 ], function(appBridgeModule, spInterfaceModule, spModule, shellModule) { | 9 ], function(appBridge, serviceProvider, shell) { |
| 10 |
| 11 const ServiceProvider = serviceProvider.ServiceProvider; |
| 12 const Shell = shell.Shell; |
| 11 | 13 |
| 12 class Application { | 14 class Application { |
| 13 constructor(shellHandle, url) { | 15 constructor(shellHandle, url) { |
| 14 this.url = url; | 16 this.url = url; |
| 15 this.serviceProviders = []; | 17 this.serviceProviders = []; |
| 16 this.shellHandle_ = shellHandle; | 18 this.shellHandle_ = shellHandle; |
| 17 this.shell = new shellModule.Shell(shellHandle, { | 19 this.shell = new Shell(shellHandle, { |
| 18 initialize: this.initialize.bind(this), | 20 initialize: this.initialize.bind(this), |
| 19 acceptConnection: this.doAcceptConnection.bind(this), | 21 acceptConnection: this.doAcceptConnection.bind(this), |
| 20 }); | 22 }); |
| 21 } | 23 } |
| 22 | 24 |
| 23 initialize(args) { | 25 initialize(args) { |
| 24 } | 26 } |
| 25 | 27 |
| 26 doAcceptConnection(url, spHandle) { | 28 doAcceptConnection(url, serviceProviderProxy) { |
| 27 var service = new spInterfaceModule.ServiceProvider.proxyClass(spHandle); | 29 var serviceProvider = new ServiceProvider(serviceProviderProxy); |
| 28 var serviceProvider = new spModule.ServiceProvider(service); | |
| 29 this.serviceProviders.push(serviceProvider); | 30 this.serviceProviders.push(serviceProvider); |
| 30 this.acceptConnection(url, serviceProvider); | 31 this.acceptConnection(url, serviceProvider); |
| 31 } | 32 } |
| 32 | 33 |
| 33 acceptConnection(url, serviceProvider) { | 34 acceptConnection(url, serviceProvider) { |
| 34 } | 35 } |
| 35 | 36 |
| 36 quit() { | 37 quit() { |
| 37 this.serviceProviders.forEach(function(sp) { | 38 this.serviceProviders.forEach(function(sp) { |
| 38 sp.close(); | 39 sp.close(); |
| 39 }); | 40 }); |
| 40 this.shell.close(); | 41 this.shell.close(); |
| 41 appBridgeModule.quit(); | 42 appBridge.quit(); |
| 42 } | 43 } |
| 43 } | 44 } |
| 44 | 45 |
| 45 var exports = {}; | 46 var exports = {}; |
| 46 exports.Application = Application; | 47 exports.Application = Application; |
| 47 return exports; | 48 return exports; |
| 48 }); | 49 }); |
| OLD | NEW |