summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/extensions/kiosk_browser_proxy.js
blob: 1d0539898b8974617276f0d29968d23ad15e5c68 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2017 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.

/**
 * @fileoverview A helper object used from the "Kiosk" dialog to interact with
 * the browser.
 */

/**
 * @typedef {{
 *   kioskEnabled: boolean,
 *   autoLaunchEnabled: boolean
 * }}
 */
let KioskSettings;

/**
 * @typedef {{
 *   id: string,
 *   name: string,
 *   iconURL: string,
 *   autoLaunch: boolean,
 *   isLoading: boolean
 * }}
 */
let KioskApp;

/**
 * @typedef {{
 *   apps: !Array<!KioskApp>,
 *   disableBailout: boolean,
 *   hasAutoLaunchApp: boolean
 * }}
 */
let KioskAppSettings;

cr.define('extensions', function() {
  /** @interface */
  class KioskBrowserProxy {
    /** @param {string} appId */
    addKioskApp(appId) {}

    /** @param {string} appId */
    disableKioskAutoLaunch(appId) {}

    /** @param {string} appId */
    enableKioskAutoLaunch(appId) {}

    /** @return {!Promise<!KioskAppSettings>} */
    getKioskAppSettings() {}

    /** @return {!Promise<!KioskSettings>} */
    initializeKioskAppSettings() {}

    /** @param {string} appId */
    removeKioskApp(appId) {}

    /** @param {boolean} disableBailout */
    setDisableBailoutShortcut(disableBailout) {}
  }

  /** @implements {extensions.KioskBrowserProxy} */
  class KioskBrowserProxyImpl {
    /** @override */
    initializeKioskAppSettings() {
      return cr.sendWithPromise('initializeKioskAppSettings');
    }

    /** @override */
    getKioskAppSettings() {
      return cr.sendWithPromise('getKioskAppSettings');
    }

    /** @override */
    addKioskApp(appId) {
      chrome.send('addKioskApp', [appId]);
    }

    /** @override */
    disableKioskAutoLaunch(appId) {
      chrome.send('disableKioskAutoLaunch', [appId]);
    }

    /** @override */
    enableKioskAutoLaunch(appId) {
      chrome.send('enableKioskAutoLaunch', [appId]);
    }

    /** @override */
    removeKioskApp(appId) {
      chrome.send('removeKioskApp', [appId]);
    }

    /** @override */
    setDisableBailoutShortcut(disableBailout) {
      chrome.send('setDisableBailoutShortcut', [disableBailout]);
    }
  }

  cr.addSingletonGetter(KioskBrowserProxyImpl);

  return {
    KioskBrowserProxy: KioskBrowserProxy,
    KioskBrowserProxyImpl: KioskBrowserProxyImpl,
  };
});