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