Chromium Code Reviews| Index: chrome/browser/resources/settings/appearance_page/home_url_input.js |
| diff --git a/chrome/browser/resources/settings/controls/settings_input.js b/chrome/browser/resources/settings/appearance_page/home_url_input.js |
| similarity index 77% |
| rename from chrome/browser/resources/settings/controls/settings_input.js |
| rename to chrome/browser/resources/settings/appearance_page/home_url_input.js |
| index 3796fdecfc542cf9eb965d798c2d8aa0f1901fbd..261580721dd0d79c0efaa44abcee9eaa6ece7330 100644 |
| --- a/chrome/browser/resources/settings/controls/settings_input.js |
| +++ b/chrome/browser/resources/settings/appearance_page/home_url_input.js |
| @@ -4,11 +4,11 @@ |
| /** |
| * @fileoverview |
| - * `settings-input` is a single-line text field for user input associated |
| - * with a pref value. |
| + * `home-url-input` is a single-line text field intending to be used with |
| + * prefs.homepage |
| */ |
| Polymer({ |
| - is: 'settings-input', |
| + is: 'home-url-input', |
| behaviors: [CrPolicyPrefBehavior, PrefControlBehavior], |
| @@ -20,28 +20,27 @@ Polymer({ |
| */ |
| pref: {observer: 'prefChanged_'}, |
| - /* The current value of the input, reflected to/from |pref|. */ |
| - value: { |
| - type: String, |
| - value: '', |
| - notify: true, |
| - }, |
| - |
| /* Set to true to disable editing the input. */ |
| disabled: {type: Boolean, value: false, reflectToAttribute: true}, |
| canTab: Boolean, |
| - invalid: { |
| - type: Boolean, |
| - value: false, |
| + invalid: {type: Boolean, value: false}, |
| + |
| + /* The current value of the input, reflected to/from |pref|. */ |
| + value: { |
| + type: String, |
| + value: '', |
| notify: true, |
| }, |
| + }, |
| + |
| + /** @private {?settings.AppearanceBrowserProxy} */ |
| + browserProxy_: null, |
| - /* Properties for paper-input. This is not strictly necessary. |
| - * Though it does define the types for the closure compiler. */ |
| - errorMessage: {type: String}, |
| - label: {type: String}, |
| + created: function() { |
| + this.browserProxy_ = settings.AppearanceBrowserProxyImpl.getInstance(); |
| + this.noExtensionIndicator = true; // Prevent double indicator. |
| }, |
| /** |
| @@ -112,15 +111,10 @@ Polymer({ |
| */ |
| onKeydown_: function(event) { |
| // If pressed enter when input is invalid, do not trigger on-change. |
| - if (event.key == 'Enter' && this.invalid) { |
| + if (event.key == 'Enter' && this.invalid) |
| event.preventDefault(); |
| - return; |
| - } |
| - |
| - if (event.key != 'Escape') |
| - return; |
| - |
| - this.resetValue_(); |
| + else if (event.key == 'Escape') |
| + this.resetValue_(); |
| }, |
| /** |
| @@ -131,4 +125,18 @@ Polymer({ |
| isDisabled_: function(disabled) { |
| return disabled || this.isPrefEnforced(); |
| }, |
| + |
| + /** |
|
dpapad
2017/03/28 00:09:27
Nit: /** @private */
scottchen
2017/03/30 07:05:03
Done.
|
| + * @private |
| + */ |
| + validate_: function() { |
| + if (this.value == '') { |
| + this.invalid = false; |
| + return; |
| + } |
| + |
| + this.browserProxy_.validateStartupPage(this.value).then(function(isValid) { |
| + this.invalid = !isValid; |
| + }.bind(this)); |
| + }, |
| }); |