summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.js
blob: 31f4824fd3bcdb1e975e9c43940307df76c95d8b (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
// Copyright 2016 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 the People section to get the
 * profile info, which consists of the profile name and icon. Used for both
 * Chrome browser and ChromeOS.
 */
cr.exportPath('settings');

/**
 * An object describing the profile.
 * @typedef {{
 *   name: string,
 *   iconUrl: string
 * }}
 */
settings.ProfileInfo;

cr.define('settings', function() {
  /** @interface */
  class ProfileInfoBrowserProxy {
    /**
     * Returns a Promise for the profile info.
     * @return {!Promise<!settings.ProfileInfo>}
     */
    getProfileInfo() {}

    /**
     * Requests the profile stats count. The result is returned by the
     * 'profile-stats-count-ready' WebUI listener event.
     */
    getProfileStatsCount() {}

    /**
     * Returns a Promise that's true if the profile manages supervised users.
     * @return {!Promise<boolean>}
     */
    getProfileManagesSupervisedUsers() {}
  }

  /**
   * @implements {ProfileInfoBrowserProxy}
   */
  class ProfileInfoBrowserProxyImpl {
    /** @override */
    getProfileInfo() {
      return cr.sendWithPromise('getProfileInfo');
    }

    /** @override */
    getProfileStatsCount() {
      chrome.send('getProfileStatsCount');
    }

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

  cr.addSingletonGetter(ProfileInfoBrowserProxyImpl);

  return {
    ProfileInfoBrowserProxyImpl: ProfileInfoBrowserProxyImpl,
  };
});