Chromium Code Reviews| 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 created: function() { |
|
dpapad
2017/03/31 20:38:52
Nit: @override
scottchen
2017/03/31 21:02:46
Done.
| |
| 34 | 42 this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); |
| 35 invalid: { | 43 this.noExtensionIndicator = true; // Prevent double indicator. |
| 36 type: Boolean, | |
| 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 }, | 44 }, |
| 46 | 45 |
| 47 /** | 46 /** |
| 48 * Focuses the 'input' element. | 47 * Focuses the 'input' element. |
| 49 */ | 48 */ |
| 50 focus: function() { | 49 focus: function() { |
| 51 this.$.input.focus(); | 50 this.$.input.focus(); |
| 52 }, | 51 }, |
| 53 | 52 |
| 54 /** | 53 /** |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 }, | 118 }, |
| 120 | 119 |
| 121 /** | 120 /** |
| 122 * @param {boolean} disabled | 121 * @param {boolean} disabled |
| 123 * @return {boolean} Whether the element should be disabled. | 122 * @return {boolean} Whether the element should be disabled. |
| 124 * @private | 123 * @private |
| 125 */ | 124 */ |
| 126 isDisabled_: function(disabled) { | 125 isDisabled_: function(disabled) { |
| 127 return disabled || this.isPrefEnforced(); | 126 return disabled || this.isPrefEnforced(); |
| 128 }, | 127 }, |
| 128 | |
| 129 /** @private */ | |
| 130 validate_: function() { | |
| 131 if (this.value == '') { | |
| 132 this.invalid = false; | |
| 133 return; | |
| 134 } | |
| 135 | |
| 136 this.browserProxy_.validateStartupPage(this.value).then(function(isValid) { | |
| 137 this.invalid = !isValid; | |
| 138 }.bind(this)); | |
| 139 }, | |
| 129 }); | 140 }); |
| OLD | NEW |