Chromium Code Reviews| 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 ceb5dab5be840a6da95a6a160fabe69ed0dc6523..df4e365eb79bb8b37d6d380ee80ae222e96070ec 100644 |
| --- a/chrome/browser/resources/md_history/history.js |
| +++ b/chrome/browser/resources/md_history/history.js |
| @@ -12,10 +12,6 @@ |
| */ |
| var BROWSING_GAP_TIME = 15 * 60 * 1000; |
| -window.addEventListener('load', function() { |
| - chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); |
| -}); |
| - |
| /** |
| * Our history system calls this function with results from searches. |
| * @param {HistoryQuery} info An object containing information about the query. |
| @@ -26,6 +22,24 @@ function historyResult(info, results) { |
| } |
| /** |
| + * Receives the synced history data. An empty list means that either there are |
| + * no foreign sessions, or tab sync is disabled for this profile. |
| + * |isTabSyncEnabled| makes it possible to distinguish between the cases. |
| + * |
| + * @param {Array} sessionList Array of objects describing the sessions |
| + * from other devices. |
| + * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
| + */ |
| +function setForeignSessions(sessionList, isTabSyncEnabled) { |
| + if (isTabSyncEnabled) { |
| + $('synced-device-manager').addSyncedHistory(sessionList); |
| + $('side-bar').hidden = false; |
| + } else { |
| + $('side-bar').hidden = true; |
| + } |
| +} |
| + |
| +/** |
| * Listens for history-item being selected or deselected (through checkbox) |
| * and changes the view of the top toolbar. |
| */ |
| @@ -58,3 +72,21 @@ window.addEventListener('keydown', function(e) { |
| window.addEventListener('resize', function() { |
| $('history-card-manager').closeMenu(); |
| }); |
| + |
| +/** |
| + * Switches between displaying history data and synced tabs data for the page. |
| + */ |
| +window.addEventListener('switch-display', function(e) { |
| + if (e.detail.display == 'history') { |
| + $('synced-device-manager').hidden = true; |
|
calamity
2016/02/02 04:09:47
Use $().hidden = e.detail.display == 'history' or
yingran
2016/02/09 04:21:34
Done.
|
| + $('history-card-manager').hidden = false; |
| + } else { |
| + $('history-card-manager').hidden = true; |
| + $('synced-device-manager').hidden = false; |
| + } |
| +}); |
| + |
| +window.addEventListener('load', function() { |
| + chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); |
| + chrome.send('getForeignSessions'); |
| +}); |