<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/classes/iron-flex-layout.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="/controls/settings_checkbox.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">
      .users {
        /* The users box must line up with the checkbox text. */
        -webkit-margin-start: 36px;
      }

      .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: 56px;
      }
    </style>
    <template is="dom-if" if="[[isWhitelistManaged_]]">
      <div class="settings-box">$i18n{settingsManagedLabel}</div>
    </template>
    <template is="dom-if" if="[[!isWhitelistManaged_]]">
      <template is="dom-if" if="[[!isOwner_]]">
        <div class="settings-box">$i18n{usersModifiedByOwnerLabel}</div>
      </template>
    </template>
    <div class="settings-box block">
      <settings-checkbox
          pref="{{prefs.cros.accounts.allowBWSI}}"
          label="$i18n{guestBrowsingLabel}"
          disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]">
      </settings-checkbox>
      <settings-checkbox
          pref="{{prefs.cros.accounts.supervisedUsersEnabled}}"
          label="$i18n{supervisedUsersLabel}"
          disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]">
      </settings-checkbox>
      <settings-checkbox
          pref="{{prefs.cros.accounts.showUserNamesOnSignIn}}"
          label="$i18n{showOnSigninLabel}"
          disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]">
      </settings-checkbox>
      <settings-checkbox
          pref="{{prefs.cros.accounts.allowGuest}}"
          id="restrictSignIn"
          label="$i18n{restrictSigninLabel}"
          disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"
          inverted>
      </settings-checkbox>
      <div class="users">
        <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 list-button"
            on-tap="openAddUserDialog_"
            hidden="[[isEditingUsersDisabled_(isOwner_, isWhitelistManaged_,
                prefs.cros.accounts.allowGuest.value)]]">
          $i18n{addUsers}
        </div>
      </div>
    </div>
    <settings-users-add-user-dialog id="addUserDialog">
    </settings-users-add-user-dialog>
  </template>
  <script src="users_page.js"></script>
</dom-module>
