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

Side by Side Diff: chrome/browser/resources/options/search_page.js

Issue 446093002: Don't pushState when setting the search page to itself. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 cr.define('options', function() { 5 cr.define('options', function() {
6 /** @const */ var Page = cr.ui.pageManager.Page; 6 /** @const */ var Page = cr.ui.pageManager.Page;
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager;
8 8
9 /** 9 /**
10 * Encapsulated handling of a search bubble. 10 * Encapsulated handling of a search bubble.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 * @private 260 * @private
261 */ 261 */
262 setSearchText_: function(text) { 262 setSearchText_: function(text) {
263 // Prevent recursive execution of this method. 263 // Prevent recursive execution of this method.
264 if (this.insideSetSearchText_) return; 264 if (this.insideSetSearchText_) return;
265 this.insideSetSearchText_ = true; 265 this.insideSetSearchText_ = true;
266 266
267 // Cleanup the search query string. 267 // Cleanup the search query string.
268 text = SearchPage.canonicalizeQuery(text); 268 text = SearchPage.canonicalizeQuery(text);
269 269
270 // Set the hash on the current page, and the enclosing uber page 270 // Set the hash on the current page, and the enclosing uber page. Only do
271 // this if the page is not current. See https://crbug.com/401004.
271 var hash = text ? '#' + encodeURIComponent(text) : ''; 272 var hash = text ? '#' + encodeURIComponent(text) : '';
272 var path = text ? this.name : ''; 273 var path = text ? this.name : '';
273 uber.pushState({}, path + hash); 274 if (location.hash != hash || location.pathname != '/' + path)
275 uber.pushState({}, path + hash);
274 276
275 // Toggle the search page if necessary. 277 // Toggle the search page if necessary.
276 if (text) { 278 if (text) {
277 if (!this.searchActive_) 279 if (!this.searchActive_)
278 PageManager.showPageByName(this.name, false); 280 PageManager.showPageByName(this.name, false);
279 } else { 281 } else {
280 if (this.searchActive_) 282 if (this.searchActive_)
281 PageManager.showDefaultPage(false); 283 PageManager.showDefaultPage(false);
282 284
283 this.insideSetSearchText_ = false; 285 this.insideSetSearchText_ = false;
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // Trim beginning and ending whitespace. 568 // Trim beginning and ending whitespace.
567 return text.replace(/^\s+|\s+$/g, ''); 569 return text.replace(/^\s+|\s+$/g, '');
568 }; 570 };
569 571
570 // Export 572 // Export
571 return { 573 return {
572 SearchPage: SearchPage 574 SearchPage: SearchPage
573 }; 575 };
574 576
575 }); 577 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698