Index: chrome/browser/resources/md_history/history.js |
diff --git a/chrome/browser/resources/md_history/history.js b/chrome/browser/resources/md_history/history.js |
index 4cce580cc9e8ccc0e21f3930cb76b28bed560a43..07ea5d27158d57e08f073d6069492a0b6d3aa46b 100644 |
--- a/chrome/browser/resources/md_history/history.js |
+++ b/chrome/browser/resources/md_history/history.js |
@@ -13,16 +13,21 @@ var upgradePromise = null; |
var resultsRendered = false; |
/** |
- * @return {!Promise} Resolves once the history-app has been fully upgraded. |
+ * @return {!Promise<!HistoryAppElement>} Resolves once the history-app has been |
+ * fully upgraded. |
*/ |
-function waitForAppUpgrade() { |
+function waitForHistoryApp() { |
if (!upgradePromise) { |
upgradePromise = new Promise(function(resolve, reject) { |
if (window.Polymer && Polymer.isInstance && |
- Polymer.isInstance($('history-app'))) { |
- resolve(); |
+ Polymer.isInstance(document.querySelector('history-app'))) { |
+ resolve(/** @type {!HistoryAppElement} */( |
+ document.querySelector('history-app'))); |
} else { |
- $('bundle').addEventListener('load', resolve); |
+ $('bundle').addEventListener('load', function() { |
+ resolve(/** @type {!HistoryAppElement} */( |
+ document.querySelector('history-app'))); |
+ }); |
} |
}); |
} |
@@ -37,9 +42,8 @@ function waitForAppUpgrade() { |
* @param {!Array<HistoryEntry>} results A list of results. |
*/ |
function historyResult(info, results) { |
- waitForAppUpgrade().then(function() { |
- /** @type {HistoryAppElement} */($('history-app')) |
- .historyResult(info, results); |
+ waitForHistoryApp().then(function(historyApp) { |
+ historyApp.historyResult(info, results); |
document.body.classList.remove('loading'); |
if (!resultsRendered) { |
@@ -69,9 +73,8 @@ function showNotification( |
// in the MD history anymore, so the parameter is not needed. Remove it |
// when WebUI is removed and this becomes the only client of |
// BrowsingHistoryHandler. |
- waitForAppUpgrade().then(function() { |
- /** @type {HistoryAppElement} */ ($('history-app')).showSidebarFooter = |
- includeOtherFormsOfBrowsingHistory; |
+ waitForHistoryApp().then(function(historyApp) { |
+ historyApp.showSidebarFooter = includeOtherFormsOfBrowsingHistory; |
}); |
} |
@@ -85,9 +88,8 @@ function showNotification( |
* @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
*/ |
function setForeignSessions(sessionList, isTabSyncEnabled) { |
- waitForAppUpgrade().then(function() { |
- /** @type {HistoryAppElement} */($('history-app')) |
- .setForeignSessions(sessionList, isTabSyncEnabled); |
+ waitForHistoryApp().then(function(historyApp) { |
+ historyApp.setForeignSessions(sessionList, isTabSyncEnabled); |
}); |
} |
@@ -102,8 +104,7 @@ function historyDeleted() { |
* @param {boolean} isUserSignedIn Whether user is signed in or not now. |
*/ |
function updateSignInState(isUserSignedIn) { |
- waitForAppUpgrade().then(function() { |
- /** @type {HistoryAppElement} */($('history-app')) |
- .updateSignInState(isUserSignedIn); |
+ waitForHistoryApp().then(function(historyApp) { |
+ historyApp.updateSignInState(isUserSignedIn); |
}); |
} |