<link rel="import" href="chrome://resources/html/polymer.html">

<link rel="import" href="chrome://resources/html/action_link.html">
<link rel="import" href="chrome://resources/html/action_link_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="../controls/settings_toggle_button.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="user_list.html">
<link rel="import" href="users_add_user_dialog.html">

<dom-module id="settings-users-page">
  <template>
    <style include="settings-shared action-link">
      .settings-box:first-of-type {
        border-top: none;
      }

      #add-user-button {
        /* Add user button must be lined up with the start of users' names. */
        -webkit-margin-start: var(--settings-box-row-indent);
      }

      .block {
        display: block;
      }
    </style>
    <div class="settings-box" hidden$="[[!isWhitelistManaged_]]">
      $i18n{settingsManagedLabel}
    </div>
    <div class="settings-box"
        hidden$="[[shouldHideModifiedByOwnerLabel_(
            isWhitelistManaged_, isOwner_)]]">
      $i18n{usersModifiedByOwnerLabel}
    </div>
    <settings-toggle-button class="first"
        pref="{{prefs.cros.accounts.allowBWSI}}"
        label="$i18n{guestBrowsingLabel}"
        disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]">
    </settings-toggle-button>
    <settings-toggle-button class="continuation"
        pref="{{prefs.cros.accounts.showUserNamesOnSignIn}}"
        label="$i18n{showOnSigninLabel}"
        disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]">
    </settings-toggle-button>
    <settings-toggle-button class="continuation"
        pref="{{prefs.cros.accounts.allowGuest}}"
        id="restrictSignIn"
        label="$i18n{restrictSigninLabel}"
        disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"
        inverted>
    </settings-toggle-button>
    <div class="list-frame">
      <settings-user-list prefs="[[prefs]]"
          disabled="[[isEditingUsersDisabled_(isOwner_, isWhitelistManaged_,
              prefs.cros.accounts.allowGuest.value)]]">
      </settings-user-list>
      <div id="add-user-button" class="list-item"
          hidden="[[isEditingUsersDisabled_(isOwner_, isWhitelistManaged_,
              prefs.cros.accounts.allowGuest.value)]]">
        <a is="action-link" class="list-button" on-click="openAddUserDialog_">
          $i18n{addUsers}
        </a>
      </div>
    </div>
    <settings-users-add-user-dialog id="addUserDialog"
        on-close="onAddUserDialogClose_">
    </settings-users-add-user-dialog>
  </template>
  <script src="users_page.js"></script>
</dom-module>
