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