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