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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_history/history.js
diff --git a/chrome/browser/resources/md_history/history.js b/chrome/browser/resources/md_history/history.js
index ae6da278a7d8760938ccae0a38caeff0f5b6d49e..830aaaa5450dd99fad6a966102e12612c163ba67 100644
--- a/chrome/browser/resources/md_history/history.js
+++ b/chrome/browser/resources/md_history/history.js
@@ -12,10 +12,6 @@
*/
var BROWSING_GAP_TIME = 15 * 60 * 1000;
-window.addEventListener('load', function() {
- chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]);
-});
-
/**
* Listens for history-item being selected or deselected (through checkbox)
* and changes the view of the top toolbar.
@@ -67,6 +63,19 @@ window.addEventListener('resize', function() {
$('history-card-manager').closeMenu();
});
+/**
+ * Switches between displaying history data and synced tabs data for the page.
+ */
+window.addEventListener('switch-display', function(e) {
+ $('synced-device-manager').hidden = e.detail.display == 'history-button';
+ $('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.
+});
+
+window.addEventListener('load', function() {
+ chrome.send('queryHistory', ['', 0, 0, 0, RESULTS_PER_PAGE]);
+ chrome.send('getForeignSessions');
+});
+
// Chrome Callbacks-------------------------------------------------------------
/**
@@ -79,6 +88,24 @@ function historyResult(info, results) {
}
/**
+ * Receives the synced history data. An empty list means that either there are
+ * no foreign sessions, or tab sync is disabled for this profile.
+ * |isTabSyncEnabled| makes it possible to distinguish between the cases.
+ *
+ * @param {Array} sessionList Array of objects describing the sessions
+ * from other devices.
+ * @param {boolean} isTabSyncEnabled Is tab sync enabled for this profile?
+ */
+function setForeignSessions(sessionList, isTabSyncEnabled) {
+ if (isTabSyncEnabled) {
+ $('synced-device-manager').addSyncedHistory(sessionList);
+ $('side-bar').hidden = false;
+ } else {
+ $('side-bar').hidden = true;
+ }
calamity 2016/02/11 00:23:31 This whole thing would be shorter if you extracted
yingran 2016/02/11 02:06:36 Done.
+}
+
+/**
* Called by the history backend when deletion was succesful.
*/
function deleteComplete() {

Powered by Google App Engine
This is Rietveld 408576698