| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Globals: | 5 // Globals: |
| 6 /** @const */ var RESULTS_PER_PAGE = 150; | 6 /** @const */ var RESULTS_PER_PAGE = 150; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Amount of time between pageviews that we consider a 'break' in browsing, | 9 * Amount of time between pageviews that we consider a 'break' in browsing, |
| 10 * measured in milliseconds. | 10 * measured in milliseconds. |
| 11 * @const | 11 * @const |
| 12 */ | 12 */ |
| 13 var BROWSING_GAP_TIME = 15 * 60 * 1000; | 13 var BROWSING_GAP_TIME = 15 * 60 * 1000; |
| 14 | 14 |
| 15 window.addEventListener('load', function() { | |
| 16 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); | |
| 17 }); | |
| 18 | |
| 19 /** | 15 /** |
| 20 * Listens for history-item being selected or deselected (through checkbox) | 16 * Listens for history-item being selected or deselected (through checkbox) |
| 21 * and changes the view of the top toolbar. | 17 * and changes the view of the top toolbar. |
| 22 */ | 18 */ |
| 23 window.addEventListener('history-checkbox-select', function(e) { | 19 window.addEventListener('history-checkbox-select', function(e) { |
| 24 $('toolbar').count += e.detail.countAddition; | 20 $('toolbar').count += e.detail.countAddition; |
| 25 }); | 21 }); |
| 26 | 22 |
| 27 /** | 23 /** |
| 28 * Listens for call to cancel selection and loops through all items to set | 24 * Listens for call to cancel selection and loops through all items to set |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 56 } |
| 61 }); | 57 }); |
| 62 | 58 |
| 63 /** | 59 /** |
| 64 * Resizing browser window will cause the overflow menu to close. | 60 * Resizing browser window will cause the overflow menu to close. |
| 65 */ | 61 */ |
| 66 window.addEventListener('resize', function() { | 62 window.addEventListener('resize', function() { |
| 67 $('history-list').closeMenu(); | 63 $('history-list').closeMenu(); |
| 68 }); | 64 }); |
| 69 | 65 |
| 66 /** |
| 67 * Switches between displaying history data and synced tabs data for the page. |
| 68 */ |
| 69 window.addEventListener('switch-display', function(e) { |
| 70 $('history-synced-device-manager').hidden = |
| 71 e.detail.display != 'synced-tabs-button'; |
| 72 $('history-list').hidden = e.detail.display != 'history-button'; |
| 73 }); |
| 74 |
| 75 window.addEventListener('load', function() { |
| 76 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); |
| 77 chrome.send('getForeignSessions'); |
| 78 }); |
| 79 |
| 70 // Chrome Callbacks------------------------------------------------------------- | 80 // Chrome Callbacks------------------------------------------------------------- |
| 71 | 81 |
| 72 /** | 82 /** |
| 73 * Our history system calls this function with results from searches. | 83 * Our history system calls this function with results from searches. |
| 74 * @param {HistoryQuery} info An object containing information about the query. | 84 * @param {HistoryQuery} info An object containing information about the query. |
| 75 * @param {Array<HistoryEntry>} results A list of results. | 85 * @param {Array<HistoryEntry>} results A list of results. |
| 76 */ | 86 */ |
| 77 function historyResult(info, results) { | 87 function historyResult(info, results) { |
| 78 $('history-list').addNewResults(results); | 88 $('history-list').addNewResults(results); |
| 79 if (info.finished) | 89 if (info.finished) |
| 80 $('history-list').disableResultLoading(); | 90 $('history-list').disableResultLoading(); |
| 81 } | 91 } |
| 82 | 92 |
| 83 /** | 93 /** |
| 94 * Receives the synced history data. An empty list means that either there are |
| 95 * no foreign sessions, or tab sync is disabled for this profile. |
| 96 * |isTabSyncEnabled| makes it possible to distinguish between the cases. |
| 97 * |
| 98 * @param {Array<Session>} sessionList Array of objects describing the sessions |
| 99 * from other devices. |
| 100 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? |
| 101 */ |
| 102 function setForeignSessions(sessionList, isTabSyncEnabled) { |
| 103 // TODO(calamity): Add a 'no synced devices' message when sessions are empty. |
| 104 $('history-side-bar').hidden = !isTabSyncEnabled; |
| 105 if (isTabSyncEnabled) |
| 106 $('history-synced-device-manager').addSyncedHistory(sessionList); |
| 107 } |
| 108 |
| 109 /** |
| 84 * Called by the history backend when deletion was succesful. | 110 * Called by the history backend when deletion was succesful. |
| 85 */ | 111 */ |
| 86 function deleteComplete() { | 112 function deleteComplete() { |
| 87 $('history-list').removeDeletedHistory($('toolbar').count); | 113 $('history-list').removeDeletedHistory($('toolbar').count); |
| 88 $('toolbar').count = 0; | 114 $('toolbar').count = 0; |
| 89 } | 115 } |
| 90 | 116 |
| 91 /** | 117 /** |
| 92 * Called by the history backend when the deletion failed. | 118 * Called by the history backend when the deletion failed. |
| 93 */ | 119 */ |
| 94 function deleteFailed() { | 120 function deleteFailed() { |
| 95 } | 121 } |
| 96 | 122 |
| 97 /** | 123 /** |
| 98 * Called when the history is deleted by someone else. | 124 * Called when the history is deleted by someone else. |
| 99 */ | 125 */ |
| 100 function historyDeleted() { | 126 function historyDeleted() { |
| 101 } | 127 } |
| OLD | NEW |