{"size": 3004, "ext": "js", "max_stars_repo_path": "chrome/browser/resources/chromeos/login/oobe_reset.js", "max_stars_repo_name": "zipated/src", "max_stars_repo_stars_event_min_datetime": "2020-04-18T07:31:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T08:39:18.000Z", "max_issues_repo_path": "chrome/browser/resources/chromeos/login/oobe_reset.js", "max_issues_repo_name": "cangulcan/src", "max_issues_repo_issues_event_min_datetime": "2020-04-18T08:22:18.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-08T13:04:49.000Z", "max_forks_repo_path": "chrome/browser/resources/chromeos/login/oobe_reset.js", "max_forks_repo_name": "cangulcan/src", "max_forks_repo_forks_event_min_datetime": "2020-04-18T08:03:10.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-29T12:33:22.000Z"}
{"max_stars_count": 2151, "max_issues_count": 395, "max_forks_count": 338, "avg_line_length": 22.4179104478, "max_line_length": 80, "alphanum_fraction": 0.6348202397}
// 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 Polymer element for displaying material design reset screen.
 */

Polymer({
  is: 'oobe-reset-md',

  properties: {
    /**
     * State of the screen corresponding to the css style set by
     * oobe_screen_reset.js.
     */
    uiState_: String,

    /**
     * Flag that determines whether help link is shown.
     */
    isOfficial_: Boolean,

    /**
     * Whether to show the TPM firmware update checkbox.
     */
    tpmFirmwareUpdateAvailable_: Boolean,

    /**
     * If the checkbox to request a TPM firmware update is checked.
     */
    tpmFirmwareUpdateChecked_: Boolean,

    /**
     * If the checkbox to request a TPM firmware update is editable.
     */
    tpmFirmwareUpdateEditable_: Boolean,

    /**
     * Reference to OOBE screen object.
     * @type {!OobeTypes.Screen}
     */
    screen: {
      type: Object,
    },
  },

  focus: function() {
    this.$.resetDialog.focus();
  },

  /** @private */
  isState_: function(uiState_, state_) {
    return uiState_ == state_;
  },

  /** @private */
  isCancelHidden_: function(uiState_) {
    return uiState_ == 'revert-promise-view';
  },

  /** @private */
  isHelpLinkHidden_: function(uiState_, isOfficial_) {
    return !isOfficial_ || (uiState_ == 'revert-promise-view');
  },

  /** @private */
  isTPMFirmwareUpdateHidden_: function(uiState_, tpmFirmwareUpdateAvailable_) {
    var inProposalView = [
      'powerwash-proposal-view', 'rollback-proposal-view'
    ].includes(uiState_);
    return !(tpmFirmwareUpdateAvailable_ && inProposalView);
  },

  /**
   * On-tap event handler for cancel button.
   *
   * @private
   */
  onCancelTap_: function() {
    chrome.send('login.ResetScreen.userActed', ['cancel-reset']);
  },

  /**
   * On-tap event handler for restart button.
   *
   * @private
   */
  onRestartTap_: function() {
    chrome.send('login.ResetScreen.userActed', ['restart-pressed']);
  },

  /**
   * On-tap event handler for powerwash button.
   *
   * @private
   */
  onPowerwashTap_: function() {
    chrome.send('login.ResetScreen.userActed', ['show-confirmation']);
  },

  /**
   * On-tap event handler for learn more link.
   *
   * @private
   */
  onLearnMoreTap_: function() {
    chrome.send('login.ResetScreen.userActed', ['learn-more-link']);
  },

  /**
   * Change handler for TPM firmware update checkbox.
   *
   * @private
   */
  onTPMFirmwareUpdateChanged_: function() {
    this.screen.onTPMFirmwareUpdateChanged_(
        this.$.tpmFirmwareUpdateCheckbox.checked);
  },

  /**
   * On-tap event handler for the TPM firmware update learn more link.
   *
   * @param {!Event} event
   * @private
   */
  onTPMFirmwareUpdateLearnMore_: function(event) {
    chrome.send(
        'login.ResetScreen.userActed', ['tpm-firmware-update-learn-more-link']);
    event.stopPropagation();
  },

});
