Chromium Code Reviews| Index: chrome/browser/resources/options/search_page.js |
| =================================================================== |
| --- chrome/browser/resources/options/search_page.js (revision 105946) |
| +++ chrome/browser/resources/options/search_page.js (working copy) |
| @@ -105,7 +105,6 @@ |
| function SearchPage() { |
| OptionsPage.call(this, 'search', templateData.searchPageTabTitle, |
| 'searchPage'); |
| - this.searchActive = false; |
| } |
| cr.addSingletonGetter(SearchPage); |
| @@ -145,7 +144,7 @@ |
| // Handle search events. (No need to throttle, WebKit's search field |
| // will do that automatically.) |
| searchField.onsearch = function(e) { |
| - self.setSearchText_(SearchPage.canonicalizeQuery(this.value)); |
| + self.setSearchText_(this.value); |
| }; |
| // We update the history stack every time the search field blurs. This way |
| @@ -284,6 +283,19 @@ |
| * @private |
| */ |
| setSearchText_: function(text) { |
| + // Prevent recursive execution of this method. |
| + if (this.insideSetSearchText_) return; |
| + this.insideSetSearchText_ = true; |
| + |
| + // Cleanup the search query string. |
| + text = SearchPage.canonicalizeQuery(text); |
| + |
| + // Notify listeners about the new search query, some pages may wish to |
| + // show/hide elements based on the query. |
| + var event = new cr.Event('searchChanged'); |
| + event.searchText = text; |
| + this.dispatchEvent(event); |
| + |
| // Toggle the search page if necessary. |
| if (text.length) { |
| if (!this.searchActive_) |
| @@ -291,6 +303,8 @@ |
| } else { |
| if (this.searchActive_) |
| OptionsPage.showDefaultPage(); |
| + |
| + this.insideSetSearchText_ = false; |
| return; |
| } |
| @@ -381,6 +395,9 @@ |
| length = bubbleControls.length; |
| for (var i = 0; i < length; i++) |
| this.createSearchBubble_(bubbleControls[i], text); |
| + |
| + // Cleanup the recursion-prevension variable. |
|
Finnur
2011/10/20 10:00:59
nit: typo: prevention, not prevension.
csilv
2011/10/20 17:49:13
Done.
|
| + this.insideSetSearchText_ = false; |
| }, |
| /** |