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/bindings", | 6 "mojo/public/js/bindings", |
7 "mojo/public/js/core", | 7 "mojo/public/js/core", |
8 "mojo/public/js/connection", | 8 "mojo/public/js/connection", |
9 "mojo/public/interfaces/application/shell.mojom", | 9 "mojo/public/interfaces/application/shell.mojom", |
10 "mojo/public/interfaces/application/service_provider.mojom", | 10 "mojo/public/interfaces/application/service_provider.mojom", |
(...skipping 15 matching lines...) Expand all Loading... |
26 ProxyBindings(this.proxy).setLocalDelegate(app); | 26 ProxyBindings(this.proxy).setLocalDelegate(app); |
27 // TODO: call this serviceProviders_ | 27 // TODO: call this serviceProviders_ |
28 this.applications_ = new Map(); | 28 this.applications_ = new Map(); |
29 } | 29 } |
30 | 30 |
31 connectToApplication(url) { | 31 connectToApplication(url) { |
32 var application = this.applications_.get(url); | 32 var application = this.applications_.get(url); |
33 if (application) | 33 if (application) |
34 return application; | 34 return application; |
35 | 35 |
36 this.proxy.connectToApplication(url, function(sp) { | 36 this.proxy.connectToApplication(url, function(services) { |
37 application = new ServiceProvider(sp); | 37 application = new ServiceProvider(services); |
| 38 }, function() { |
| 39 return application; |
38 }); | 40 }); |
39 this.applications_.set(url, application); | 41 this.applications_.set(url, application); |
40 return application; | 42 return application; |
41 } | 43 } |
42 | 44 |
43 connectToService(url, service, client) { | 45 connectToService(url, service, client) { |
44 return this.connectToApplication(url).requestService(service, client); | 46 return this.connectToApplication(url).requestService(service, client); |
45 }; | 47 }; |
46 | 48 |
47 close() { | 49 close() { |
48 this.applications_.forEach(function(application, url) { | 50 this.applications_.forEach(function(application, url) { |
49 application.close(); | 51 application.close(); |
50 }); | 52 }); |
51 this.applications_.clear(); | 53 this.applications_.clear(); |
52 core.close(this.shellHandle); | 54 core.close(this.shellHandle); |
53 } | 55 } |
54 } | 56 } |
55 | 57 |
56 var exports = {}; | 58 var exports = {}; |
57 exports.Shell = Shell; | 59 exports.Shell = Shell; |
58 return exports; | 60 return exports; |
59 }); | 61 }); |
OLD | NEW |