| Index: chrome/browser/resources/md_extensions/navigation_helper.js
|
| diff --git a/chrome/browser/resources/md_extensions/navigation_helper.js b/chrome/browser/resources/md_extensions/navigation_helper.js
|
| index 43e23820a89a1f45ef55aa445b31e9c14015b72f..d15ca599647902099a8a86091b3119c989129139 100644
|
| --- a/chrome/browser/resources/md_extensions/navigation_helper.js
|
| +++ b/chrome/browser/resources/md_extensions/navigation_helper.js
|
| @@ -31,26 +31,28 @@ cr.define('extensions', function() {
|
| * A helper object to manage in-page navigations. Since the extensions page
|
| * needs to support different urls for different subpages (like the details
|
| * page), we use this object to manage the history and url conversions.
|
| - * @param {!function(!PageState):void} onHistoryChange A function to call when
|
| - * the page has changed as a result of the user going back or forward in
|
| - * history; called with the new active page.
|
| - * @constructor */
|
| - function NavigationHelper(onHistoryChange) {
|
| - this.onHistoryChange_ = onHistoryChange;
|
| - window.addEventListener('popstate', this.onPopState_.bind(this));
|
| - }
|
| + */
|
| + class NavigationHelper {
|
| + /**
|
| + * @param {!function(!PageState):void} onHistoryChange A function to call
|
| + * when the page has changed as a result of the user going back or
|
| + * forward in history; called with the new active page.
|
| + */
|
| + constructor(onHistoryChange) {
|
| + this.onHistoryChange_ = onHistoryChange;
|
| + window.addEventListener('popstate', this.onPopState_.bind(this));
|
| + }
|
|
|
| - NavigationHelper.prototype = {
|
| /** @private */
|
| - onPopState_: function() {
|
| + onPopState_() {
|
| this.onHistoryChange_(this.getCurrentPage());
|
| - },
|
| + }
|
|
|
| /**
|
| - * Returns the page that should be displayed for the current URL.
|
| - * @return {!PageState}
|
| + * @return {!PageState} The page that should be displayed for the current
|
| + * URL.
|
| */
|
| - getCurrentPage: function() {
|
| + getCurrentPage() {
|
| var search = new URLSearchParams(location.search);
|
| var id = search.get('id');
|
| if (id)
|
| @@ -66,13 +68,13 @@ cr.define('extensions', function() {
|
| return {page: Page.SHORTCUTS};
|
|
|
| return {page: Page.LIST};
|
| - },
|
| + }
|
|
|
| /**
|
| * Called when a page changes, and pushes state to history to reflect it.
|
| * @param {!PageState} entry
|
| */
|
| - updateHistory: function(entry) {
|
| + updateHistory(entry) {
|
| var path;
|
| switch (entry.page) {
|
| case Page.LIST:
|
| @@ -106,8 +108,8 @@ cr.define('extensions', function() {
|
| history.replaceState(state, '', path);
|
| else
|
| history.pushState(state, '', path);
|
| - },
|
| - };
|
| + }
|
| + }
|
|
|
| return {NavigationHelper: NavigationHelper};
|
| });
|
|
|