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

Side by Side Diff: chrome/browser/resources/settings/settings_main/settings_main.js

Issue 2449663002: MD Settings: Implement search URLs. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @typedef {{about: boolean, basic: boolean, advanced: boolean}} 6 * @typedef {{about: boolean, basic: boolean, advanced: boolean}}
7 */ 7 */
8 var MainPageVisibility; 8 var MainPageVisibility;
9 9
10 /** 10 /**
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 }, 79 },
80 80
81 /** 81 /**
82 * Dictionary defining page visibility. 82 * Dictionary defining page visibility.
83 * @type {!GuestModePageVisibility} 83 * @type {!GuestModePageVisibility}
84 */ 84 */
85 pageVisibility: { 85 pageVisibility: {
86 type: Object, 86 type: Object,
87 value: function() { return {}; }, 87 value: function() { return {}; },
88 }, 88 },
89
90 /** @private */
91 searchQuery: {
tommycli 2016/11/01 21:05:26 Looks like settings-ui is messing with this. In th
dpapad 2016/11/01 22:02:02 Removed searchQuery property per suggestion.
92 type: String,
93 value: '',
94 observer: 'searchQueryChanged_',
95 },
89 }, 96 },
90 97
91 /** @override */ 98 /** @override */
92 attached: function() { 99 attached: function() {
93 var currentRoute = settings.getCurrentRoute(); 100 var currentRoute = settings.getCurrentRoute();
94 this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage(); 101 this.hasExpandedSection_ = currentRoute && currentRoute.isSubpage();
95 }, 102 },
96 103
97 /** @private */ 104 /** @private */
98 overscrollChanged_: function() { 105 overscrollChanged_: function() {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // update hasExpandedSection_ to unhide the other sections. 206 // update hasExpandedSection_ to unhide the other sections.
200 if (!newRoute.isSubpage()) 207 if (!newRoute.isSubpage())
201 this.hasExpandedSection_ = false; 208 this.hasExpandedSection_ = false;
202 209
203 if (settings.Route.ADVANCED.contains(newRoute)) 210 if (settings.Route.ADVANCED.contains(newRoute))
204 this.advancedToggleExpanded = true; 211 this.advancedToggleExpanded = true;
205 212
206 this.updatePagesShown_(); 213 this.updatePagesShown_();
207 }, 214 },
208 215
216 /**
217 * @param {string} current
218 * @param {string} previous
219 * @private
220 */
221 searchQueryChanged_: function(current, previous) {
222 // Ignore change triggered by initialization.
223 if (previous == undefined)
224 return;
225
226 this.searchContents(this.searchQuery);
227 },
228
209 /** @private */ 229 /** @private */
210 onSubpageExpand_: function() { 230 onSubpageExpand_: function() {
211 // The subpage finished expanding fully. Hide pages other than the current 231 // The subpage finished expanding fully. Hide pages other than the current
212 // section's parent page. 232 // section's parent page.
213 this.hasExpandedSection_ = true; 233 this.hasExpandedSection_ = true;
214 this.updatePagesShown_(); 234 this.updatePagesShown_();
215 }, 235 },
216 236
217 /** 237 /**
218 * Updates the hidden state of the about, basic and advanced pages, based on 238 * Updates the hidden state of the about, basic and advanced pages, based on
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 this.$$('settings-advanced-page')); 326 this.$$('settings-advanced-page'));
307 } 327 }
308 if (settings.Route.BASIC.contains(route)) { 328 if (settings.Route.BASIC.contains(route)) {
309 return /** @type {?SettingsBasicPageElement} */( 329 return /** @type {?SettingsBasicPageElement} */(
310 this.$$('settings-basic-page')); 330 this.$$('settings-basic-page'));
311 } 331 }
312 assertNotReached(); 332 assertNotReached();
313 }, 333 },
314 334
315 /** 335 /**
316 * Navigates to the default search page (if necessary).
317 * @private
318 */
319 ensureInDefaultSearchPage_: function() {
320 if (settings.getCurrentRoute() != settings.Route.BASIC)
321 settings.navigateTo(settings.Route.BASIC);
322 },
323
324 /**
325 * @param {string} query 336 * @param {string} query
326 * @return {!Promise} A promise indicating that searching finished. 337 * @return {!Promise} A promise indicating that searching finished.
327 */ 338 */
328 searchContents: function(query) { 339 searchContents: function(query) {
329 // Trigger rendering of the basic and advanced pages and search once ready. 340 // Trigger rendering of the basic and advanced pages and search once ready.
330 this.inSearchMode_ = true; 341 this.inSearchMode_ = true;
331 this.ensureInDefaultSearchPage_();
332 this.toolbarSpinnerActive = true; 342 this.toolbarSpinnerActive = true;
333 343
334 return new Promise(function(resolve, reject) { 344 return new Promise(function(resolve, reject) {
335 setTimeout(function() { 345 setTimeout(function() {
336 var whenSearchDone = settings.getSearchManager().search( 346 var whenSearchDone = settings.getSearchManager().search(
337 query, assert(this.getPage_(settings.Route.BASIC))); 347 query, assert(this.getPage_(settings.Route.BASIC)));
338 assert( 348 assert(
339 whenSearchDone === 349 whenSearchDone ===
340 settings.getSearchManager().search( 350 settings.getSearchManager().search(
341 query, assert(this.getPage_(settings.Route.ADVANCED)))); 351 query, assert(this.getPage_(settings.Route.ADVANCED))));
(...skipping 18 matching lines...) Expand all
360 370
361 /** 371 /**
362 * @param {(boolean|undefined)} visibility 372 * @param {(boolean|undefined)} visibility
363 * @return {boolean} True unless visibility is false. 373 * @return {boolean} True unless visibility is false.
364 * @private 374 * @private
365 */ 375 */
366 showAdvancedSettings_: function(visibility) { 376 showAdvancedSettings_: function(visibility) {
367 return visibility !== false; 377 return visibility !== false;
368 }, 378 },
369 }); 379 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698