summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/resources/settings/autofill_page/password_list_item.js
blob: 12c176fd9326695bb27847057406cba9bdb7b205 (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
// 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 PasswordListItem represents one row in the list of passwords.
 * It needs to be its own component because FocusRowBehavior provides good a11y.
 */

Polymer({
  is: 'password-list-item',

  behaviors: [
    cr.ui.FocusRowBehavior,
    ShowPasswordBehavior,
  ],

  /**
   * Selects the password on tap if revealed.
   * @private
   */
  onReadonlyInputTap_: function() {
    if (this.item.password) {
      this.$$('#password').select();
    }
  },

  /**
   * Opens the password action menu.
   * @private
   */
  onPasswordMenuTap_: function() {
    this.fire(
        'password-menu-tap', {target: this.$.passwordMenu, listItem: this});
  },

  /**
   * Get the aria label for the More Actions button on this row.
   * @param {!PasswordManagerProxy.UiEntryWithPassword} item This row's item.
   * @private
   */
  getMoreActionsLabel_: function(item) {
    // Avoid using I18nBehavior.i18n, because it will filter sequences, which
    // are otherwise not illegal for usernames. Polymer still protects against
    // XSS injection.
    return loadTimeData.getStringF(
        (item.entry.federationText) ? 'passwordRowFederatedMoreActionsButton' :
                                      'passwordRowMoreActionsButton',
        item.entry.username, item.entry.urls.shown);
  },
});