| Index: chrome/browser/resources/edit_search_engine_dialog.js
|
| diff --git a/chrome/browser/resources/edit_search_engine_dialog.js b/chrome/browser/resources/edit_search_engine_dialog.js
|
| index 0d9cdb375966bb2343c7f488b399d1e0e2922773..1c3fca023d35b872819873e58d52e2edfad1ca55 100644
|
| --- a/chrome/browser/resources/edit_search_engine_dialog.js
|
| +++ b/chrome/browser/resources/edit_search_engine_dialog.js
|
| @@ -6,6 +6,14 @@ cr.define('editSearchEngineDialog', function() {
|
| 'use strict';
|
|
|
| /**
|
| + * Flag inidicating if we are in the process of validating input. While
|
| + * validating, the validity of the inputs is indeterminate.
|
| + * @type {boolean}
|
| + * @private
|
| + */
|
| + var isValidating_ = false;
|
| +
|
| + /**
|
| * Disables the controls while the dialog is busy.
|
| */
|
| function disableControls() {
|
| @@ -50,16 +58,20 @@ cr.define('editSearchEngineDialog', function() {
|
| * by calling setValidation.
|
| */
|
| function validate() {
|
| + isValidating_ = true;
|
| chrome.send('requestValidation', [$('description-text').value,
|
| $('keyword-text').value, $('url-text').value]);
|
| }
|
|
|
| /**
|
| * Sets dialog state given the results of the validation of input by Chrome.
|
| - * @param {{description: boolean, details: boolean, url: boolean, ok:boolean}}
|
| - * details A dictionary of booleans indicating the validation results of
|
| - * various parts of the UI. |description|, |details| and |url| indicate
|
| - * the validity of the respective text fields, and |ok| indicates whether
|
| + * @param {{description: boolean,
|
| + keyword: boolean,
|
| + url: boolean,
|
| + ok: boolean}} details
|
| + * A dictionary of booleans indicating the validation results of various
|
| + * parts of the UI. |description|, |keyword| and |url| indicate the
|
| + * validity of the respective text fields, and |ok| indicates whether
|
| * the OK/Save button can be pressed.
|
| */
|
| function setValidation(details) {
|
| @@ -67,6 +79,7 @@ cr.define('editSearchEngineDialog', function() {
|
| setValidImage($('keyword-icon'), details.keyword);
|
| setValidImage($('url-icon'), details.url);
|
| $('save').disabled = !details.ok;
|
| + isValidating_ = false;
|
| }
|
|
|
| /**
|
| @@ -108,12 +121,25 @@ cr.define('editSearchEngineDialog', function() {
|
| setValidation({description: false, keyword: false, url: false});
|
| if (cr.isViews)
|
| forEach(document.querySelectorAll('.button-strip'), reverseChildren);
|
| - chrome.send('requestDetails')
|
| + // Mark that we are in the process of validating, since the 'send' call
|
| + // is asynchronous. Until the next call to 'setValidation' complete, the
|
| + // validity of the inputs is in an indeterminate state.
|
| + isValidating_ = true;
|
| + chrome.send('requestDetails');
|
| + }
|
| +
|
| + /**
|
| + * Indicates if we are in the process of validating input.
|
| + * @return {boolean} True if validation is in progress.
|
| + */
|
| + function isValidating() {
|
| + return isValidating_;
|
| }
|
|
|
| document.addEventListener('DOMContentLoaded', initialize);
|
|
|
| return {
|
| + isValidating: isValidating,
|
| setDetails: setDetails,
|
| setValidation: setValidation,
|
| };
|
|
|