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

ash / webui / status_area_internals / resources / privacy_indicator_app_manager.ts [blame]

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import './privacy_indicator_app.js';

import {PolymerElementProperties} from 'chrome://resources/polymer/v3_0/polymer/interfaces.js';
import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {getTemplate} from './privacy_indicator_app_manager.html.js';

const testAppIdPrefix = 'chromeos-status-area-test-app';

/**
 * @fileoverview
 * 'privacy-indicator-app-manager' defines the UI for the Privacy
 * Indicators app management section of the test page.
 */

export class PrivacyIndicatorAppManagerElement extends PolymerElement {
  static get is() {
    return 'privacy-indicator-app-manager';
  }

  static get template() {
    return getTemplate();
  }

  static get properties(): PolymerElementProperties {
    return {
      idLatest: {
        type: Number,
        value: 0,
      },
      appList: {
        type: Array,
        value: [],
      },
    };
  }

  private idLatest: number = 0;
  private appList: string[] = [];

  onAddPrivacyIndicatorsApp(e: Event) {
    e.stopPropagation();

    this.appList.push(testAppIdPrefix + this.idLatest);
    this.idLatest++;

    // Force `appList` to update in the UI.
    this.appList = this.appList.slice();
  }
}

customElements.define(
    PrivacyIndicatorAppManagerElement.is, PrivacyIndicatorAppManagerElement);