Chromium Code Reviews| Index: chrome/browser/resources/settings/settings_main/settings_main.js |
| diff --git a/chrome/browser/resources/settings/settings_main/settings_main.js b/chrome/browser/resources/settings/settings_main/settings_main.js |
| index d9c65784fda9f8a9bd4079fcc57ebc866a2c3572..6f1ff0f69021d9d507243e845ee8c9fc6da16d3f 100644 |
| --- a/chrome/browser/resources/settings/settings_main/settings_main.js |
| +++ b/chrome/browser/resources/settings/settings_main/settings_main.js |
| @@ -176,6 +176,7 @@ Polymer({ |
| /** |
| * @param {string} query |
| + * @return {!Promise} A promise indicating that searching finished. |
| */ |
| searchContents: function(query) { |
| this.ensureInDefaultSearchPage_(); |
| @@ -184,26 +185,31 @@ Polymer({ |
| // Trigger rendering of the basic and advanced pages and search once ready. |
| this.showPages_ = {about: false, basic: true, advanced: true}; |
| - setTimeout(function() { |
| - settings.getSearchManager().search( |
| - query, assert(this.$$('settings-basic-page'))); |
| - }.bind(this), 0); |
| - setTimeout(function() { |
| - settings.getSearchManager().search( |
| - query, assert(this.$$('settings-advanced-page'))).then( |
| - function(request) { |
| - if (!request.finished) { |
| - // Nothing to do here. A previous search request was canceled |
| - // because a new search request was issued before the first one |
| - // completed. |
| - return; |
| - } |
| - |
| - this.toolbarSpinnerActive = false; |
| - this.showNoResultsFound_ = |
| - !request.isSame('') && !request.didFindMatches(); |
| - }.bind(this)); |
| - }.bind(this), 0); |
| + return new Promise(function(resolve, reject) { |
| + setTimeout(function() { |
| + var whenSearchDone = settings.getSearchManager().search( |
| + query, assert(this.$$('settings-basic-page'))); |
| + assert( |
| + whenSearchDone === |
| + settings.getSearchManager().search( |
|
michaelpg
2016/08/02 20:45:20
is this indent ok?
dpapad
2016/08/02 22:33:15
Fixed.
|
| + query, assert(this.$$('settings-advanced-page')))); |
| + |
| + whenSearchDone.then( |
|
michaelpg
2016/08/02 20:45:20
perhaps join with the next line to save precious w
dpapad
2016/08/02 22:33:15
Done. I don't mind either way.
|
| + function(request) { |
| + resolve(); |
| + if (!request.finished) { |
| + // Nothing to do here. A previous search request was canceled |
| + // because a new search request was issued before the first one |
| + // completed. |
| + return; |
| + } |
| + |
| + this.toolbarSpinnerActive = false; |
| + this.showNoResultsFound_ = |
| + !request.isSame('') && !request.didFindMatches(); |
| + }.bind(this)); |
| + }.bind(this), 0); |
| + }.bind(this)); |
| }, |
| /** |