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

Unified Diff: chrome/browser/resources/md_extensions/navigation_helper.js

Issue 2960293002: MD Extensions: Convert classes to use ES6 class syntax. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
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};
});
« no previous file with comments | « chrome/browser/resources/md_extensions/manager.js ('k') | chrome/browser/resources/md_extensions/service.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698