OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview Polymer element for displaying AD domain joining and AD | 6 * @fileoverview Polymer element for displaying AD domain joining and AD |
7 * Authenticate user screens. | 7 * Authenticate user screens. |
8 */ | 8 */ |
9 // Possible error states of the screen. Must be in the same order as | 9 // Possible error states of the screen. Must be in the same order as |
10 // ActiveDirectoryErrorState enum values. | 10 // ActiveDirectoryErrorState enum values. |
11 /** @enum {number} */ var ACTIVE_DIRECTORY_ERROR_STATE = { | 11 /** @enum {number} */ var ACTIVE_DIRECTORY_ERROR_STATE = { |
12 NONE: 0, | 12 NONE: 0, |
13 MACHINE_NAME_INVALID: 1, | 13 MACHINE_NAME_INVALID: 1, |
14 MACHINE_NAME_TOO_LONG: 2, | 14 MACHINE_NAME_TOO_LONG: 2, |
15 BAD_USERNAME: 3, | 15 BAD_USERNAME: 3, |
16 BAD_PASSWORD: 4, | 16 BAD_PASSWORD: 4, |
17 }; | 17 }; |
18 | 18 |
19 Polymer({ | 19 Polymer({ |
20 is: 'offline-ad-login', | 20 is: 'offline-ad-login', |
21 | 21 |
22 properties: { | 22 properties: { |
23 /** | 23 /** |
24 * Whether the UI disabled. | 24 * Whether the UI disabled. |
25 */ | 25 */ |
26 disabled: { | 26 disabled: {type: Boolean, value: false, observer: 'disabledChanged_'}, |
27 type: Boolean, | |
28 value: false, | |
29 observer: 'disabledChanged_' | |
30 }, | |
31 /** | 27 /** |
32 * Whether to show machine name input field. | 28 * Whether to show machine name input field. |
33 */ | 29 */ |
34 showMachineInput: { | 30 showMachineInput: {type: Boolean, value: false}, |
35 type: Boolean, | |
36 value: false | |
37 }, | |
38 /** | 31 /** |
39 * The kerberos realm (AD Domain), the machine is part of. | 32 * The kerberos realm (AD Domain), the machine is part of. |
40 */ | 33 */ |
41 realm: { | 34 realm: {type: String, observer: 'realmChanged_'}, |
42 type: String, | |
43 observer: 'realmChanged_' | |
44 }, | |
45 /** | 35 /** |
46 * The user kerberos default realm. Used for autocompletion. | 36 * The user kerberos default realm. Used for autocompletion. |
47 */ | 37 */ |
48 userRealm: String, | 38 userRealm: String, |
49 /** | 39 /** |
50 * Welcome message on top of the UI. | 40 * Welcome message on top of the UI. |
51 */ | 41 */ |
52 adWelcomeMessage: String, | 42 adWelcomeMessage: String, |
53 /** | 43 /** |
54 * Error message for the machine name input. | 44 * Error message for the machine name input. |
55 */ | 45 */ |
56 machineNameError: String, | 46 machineNameError: String, |
57 }, | 47 }, |
58 | 48 |
59 /** @private */ | 49 /** @private */ |
60 realmChanged_: function() { | 50 realmChanged_: function() { |
61 this.adWelcomeMessage = | 51 this.adWelcomeMessage = |
62 loadTimeData.getStringF('adAuthWelcomeMessage', this.realm); | 52 loadTimeData.getStringF('adAuthWelcomeMessage', this.realm); |
63 }, | 53 }, |
64 | 54 |
65 /** @private */ | 55 /** @private */ |
66 disabledChanged_: function() { | 56 disabledChanged_: function() { |
67 this.$.gaiaCard.classList.toggle('disabled', this.disabled); | 57 this.$.gaiaCard.classList.toggle('disabled', this.disabled); |
68 }, | 58 }, |
69 | 59 |
70 focus: function() { | 60 focus: function() { |
71 if (this.showMachineInput && /** @type {string} */ ( | 61 if (this.showMachineInput && |
72 this.$.machineNameInput.value) == '') { | 62 /** @type {string} */ (this.$.machineNameInput.value) == '') { |
73 this.$.machineNameInput.focus(); | 63 this.$.machineNameInput.focus(); |
74 } else if (/** @type {string} */ (this.$.userInput.value) == '') { | 64 } else if (/** @type {string} */ (this.$.userInput.value) == '') { |
75 this.$.userInput.focus(); | 65 this.$.userInput.focus(); |
76 } else { | 66 } else { |
77 this.$.passwordInput.focus(); | 67 this.$.passwordInput.focus(); |
78 } | 68 } |
79 }, | 69 }, |
80 | 70 |
81 /** | 71 /** |
82 * @param {string|undefined} user | 72 * @param {string|undefined} user |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 user += this.userRealm; | 123 user += this.userRealm; |
134 var msg = { | 124 var msg = { |
135 'machinename': this.$.machineNameInput.value, | 125 'machinename': this.$.machineNameInput.value, |
136 'username': user, | 126 'username': user, |
137 'password': this.$.passwordInput.value | 127 'password': this.$.passwordInput.value |
138 }; | 128 }; |
139 this.$.passwordInput.value = ''; | 129 this.$.passwordInput.value = ''; |
140 this.fire('authCompleted', msg); | 130 this.fire('authCompleted', msg); |
141 }, | 131 }, |
142 }); | 132 }); |
OLD | NEW |