| 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 12 matching lines...) Expand all Loading... |
| 23 this.applications_ = new Map(); | 23 this.applications_ = new Map(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 connectToApplication(url) { | 26 connectToApplication(url) { |
| 27 var application = this.applications_.get(url); | 27 var application = this.applications_.get(url); |
| 28 if (application) | 28 if (application) |
| 29 return application; | 29 return application; |
| 30 | 30 |
| 31 var application = new ServiceExchange(); | 31 var application = new ServiceExchange(); |
| 32 this.shellProxy.connectToApplication(url, | 32 this.shellProxy.connectToApplication(url, |
| 33 function(servicesProxy) { | 33 function(services) { |
| 34 application.proxy = servicesProxy; | 34 application.proxy = services; |
| 35 }, | 35 }, |
| 36 function(exposedServicesStub) { | 36 application); |
| 37 application.stub = exposedServicesStub; | |
| 38 StubBindings(exposedServicesStub).delegate = application; | |
| 39 }); | |
| 40 this.applications_.set(url, application); | 37 this.applications_.set(url, application); |
| 41 return application; | 38 return application; |
| 42 } | 39 } |
| 43 | 40 |
| 44 connectToService(url, service, client) { | 41 connectToService(url, service, client) { |
| 45 return this.connectToApplication(url).requestService(service, client); | 42 return this.connectToApplication(url).requestService(service, client); |
| 46 }; | 43 }; |
| 47 | 44 |
| 48 close() { | 45 close() { |
| 49 this.applications_.forEach(function(application, url) { | 46 this.applications_.forEach(function(application, url) { |
| 50 application.close(); | 47 application.close(); |
| 51 }); | 48 }); |
| 52 ProxyBindings(this.shellProxy).close(); | 49 ProxyBindings(this.shellProxy).close(); |
| 53 this.applications_.clear(); | 50 this.applications_.clear(); |
| 54 } | 51 } |
| 55 } | 52 } |
| 56 | 53 |
| 57 var exports = {}; | 54 var exports = {}; |
| 58 exports.Shell = Shell; | 55 exports.Shell = Shell; |
| 59 return exports; | 56 return exports; |
| 60 }); | 57 }); |
| OLD | NEW |