summaryrefslogtreecommitdiffstats
path: root/components/proximity_auth/webui/resources/local-state.js
blob: 6ee17eb5a95cfe578719e54a39d9aca0a030d0d9 (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
// Copyright 2015 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.

Polymer({
  is: 'local-state',
  properties: {
    /**
     * The current CryptAuth enrollment status.
     * @type {{
     *   lastSuccessTime: ?number,
     *   nextRefreshTime: string,
     *   lastAttemptFailed: boolean,
     * }}
     */
    enrollmentInfo: {
      type: Object,
      value: {
        lastSuccessTime: null,
        nextRefreshTime: '90 days',
        lastAttemptFailed: true
      },
      notify: true,
    },

    /**
     * The current CryptAuth device sync status.
     * @type {{
     *   lastSuccessTime: ?number,
     *   nextRefreshTime: string,
     *   lastAttemptFailed: boolean,
     * }}
     */
    deviceSyncInfo: {
      type: Object,
      value: {
        lastSuccessTime: 'April 20 14:23',
        nextRefreshTime: '15.5 hours',
        lastAttemptFailed: false
      },
      notify: true,
    },

    /**
     * List of unlock keys that can unlock the local device.
     * @type {Array<DeviceInfo>}
     */
    unlockKeys: {
      type: Array,
      value: [
        {
         publicKey: 'CAESRQogOlH8DgPMQu7eAt-b6yoTXcazG8mAl6SPC5Ds-LTULIcSIQDZ' +
                    'DMqsoYRO4tNMej1FBEl1sTiTiVDqrcGq-CkYCzDThw==',
         friendlyDeviceName: 'LGE Nexus 4',
         bluetoothAddress: 'C4:43:8F:12:07:07',
         unlockKey: true,
         unlockable: false,
         connectionStatus: 'connected',
         remoteState: {
           userPresent: true,
           secureScreenLock: true,
           trustAgent: true
         },
        },
      ],
      notify: true,
    },
  },

  /**
   * @param {SyncInfo} syncInfo
   * @param {string} neverSyncedString
   * @return {string}
   */
  getLastSyncTimeString_: function(syncInfo, neverSyncedString) {
    return syncInfo.lastSuccessTime || neverSyncedString;
  },

  /**
   * @param {SyncInfo} syncInfo
   * @return {string}
   */
  getNextEnrollmentString_: function(syncInfo) {
    return syncInfo.nextRefreshTime + ' to refresh';
  },

  /**
   * @param {SyncInfo} syncInfo
   * @return {string}
   */
  getIconForLastAttempt_: function(syncInfo) {
    return syncInfo.lastAttemptFailed ?
        'icons:error' : 'icons:cloud-done';
  },
});