| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 | 6 * @fileoverview |
| 7 * `settings-input` is a single-line text field for user input associated | 7 * `home-url-input` is a single-line text field intending to be used with |
| 8 * with a pref value. | 8 * prefs.homepage |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| 11 is: 'settings-input', | 11 is: 'home-url-input', |
| 12 | 12 |
| 13 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], | 13 behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], |
| 14 | 14 |
| 15 properties: { | 15 properties: { |
| 16 /** | 16 /** |
| 17 * The preference object to control. | 17 * The preference object to control. |
| 18 * @type {!chrome.settingsPrivate.PrefObject|undefined} | 18 * @type {!chrome.settingsPrivate.PrefObject|undefined} |
| 19 * @override | 19 * @override |
| 20 */ | 20 */ |
| 21 pref: {observer: 'prefChanged_'}, | 21 pref: {observer: 'prefChanged_'}, |
| 22 | 22 |
| 23 /* Set to true to disable editing the input. */ |
| 24 disabled: {type: Boolean, value: false, reflectToAttribute: true}, |
| 25 |
| 26 canTab: Boolean, |
| 27 |
| 28 invalid: {type: Boolean, value: false}, |
| 29 |
| 23 /* The current value of the input, reflected to/from |pref|. */ | 30 /* The current value of the input, reflected to/from |pref|. */ |
| 24 value: { | 31 value: { |
| 25 type: String, | 32 type: String, |
| 26 value: '', | 33 value: '', |
| 27 notify: true, | 34 notify: true, |
| 28 }, | 35 }, |
| 36 }, |
| 29 | 37 |
| 30 /* Set to true to disable editing the input. */ | 38 /** @private {?settings.AppearanceBrowserProxy} */ |
| 31 disabled: {type: Boolean, value: false, reflectToAttribute: true}, | 39 browserProxy_: null, |
| 32 | 40 |
| 33 canTab: Boolean, | 41 /** @override */ |
| 34 | 42 created: function() { |
| 35 invalid: { | 43 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); |
| 36 type: Boolean, | 44 this.noExtensionIndicator = true; // Prevent double indicator. |
| 37 value: false, | |
| 38 notify: true, | |
| 39 }, | |
| 40 | |
| 41 /* Properties for paper-input. This is not strictly necessary. | |
| 42 * Though it does define the types for the closure compiler. */ | |
| 43 errorMessage: {type: String}, | |
| 44 label: {type: String}, | |
| 45 }, | 45 }, |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Focuses the 'input' element. | 48 * Focuses the 'input' element. |
| 49 */ | 49 */ |
| 50 focus: function() { | 50 focus: function() { |
| 51 this.$.input.focus(); | 51 this.$.input.focus(); |
| 52 }, | 52 }, |
| 53 | 53 |
| 54 /** | 54 /** |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 }, | 119 }, |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * @param {boolean} disabled | 122 * @param {boolean} disabled |
| 123 * @return {boolean} Whether the element should be disabled. | 123 * @return {boolean} Whether the element should be disabled. |
| 124 * @private | 124 * @private |
| 125 */ | 125 */ |
| 126 isDisabled_: function(disabled) { | 126 isDisabled_: function(disabled) { |
| 127 return disabled || this.isPrefEnforced(); | 127 return disabled || this.isPrefEnforced(); |
| 128 }, | 128 }, |
| 129 |
| 130 /** @private */ |
| 131 validate_: function() { |
| 132 if (this.value == '') { |
| 133 this.invalid = false; |
| 134 return; |
| 135 } |
| 136 |
| 137 this.browserProxy_.validateStartupPage(this.value).then(function(isValid) { |
| 138 this.invalid = !isValid; |
| 139 }.bind(this)); |
| 140 }, |
| 129 }); | 141 }); |
| OLD | NEW |