Chromium Code Reviews| 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 $('synced-device-manager').hidden = e.detail.display != 'synced-tabs-button'; | |
|
tsergeant
2016/03/01 03:58:22
Did you experiment with using something other than
calamity
2016/03/08 02:46:51
I looked into it. It didn't work out so well. This
| |
| 71 $('history-list').hidden = e.detail.display != 'history-button'; | |
| 72 }); | |
| 73 | |
| 74 window.addEventListener('load', function() { | |
| 75 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); | |
| 76 chrome.send('getForeignSessions'); | |
| 77 }); | |
| 78 | |
| 70 // Chrome Callbacks------------------------------------------------------------- | 79 // Chrome Callbacks------------------------------------------------------------- |
| 71 | 80 |
| 72 /** | 81 /** |
| 73 * Our history system calls this function with results from searches. | 82 * Our history system calls this function with results from searches. |
| 74 * @param {HistoryQuery} info An object containing information about the query. | 83 * @param {HistoryQuery} info An object containing information about the query. |
| 75 * @param {Array<HistoryEntry>} results A list of results. | 84 * @param {Array<HistoryEntry>} results A list of results. |
| 76 */ | 85 */ |
| 77 function historyResult(info, results) { | 86 function historyResult(info, results) { |
| 78 $('history-list').addNewResults(results); | 87 $('history-list').addNewResults(results); |
| 79 if (info.finished) | 88 if (info.finished) |
| 80 $('history-list').disableResultLoading(); | 89 $('history-list').disableResultLoading(); |
| 81 } | 90 } |
| 82 | 91 |
| 83 /** | 92 /** |
| 93 * Receives the synced history data. An empty list means that either there are | |
| 94 * no foreign sessions, or tab sync is disabled for this profile. | |
|
tsergeant
2016/03/01 03:58:22
This means that it's possible to have no foreign s
calamity
2016/03/08 02:46:51
Good pointâ„¢.
| |
| 95 * |isTabSyncEnabled| makes it possible to distinguish between the cases. | |
| 96 * | |
| 97 * @param {Array<Session>} sessionList Array of objects describing the sessions | |
| 98 * from other devices. | |
| 99 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? | |
| 100 */ | |
| 101 function setForeignSessions(sessionList, isTabSyncEnabled) { | |
| 102 $('side-bar').hidden = !isTabSyncEnabled; | |
| 103 if (isTabSyncEnabled) { | |
|
tsergeant
2016/03/01 03:58:22
Nit: {}
calamity
2016/03/08 02:46:51
Done.
| |
| 104 $('synced-device-manager').addSyncedHistory(sessionList); | |
| 105 } | |
| 106 } | |
| 107 | |
| 108 /** | |
| 84 * Called by the history backend when deletion was succesful. | 109 * Called by the history backend when deletion was succesful. |
| 85 */ | 110 */ |
| 86 function deleteComplete() { | 111 function deleteComplete() { |
| 87 $('history-list').removeDeletedHistory($('toolbar').count); | 112 $('history-list').removeDeletedHistory($('toolbar').count); |
| 88 $('toolbar').count = 0; | 113 $('toolbar').count = 0; |
| 89 } | 114 } |
| 90 | 115 |
| 91 /** | 116 /** |
| 92 * Called by the history backend when the deletion failed. | 117 * Called by the history backend when the deletion failed. |
| 93 */ | 118 */ |
| 94 function deleteFailed() { | 119 function deleteFailed() { |
| 95 } | 120 } |
| 96 | 121 |
| 97 /** | 122 /** |
| 98 * Called when the history is deleted by someone else. | 123 * Called when the history is deleted by someone else. |
| 99 */ | 124 */ |
| 100 function historyDeleted() { | 125 function historyDeleted() { |
| 101 } | 126 } |
| OLD | NEW |