Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: chrome/browser/resources/md_history/history.js

Issue 1607403004: MD History: Display synced tabs history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@second_patch
Patch Set: Changed switching between pages & addressed comments Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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-card-manager').closeMenu(); 63 $('history-card-manager').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 == 'history-button';
71 $('history-card-manager').hidden = e.detail.display == 'synced-tabs-button';
calamity 2016/02/11 00:23:31 Invert this. $('synced..').hidden = ... != 'synce
yingran 2016/02/11 02:06:36 Done.
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-card-manager').addNewResults(results); 87 $('history-card-manager').addNewResults(results);
79 } 88 }
80 89
81 /** 90 /**
91 * Receives the synced history data. An empty list means that either there are
92 * no foreign sessions, or tab sync is disabled for this profile.
93 * |isTabSyncEnabled| makes it possible to distinguish between the cases.
94 *
95 * @param {Array} sessionList Array of objects describing the sessions
96 * from other devices.
97 * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile?
98 */
99 function setForeignSessions(sessionList, isTabSyncEnabled) {
100 if (isTabSyncEnabled) {
101 $('synced-device-manager').addSyncedHistory(sessionList);
102 $('side-bar').hidden = false;
103 } else {
104 $('side-bar').hidden = true;
105 }
calamity 2016/02/11 00:23:31 This whole thing would be shorter if you extracted
yingran 2016/02/11 02:06:36 Done.
106 }
107
108 /**
82 * Called by the history backend when deletion was succesful. 109 * Called by the history backend when deletion was succesful.
83 */ 110 */
84 function deleteComplete() { 111 function deleteComplete() {
85 $('history-card-manager').removeDeletedHistory($('toolbar').count); 112 $('history-card-manager').removeDeletedHistory($('toolbar').count);
86 $('toolbar').count = 0; 113 $('toolbar').count = 0;
87 } 114 }
88 115
89 /** 116 /**
90 * Called by the history backend when the deletion failed. 117 * Called by the history backend when the deletion failed.
91 */ 118 */
92 function deleteFailed() { 119 function deleteFailed() {
93 } 120 }
94 121
95 /** 122 /**
96 * Called when the history is deleted by someone else. 123 * Called when the history is deleted by someone else.
97 */ 124 */
98 function historyDeleted() { 125 function historyDeleted() {
99 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698