Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview Polymer element for displaying AD domain joining and AD | |
| 7 * Authenticate user screens. | |
| 8 */ | |
| 9 | |
| 10 Polymer({ | |
| 11 is: 'offline-ad-login', | |
| 12 | |
| 13 properties: { | |
| 14 /** | |
| 15 * Whether the UI disabled. | |
| 16 */ | |
| 17 disabled: { | |
| 18 type: Boolean, | |
| 19 value: false, | |
| 20 observer: 'disabledChanged_' | |
| 21 }, | |
| 22 /** | |
| 23 * Whether to show machine name input field. | |
| 24 */ | |
| 25 showMachineInput: { | |
| 26 type: Boolean, | |
| 27 value: false | |
| 28 }, | |
| 29 /** | |
| 30 * The kerberos realm (AD Domain), the machine is part of. | |
| 31 */ | |
| 32 realm: { | |
| 33 type: String, | |
| 34 observer: 'realmChanged_' | |
| 35 }, | |
| 36 /** | |
| 37 * The user kerberos default realm. Used for autocompletion. | |
| 38 */ | |
| 39 userRealm: String, | |
| 40 /** | |
| 41 * Welcome message on top of the UI. | |
| 42 */ | |
| 43 adWelcomeMessage: String | |
|
michaelpg
2016/11/02 23:08:53
unused? (see above)
Roman Sorokin (ftl)
2016/11/03 14:03:46
Changed it. Will be used more in the next CL (Logi
| |
| 44 }, | |
| 45 | |
| 46 /** @private */ | |
| 47 realmChanged_: function() { | |
| 48 this.$.welcomeMsg.textContent = | |
| 49 loadTimeData.getStringF('ADAuthWelcomeMessage', this.realm); | |
| 50 }, | |
| 51 | |
| 52 /** @private */ | |
| 53 disabledChanged_: function() { | |
| 54 this.$.gaiaCard.classList.toggle('disabled', this.disabled); | |
| 55 }, | |
| 56 | |
| 57 focus: function() { | |
| 58 if (this.showMachineInput && /** @type {string} */ ( | |
| 59 this.$.machineNameInput.value) == '') { | |
| 60 this.$.machineNameInput.focus(); | |
| 61 } else if (/** @type {string} */ (this.$.userInput.value) == '') { | |
| 62 this.$.userInput.focus(); | |
| 63 } else { | |
| 64 this.$.passwordInput.focus(); | |
| 65 } | |
| 66 }, | |
| 67 | |
| 68 /** | |
| 69 * @param {!string|undefined} user | |
|
michaelpg
2016/11/02 23:08:53
nit: ! not required for fundamental types (non-obj
Roman Sorokin (ftl)
2016/11/03 14:03:46
Done.
| |
| 70 * @param {!string|undefined} machineName | |
| 71 */ | |
| 72 setUser: function(user, machineName) { | |
| 73 this.$.userInput.value = user || ''; | |
| 74 this.$.machineNameInput.value = machineName || ''; | |
| 75 this.$.passwordInput.value = ''; | |
| 76 this.$.passwordInput.isInvalid = !!user; | |
| 77 this.focus(); | |
| 78 }, | |
| 79 | |
| 80 /** @private */ | |
| 81 onSubmit_: function() { | |
| 82 if (this.showMachineInput && !this.$.machineNameInput.checkValidity()) | |
| 83 return; | |
| 84 if (!this.$.passwordInput.checkValidity()) | |
| 85 return; | |
| 86 var user = /** @type {string} */ (this.$.userInput.value); | |
| 87 if (!user.includes('@') && this.userRealm) | |
| 88 user += this.userRealm; | |
| 89 var msg = { | |
| 90 'machinename': this.$.machineNameInput.value, | |
| 91 'username': user, | |
| 92 'password': this.$.passwordInput.value | |
| 93 }; | |
| 94 this.$.passwordInput.value = ''; | |
| 95 this.fire('authCompleted', msg); | |
| 96 }, | |
| 97 }); | |
| OLD | NEW |