Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2449663002: MD Settings: Implement search URLs. (Closed)
Patch Set: Register listener earlier. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 d090cdedbb16ce619799256543678264361d0e9d..3cc721051c8c3d425bb11e5819b3b78bacd5c6e3 100644
--- a/chrome/browser/resources/settings/settings_main/settings_main.js
+++ b/chrome/browser/resources/settings/settings_main/settings_main.js
@@ -194,7 +194,19 @@ Polymer({
},
/** @param {!settings.Route} newRoute */
- currentRouteChanged: function(newRoute) {
+ currentRouteChanged: function(newRoute, previousRoute) {
+ // Don't issue any new search requests, if the current page is a subpage or
+ // if user returns to a top-level from a subpage, since the search hits are
+ // already highlighted.
+ if (!newRoute.isSubpage() &&
dpapad 2016/10/27 17:39:58 As I was explaining this logic to Tommy, he found
+ (!previousRoute || !previousRoute.isSubpage())) {
+ var searchQuery = settings.getQueryParameters().get('search') || '';
+ if (searchQuery)
+ this.searchContents_(searchQuery);
+ else if (this.inSearchMode_)
+ this.searchContents_('');
+ }
+
// When the route changes from a sub-page to the main page, immediately
// update hasExpandedSection_ to unhide the other sections.
if (!newRoute.isSubpage())
@@ -313,22 +325,12 @@ Polymer({
},
/**
- * Navigates to the default search page (if necessary).
- * @private
- */
- ensureInDefaultSearchPage_: function() {
- if (settings.getCurrentRoute() != settings.Route.BASIC)
- settings.navigateTo(settings.Route.BASIC);
- },
-
- /**
* @param {string} query
* @return {!Promise} A promise indicating that searching finished.
*/
- searchContents: function(query) {
+ searchContents_: function(query) {
// Trigger rendering of the basic and advanced pages and search once ready.
this.inSearchMode_ = true;
- this.ensureInDefaultSearchPage_();
this.toolbarSpinnerActive = true;
return new Promise(function(resolve, reject) {

Powered by Google App Engine
This is Rietveld 408576698