summaryrefslogtreecommitdiffstats
path: root/mojo/services/public/js/application.js
blob: 58934241994b85e5494aba9ddbc0a7119b808b2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

define("mojo/services/public/js/application", [
  "services/js/app_bridge",
  "mojo/services/public/js/service_provider",
  "mojo/services/public/js/shell",
], function(appBridgeModule, spModule, shellModule) {

  class Application {
    constructor(appShell, url) {
      this.shell = new shellModule.Shell(appShell);
      this.url = url;
      this.serviceProviders = [];
    }

    initialize(args) {
    }

    acceptConnection_(url, spHandle) {
      var serviceProvider =  new spModule.ServiceProvider(spHandle);
      this.serviceProviders.push(serviceProvider);
      this.acceptConnection(url, serviceProvider);
    }

    acceptConnection(url, serviceProvider) {
    }

    quit() {
      this.shell.close();
      this.serviceProviders.forEach(function(sp) {
        sp.close();
      });
      appBridgeModule.quit();
    }
  }

  var exports = {};
  exports.Application = Application;
  return exports;
});