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

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

Issue 2249933002: WebUI cr-dialog: Cancel dialog on any 'popstate' event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ensure we popstate before any route changes. Created 4 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
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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('settings', function() { 5 cr.define('settings', function() {
6 /** 6 /**
7 * Class for navigable routes. May only be instantiated within this file. 7 * Class for navigable routes. May only be instantiated within this file.
8 * @constructor 8 * @constructor
9 * @param {string} path 9 * @param {string} path
10 * @private 10 * @private
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 var params = opt_dynamicParameters || new URLSearchParams(); 327 var params = opt_dynamicParameters || new URLSearchParams();
328 328
329 var url = route.path; 329 var url = route.path;
330 if (opt_dynamicParameters) { 330 if (opt_dynamicParameters) {
331 var queryString = opt_dynamicParameters.toString(); 331 var queryString = opt_dynamicParameters.toString();
332 if (queryString) 332 if (queryString)
333 url += '?' + queryString; 333 url += '?' + queryString;
334 } 334 }
335 335
336 // History serializes the state, so we don't push the actual route object. 336 // History serializes the state, so we don't push the actual route object.
337 var previousRoutePath = currentRoute_.path; 337 window.history.pushState(currentRoute_.path, '', url);
338 setCurrentRoute(route, params); 338 setCurrentRoute(route, params);
339 window.history.pushState(previousRoutePath, '', url);
340 }; 339 };
341 340
342 window.addEventListener('popstate', function(event) { 341 window.addEventListener('popstate', function(event) {
343 // On pop state, do not push the state onto the window.history again. 342 // On pop state, do not push the state onto the window.history again.
344 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, 343 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC,
345 new URLSearchParams(window.location.search)); 344 new URLSearchParams(window.location.search));
346 }); 345 });
347 346
348 return { 347 return {
349 Route: Route, 348 Route: Route,
350 RouteObserverBehavior: RouteObserverBehavior, 349 RouteObserverBehavior: RouteObserverBehavior,
351 getRouteForPath: getRouteForPath, 350 getRouteForPath: getRouteForPath,
352 initializeRouteFromUrl: initializeRouteFromUrl, 351 initializeRouteFromUrl: initializeRouteFromUrl,
353 getCurrentRoute: getCurrentRoute, 352 getCurrentRoute: getCurrentRoute,
354 getQueryParameters: getQueryParameters, 353 getQueryParameters: getQueryParameters,
355 navigateTo: navigateTo, 354 navigateTo: navigateTo,
356 }; 355 };
357 }); 356 });
OLDNEW
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698