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 676429b994c7533a5426cb7ced6b98673c6cadf0..f8675c6f52f782a03950fd695ecf6099702acfa4 100644 |
| --- a/chrome/browser/resources/settings/settings_main/settings_main.js |
| +++ b/chrome/browser/resources/settings/settings_main/settings_main.js |
| @@ -47,6 +47,18 @@ Polymer({ |
| }, |
| }, |
| + /** |
| + * The main pages that were displayed before search was initiated. When |
| + * |null| it indicates that currently the page is displaying its normal |
| + * contents, instead of displaying search results. |
| + * @type {?{about: boolean, basic: boolean, advanced: boolean}} |
|
Dan Beam
2016/08/11 05:32:34
can we typedef this?
dpapad
2016/08/11 18:20:03
Done.
|
| + * @private |
| + */ |
| + previousShowPages_: { |
| + type: Object, |
| + value: null, |
| + }, |
| + |
| /** @private */ |
| showNoResultsFound_: { |
| type: Boolean, |
| @@ -112,13 +124,12 @@ Polymer({ |
| }, |
| /** |
| - * @param {boolean} showBasicPage |
| - * @param {boolean} inSubpage |
| * @return {boolean} |
| * @private |
| */ |
| - showAdvancedToggle_: function(showBasicPage, inSubpage) { |
| - return showBasicPage && !inSubpage; |
| + showAdvancedToggle_: function() { |
|
Dan Beam
2016/08/11 05:32:34
nit:
var isSearching = !!this.previousShowPages_;
dpapad
2016/08/11 18:20:03
Done. I chose a slightly different name, inSearchM
|
| + return this.showPages_.basic && !this.inSubpage_ && |
| + !this.previousShowPages_; |
| }, |
| /** @protected */ |
| @@ -198,6 +209,12 @@ Polymer({ |
| * @return {!Promise} A promise indicating that searching finished. |
| */ |
| searchContents: function(query) { |
| + if (!this.previousShowPages_) { |
| + // Store which pages are shown before search, so that they can be restored |
| + // after the user clears the search results. |
| + this.previousShowPages_ = this.showPages_; |
| + } |
| + |
| this.ensureInDefaultSearchPage_(); |
| this.toolbarSpinnerActive = true; |
| @@ -223,8 +240,15 @@ Polymer({ |
| } |
| this.toolbarSpinnerActive = false; |
| + var showingSearchResults = !request.isSame(''); |
| this.showNoResultsFound_ = |
| - !request.isSame('') && !request.didFindMatches(); |
| + showingSearchResults && !request.didFindMatches(); |
| + |
| + if (!showingSearchResults) { |
| + // Restore the pages that were shown before search was initiated. |
| + this.showPages_ = assert(this.previousShowPages_); |
| + this.previousShowPages_ = null; |
| + } |
| }.bind(this)); |
| }.bind(this), 0); |
| }.bind(this)); |