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

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

Issue 2442843002: Override SigninManager::SignOut if force-signin is enabled. (Closed)
Patch Set: 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 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 if (queryString) 327 if (queryString)
328 url += '?' + queryString; 328 url += '?' + queryString;
329 } 329 }
330 330
331 // History serializes the state, so we don't push the actual route object. 331 // History serializes the state, so we don't push the actual route object.
332 window.history.pushState(currentRoute_.path, '', url); 332 window.history.pushState(currentRoute_.path, '', url);
333 setCurrentRoute(route, params, false); 333 setCurrentRoute(route, params, false);
334 }; 334 };
335 335
336 /** 336 /**
337 * Return true if the previous route exsited in the history and has an equal
338 * or lesser depth. Otherwise, return false.
339 */
340 var isPreviousRouteExistedInHistory = function() {
341 var previousRoute =
342 window.history.state &&
343 assert(getRouteForPath(/** @type {string} */ (window.history.state)));
344 return previousRoute && previousRoute.depth <= currentRoute_.depth;
345 };
346
347 /**
337 * Navigates to the previous route if it has an equal or lesser depth. 348 * Navigates to the previous route if it has an equal or lesser depth.
338 * If there is no previous route in history meeting those requirements, 349 * If there is no previous route in history meeting those requirements,
339 * this navigates to the immediate parent. This will never exit Settings. 350 * this navigates to the immediate parent. This will never exit Settings.
340 */ 351 */
341 var navigateToPreviousRoute = function() { 352 var navigateToPreviousRoute = function() {
342 var previousRoute = 353 if (isPreviousRouteExistedInHistory())
tommycli 2016/11/02 18:46:57 I'm sorry - but I just don't think this is a good
343 window.history.state &&
344 assert(getRouteForPath(/** @type {string} */ (window.history.state)));
345
346 if (previousRoute && previousRoute.depth <= currentRoute_.depth)
347 window.history.back(); 354 window.history.back();
348 else 355 else
349 navigateTo(currentRoute_.parent || Route.BASIC); 356 navigateTo(currentRoute_.parent || Route.BASIC);
350 }; 357 };
351 358
352 window.addEventListener('popstate', function(event) { 359 window.addEventListener('popstate', function(event) {
353 // On pop state, do not push the state onto the window.history again. 360 // On pop state, do not push the state onto the window.history again.
354 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC, 361 setCurrentRoute(getRouteForPath(window.location.pathname) || Route.BASIC,
355 new URLSearchParams(window.location.search), true); 362 new URLSearchParams(window.location.search), true);
356 }); 363 });
357 364
358 return { 365 return {
359 Route: Route, 366 Route: Route,
360 RouteObserverBehavior: RouteObserverBehavior, 367 RouteObserverBehavior: RouteObserverBehavior,
361 getRouteForPath: getRouteForPath, 368 getRouteForPath: getRouteForPath,
362 initializeRouteFromUrl: initializeRouteFromUrl, 369 initializeRouteFromUrl: initializeRouteFromUrl,
363 getCurrentRoute: getCurrentRoute, 370 getCurrentRoute: getCurrentRoute,
364 getQueryParameters: getQueryParameters, 371 getQueryParameters: getQueryParameters,
365 lastRouteChangeWasPopstate: lastRouteChangeWasPopstate, 372 lastRouteChangeWasPopstate: lastRouteChangeWasPopstate,
366 navigateTo: navigateTo, 373 navigateTo: navigateTo,
374 isPreviousRouteExistedInHistory: isPreviousRouteExistedInHistory,
367 navigateToPreviousRoute: navigateToPreviousRoute, 375 navigateToPreviousRoute: navigateToPreviousRoute,
368 }; 376 };
369 }); 377 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698