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() { | 15 window.addEventListener('load', function() { |
| 16 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); | 16 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); |
| 17 }); | 17 }); |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * Our history system calls this function with results from searches. | |
| 21 * @param {HistoryQuery} info An object containing information about the query. | |
| 22 * @param {Array<HistoryEntry>} results A list of results. | |
| 23 */ | |
| 24 function historyResult(info, results) { | |
| 25 $('history-card-manager').addNewResults(results); | |
| 26 } | |
| 27 | |
| 28 /** | |
| 29 * Listens for history-item being selected or deselected (through checkbox) | 20 * Listens for history-item being selected or deselected (through checkbox) |
| 30 * and changes the view of the top toolbar. | 21 * and changes the view of the top toolbar. |
| 31 */ | 22 */ |
| 32 window.addEventListener('history-checkbox-select', function(e) { | 23 window.addEventListener('history-checkbox-select', function(e) { |
| 33 $('toolbar').count += e.detail.countAddition; | 24 $('toolbar').count += e.detail.countAddition; |
| 34 }); | 25 }); |
| 35 | 26 |
| 36 /** | 27 /** |
| 37 * Listens for call to cancel selection and loops through all items to set | 28 * Listens for call to cancel selection and loops through all items to set |
| 38 * checkbox to be unselected. | 29 * checkbox to be unselected. |
| 39 */ | 30 */ |
| 40 window.addEventListener('unselect-all', function() { | 31 window.addEventListener('unselect-all', function() { |
| 41 $('history-card-manager').unselectAllItems($('toolbar').count); | 32 $('history-card-manager').unselectAllItems($('toolbar').count); |
| 42 $('toolbar').count = 0; | 33 $('toolbar').count = 0; |
| 43 }); | 34 }); |
| 44 | 35 |
| 45 /** | 36 /** |
| 37 * Listens for call to delete all selected items and loops through all items to | |
| 38 * to determine which one are selected and deletes these. | |
|
calamity
2016/01/21 00:11:08
s/one/ones/
hsampson
2016/01/21 05:34:46
Done.
| |
| 39 */ | |
| 40 window.addEventListener('delete-selected', function() { | |
| 41 if (!loadTimeData.getBoolean('allowDeletingHistory')) { | |
| 42 return; | |
| 43 } | |
| 44 | |
| 45 // TODO(hsampson): add a popup to check whether the user definitely wants to | |
| 46 // delete the selected items. | |
| 47 | |
| 48 var toBeRemoved = $('history-card-manager').getItemsToDelete( | |
| 49 $('toolbar').count); | |
| 50 chrome.send('removeVisits', toBeRemoved); | |
| 51 }); | |
| 52 | |
| 53 /** | |
| 46 * Listens for any keyboard presses which will close the overflow menu. | 54 * Listens for any keyboard presses which will close the overflow menu. |
| 47 */ | 55 */ |
| 48 window.addEventListener('keydown', function(e) { | 56 window.addEventListener('keydown', function(e) { |
| 49 // Escape button on keyboard | 57 // Escape button on keyboard |
| 50 if (e.keyCode == 27) { | 58 if (e.keyCode == 27) { |
| 51 $('history-card-manager').closeMenu(); | 59 $('history-card-manager').closeMenu(); |
| 52 } | 60 } |
| 53 }); | 61 }); |
| 54 | 62 |
| 55 /** | 63 /** |
| 56 * Resizing browser window will cause the overflow menu to close. | 64 * Resizing browser window will cause the overflow menu to close. |
| 57 */ | 65 */ |
| 58 window.addEventListener('resize', function() { | 66 window.addEventListener('resize', function() { |
| 59 $('history-card-manager').closeMenu(); | 67 $('history-card-manager').closeMenu(); |
| 60 }); | 68 }); |
| 69 | |
| 70 // Chrome Callbacks------------------------------------------------------------- | |
|
calamity
2016/01/21 00:11:08
Woo, I heartily endorse this sectioning.
hsampson
2016/01/21 05:34:46
Yay!
| |
| 71 | |
| 72 /** | |
| 73 * Our history system calls this function with results from searches. | |
| 74 * @param {HistoryQuery} info An object containing information about the query. | |
| 75 * @param {Array<HistoryEntry>} results A list of results. | |
| 76 */ | |
| 77 function historyResult(info, results) { | |
| 78 $('history-card-manager').addNewResults(results); | |
| 79 } | |
| 80 | |
| 81 /** | |
| 82 * Called by the history backend when deletion was succesful. | |
| 83 */ | |
| 84 function deleteComplete() { | |
| 85 $('history-card-manager').removeDeletedHistory($('toolbar').count); | |
| 86 $('toolbar').count = 0; | |
| 87 } | |
| 88 | |
| 89 /** | |
| 90 * Called by the history backend when the deletion failed. | |
| 91 */ | |
| 92 function deleteFailed() { | |
| 93 window.console.log('Delete failed'); | |
|
calamity
2016/01/21 00:11:08
Should this still be here?
hsampson
2016/01/21 05:34:46
Done.
| |
| 94 } | |
| 95 | |
| 96 /** | |
| 97 * Called when the history is deleted by someone else. | |
| 98 */ | |
| 99 function historyDeleted() { | |
| 100 } | |
| OLD | NEW |