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/shell", [ | 5 define("mojo/services/public/js/shell", [ |
| 6 "mojo/public/js/core", |
| 7 "mojo/public/interfaces/application/shell.mojom", |
6 "mojo/public/interfaces/application/service_provider.mojom", | 8 "mojo/public/interfaces/application/service_provider.mojom", |
7 "mojo/services/public/js/service_provider", | 9 "mojo/services/public/js/service_provider", |
8 ], function(spInterfaceModule, spModule) { | 10 ], function(coreModule, shellInterfaceModule, spInterfaceModule, spModule) { |
9 | 11 |
10 class Shell { | 12 class Shell { |
11 constructor(appShell) { | 13 constructor(shellHandle, app) { |
12 this.appShell_ = appShell; | 14 this.shellHandle = shellHandle; |
| 15 this.proxy = new shellInterfaceModule.Shell.proxyClass(shellHandle); |
| 16 this.proxy.client$ = app; |
13 this.applications_ = new Map(); | 17 this.applications_ = new Map(); |
14 } | 18 } |
15 | 19 |
16 connectToApplication(url) { | 20 connectToApplication(url) { |
17 var application = this.applications_.get(url); | 21 var application = this.applications_.get(url); |
18 if (application) | 22 if (application) |
19 return application; | 23 return application; |
20 | 24 |
21 var proxy = new spInterfaceModule.ServiceProvider.proxyClass; | 25 var spProxy = new spInterfaceModule.ServiceProvider.proxyClass; |
22 this.appShell_.connectToApplication(url, proxy); | 26 this.proxy.connectToApplication(url, spProxy); |
23 application = new spModule.ServiceProvider(proxy); | 27 application = new spModule.ServiceProvider(spProxy); |
24 this.applications_.set(url, application); | 28 this.applications_.set(url, application); |
25 return application; | 29 return application; |
26 } | 30 } |
27 | 31 |
28 connectToService(url, service, client) { | 32 connectToService(url, service, client) { |
29 return this.connectToApplication(url).connectToService(service, client); | 33 return this.connectToApplication(url).connectToService(service, client); |
30 }; | 34 }; |
31 | 35 |
32 close() { | 36 close() { |
33 this.applications_.forEach(function(application, url) { | 37 this.applications_.forEach(function(application, url) { |
34 application.close(); | 38 application.close(); |
35 }); | 39 }); |
36 this.applications_.clear(); | 40 this.applications_.clear(); |
| 41 coreModule.close(this.shellHandle); |
37 } | 42 } |
38 } | 43 } |
39 | 44 |
40 var exports = {}; | 45 var exports = {}; |
41 exports.Shell = Shell; | 46 exports.Shell = Shell; |
42 return exports; | 47 return exports; |
43 }); | 48 }); |
OLD | NEW |