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.
5 define("mojo/services/public/js/shell", [
6 "mojo/public/js/bindings",
8 "mojo/public/js/connection",
9 "mojo/public/interfaces/application/shell.mojom",
10 "mojo/public/interfaces/application/service_provider.mojom",
11 "mojo/services/public/js/service_provider",
19 const ProxyBindings
= bindings
.ProxyBindings
;
20 const StubBindings
= bindings
.StubBindings
;
21 const ServiceProvider
= serviceProvider
.ServiceProvider
;
22 const ServiceProviderInterface
= serviceProviderMojom
.ServiceProvider
;
23 const ShellInterface
= shellMojom
.Shell
;
26 constructor(shellHandle
, app
) {
27 this.shellHandle
= shellHandle
;
28 this.proxy
= connection
.bindProxyHandle(
29 shellHandle
, ShellInterface
.client
, ShellInterface
);
31 ProxyBindings(this.proxy
).setLocalDelegate(app
);
32 // TODO: call this serviceProviders_
33 this.applications_
= new Map();
36 connectToApplication(url
) {
37 var application
= this.applications_
.get(url
);
41 this.proxy
.connectToApplication(url
, function(sp
) {
42 application
= new ServiceProvider(sp
);
44 this.applications_
.set(url
, application
);
48 connectToService(url
, service
, client
) {
49 return this.connectToApplication(url
).requestService(service
, client
);
53 this.applications_
.forEach(function(application
, url
) {
56 this.applications_
.clear();
57 core
.close(this.shellHandle
);
62 exports
.Shell
= Shell
;