summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js
blob: 9a317f08e465c6e675133a7bd32a7c98aeca273d (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
// 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: [FocusRowBehavior, ShowPasswordBehavior],

  /**
   * Selects the password on tap if revealed.
   * @private
   */
  onReadonlyInputTap_: function() {
    if (this.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 {{
   *    entry: !chrome.passwordsPrivate.PasswordUiEntry,
   *    password: string
   * }} 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.loginPair.username, item.entry.loginPair.urls.shown);
  },
});