summaryrefslogtreecommitdiff
path: root/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.js
blob: fd1606d2d221d4c31a1be4d0f3d1fc7351faf42c (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
// 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 Constants used for logging the pin unlock setup uma.
 */
cr.define('settings', function() {
  /**
   * Name of the pin unlock setup uma histogram.
   * @type {string}
   */
  const PinUnlockUmaHistogramName = 'Settings.PinUnlockSetup';

  /**
   * Stages the user can enter while setting up pin unlock.
   * @enum {number}
   */
  /* #export */ const LockScreenProgress = {
    START_SCREEN_LOCK: 0,
    ENTER_PASSWORD_CORRECTLY: 1,
    CHOOSE_PIN_OR_PASSWORD: 2,
    ENTER_PIN: 3,
    CONFIRM_PIN: 4,
    MAX_BUCKET: 5
  };
  /**
   * Helper function to send the progress of the pin setup to be recorded in the
   * histogram.
   * @param {settings.LockScreenProgress} currentProgress
   */
  /* #export */ const recordLockScreenProgress = function(currentProgress) {
    if (currentProgress >= LockScreenProgress.MAX_BUCKET) {
      console.error(
          'Expected a enumeration value of ' + LockScreenProgress.MAX_BUCKET +
          ' or lower: Received ' + currentProgress + '.');
      return;
    }
    chrome.send('metricsHandler:recordInHistogram', [
      PinUnlockUmaHistogramName, currentProgress, LockScreenProgress.MAX_BUCKET
    ]);
  };

  // #cr_define_end
  return {
    recordLockScreenProgress: recordLockScreenProgress,
    LockScreenProgress: LockScreenProgress
  };
});