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 * Our history system calls this function with results from searches. | 16 * Our history system calls this function with results from searches. |
| 21 * @param {HistoryQuery} info An object containing information about the query. | 17 * @param {HistoryQuery} info An object containing information about the query. |
| 22 * @param {Array<HistoryEntry>} results A list of results. | 18 * @param {Array<HistoryEntry>} results A list of results. |
| 23 */ | 19 */ |
| 24 function historyResult(info, results) { | 20 function historyResult(info, results) { |
| 25 $('history-card-manager').addNewResults(results); | 21 $('history-card-manager').addNewResults(results); |
| 26 } | 22 } |
| 27 | 23 |
| 28 /** | 24 /** |
| 25 * Receives the synced history data. An empty list means that either there are | |
| 26 * no foreign sessions, or tab sync is disabled for this profile. | |
| 27 * |isTabSyncEnabled| makes it possible to distinguish between the cases. | |
| 28 * | |
| 29 * @param {Array} sessionList Array of objects describing the sessions | |
| 30 * from other devices. | |
| 31 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile? | |
| 32 */ | |
| 33 function setForeignSessions(sessionList, isTabSyncEnabled) { | |
| 34 if (isTabSyncEnabled) { | |
| 35 $('synced-device-manager').addSyncedHistory(sessionList); | |
| 36 $('side-bar').hidden = false; | |
| 37 } else { | |
| 38 $('side-bar').hidden = true; | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 /** | |
| 29 * Listens for history-item being selected or deselected (through checkbox) | 43 * Listens for history-item being selected or deselected (through checkbox) |
| 30 * and changes the view of the top toolbar. | 44 * and changes the view of the top toolbar. |
| 31 */ | 45 */ |
| 32 window.addEventListener('history-checkbox-select', function(e) { | 46 window.addEventListener('history-checkbox-select', function(e) { |
| 33 $('toolbar').count += e.detail.countAddition; | 47 $('toolbar').count += e.detail.countAddition; |
| 34 }); | 48 }); |
| 35 | 49 |
| 36 /** | 50 /** |
| 37 * Listens for call to cancel selection and loops through all items to set | 51 * Listens for call to cancel selection and loops through all items to set |
| 38 * checkbox to be unselected. | 52 * checkbox to be unselected. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 51 $('history-card-manager').closeMenu(); | 65 $('history-card-manager').closeMenu(); |
| 52 } | 66 } |
| 53 }); | 67 }); |
| 54 | 68 |
| 55 /** | 69 /** |
| 56 * Resizing browser window will cause the overflow menu to close. | 70 * Resizing browser window will cause the overflow menu to close. |
| 57 */ | 71 */ |
| 58 window.addEventListener('resize', function() { | 72 window.addEventListener('resize', function() { |
| 59 $('history-card-manager').closeMenu(); | 73 $('history-card-manager').closeMenu(); |
| 60 }); | 74 }); |
| 75 | |
| 76 /** | |
| 77 * Switches between displaying history data and synced tabs data for the page. | |
| 78 */ | |
| 79 window.addEventListener('switch-display', function(e) { | |
| 80 if (e.detail.display == 'history') { | |
| 81 $('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.
| |
| 82 $('history-card-manager').hidden = false; | |
| 83 } else { | |
| 84 $('history-card-manager').hidden = true; | |
| 85 $('synced-device-manager').hidden = false; | |
| 86 } | |
| 87 }); | |
| 88 | |
| 89 window.addEventListener('load', function() { | |
| 90 chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]); | |
| 91 chrome.send('getForeignSessions'); | |
| 92 }); | |
| OLD | NEW |