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

Side by Side Diff: chrome/browser/resources/md_history/app.crisper.js

Issue 2251323002: MD History: Synced Tabs fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history_css_shuffle
Patch Set: Review comment, revulcanize Created 4 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/md_history/app.vulcanized.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview PromiseResolver is a helper class that allows creating a 6 * @fileoverview PromiseResolver is a helper class that allows creating a
7 * Promise that will be fulfilled (resolved or rejected) some time later. 7 * Promise that will be fulfilled (resolved or rejected) some time later.
8 * 8 *
9 * Example: 9 * Example:
10 * var resolver = new PromiseResolver(); 10 * var resolver = new PromiseResolver();
(...skipping 14593 matching lines...) Expand 10 before | Expand all | Expand 10 after
14604 14604
14605 /** 14605 /**
14606 * The indexes where a window separator should be shown. The use of a 14606 * The indexes where a window separator should be shown. The use of a
14607 * separate array here is necessary for window separators to appear 14607 * separate array here is necessary for window separators to appear
14608 * correctly in search. See http://crrev.com/2022003002 for more details. 14608 * correctly in search. See http://crrev.com/2022003002 for more details.
14609 * @type {!Array<number>} 14609 * @type {!Array<number>}
14610 */ 14610 */
14611 separatorIndexes: Array, 14611 separatorIndexes: Array,
14612 14612
14613 // Whether the card is open. 14613 // Whether the card is open.
14614 cardOpen_: {type: Boolean, value: true}, 14614 opened: Boolean,
14615 14615
14616 searchTerm: String, 14616 searchTerm: String,
14617 14617
14618 // Internal identifier for the device. 14618 // Internal identifier for the device.
14619 sessionTag: String, 14619 sessionTag: String,
14620 }, 14620 },
14621 14621
14622 /** 14622 /**
14623 * Open a single synced tab. Listens to 'click' rather than 'tap' 14623 * Open a single synced tab. Listens to 'click' rather than 'tap'
14624 * to determine what modifier keys were pressed. 14624 * to determine what modifier keys were pressed.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
14656 } 14656 }
14657 }); 14657 });
14658 }, 14658 },
14659 14659
14660 /** @private */ 14660 /** @private */
14661 isWindowSeparatorIndex_: function(index, separatorIndexes) { 14661 isWindowSeparatorIndex_: function(index, separatorIndexes) {
14662 return this.separatorIndexes.indexOf(index) != -1; 14662 return this.separatorIndexes.indexOf(index) != -1;
14663 }, 14663 },
14664 14664
14665 /** 14665 /**
14666 * @param {boolean} cardOpen 14666 * @param {boolean} opened
14667 * @return {string} 14667 * @return {string}
14668 * @private
14668 */ 14669 */
14669 getCollapseTitle_: function(cardOpen) { 14670 getCollapseIcon_: function(opened) {
14670 return cardOpen ? loadTimeData.getString('collapseSessionButton') : 14671 return opened ? 'cr:expand-less' : 'cr:expand-more';
14671 loadTimeData.getString('expandSessionButton');
14672 }, 14672 },
14673 14673
14674 /** 14674 /**
14675 * @param {boolean} opened
14676 * @return {string}
14677 * @private
14678 */
14679 getCollapseTitle_: function(opened) {
14680 return opened ? loadTimeData.getString('collapseSessionButton') :
14681 loadTimeData.getString('expandSessionButton');
14682 },
14683
14684 /**
14675 * @param {CustomEvent} e 14685 * @param {CustomEvent} e
14676 * @private 14686 * @private
14677 */ 14687 */
14678 onMenuButtonTap_: function(e) { 14688 onMenuButtonTap_: function(e) {
14679 this.fire('toggle-menu', { 14689 this.fire('toggle-menu', {
14680 target: Polymer.dom(e).localTarget, 14690 target: Polymer.dom(e).localTarget,
14681 tag: this.sessionTag 14691 tag: this.sessionTag
14682 }); 14692 });
14683 e.stopPropagation(); // Prevent iron-collapse. 14693 e.stopPropagation(); // Prevent iron-collapse.
14684 }, 14694 },
14685 }); 14695 });
14686 // Copyright 2016 The Chromium Authors. All rights reserved. 14696 // Copyright 2016 The Chromium Authors. All rights reserved.
14687 // Use of this source code is governed by a BSD-style license that can be 14697 // Use of this source code is governed by a BSD-style license that can be
14688 // found in the LICENSE file. 14698 // found in the LICENSE file.
14689 14699
14690 /** 14700 /**
14691 * @typedef {{device: string, 14701 * @typedef {{device: string,
14692 * lastUpdateTime: string, 14702 * lastUpdateTime: string,
14703 * opened: boolean,
14693 * separatorIndexes: !Array<number>, 14704 * separatorIndexes: !Array<number>,
14694 * timestamp: number, 14705 * timestamp: number,
14695 * tabs: !Array<!ForeignSessionTab>, 14706 * tabs: !Array<!ForeignSessionTab>,
14696 * tag: string}} 14707 * tag: string}}
14697 */ 14708 */
14698 var ForeignDeviceInternal; 14709 var ForeignDeviceInternal;
14699 14710
14700 Polymer({ 14711 Polymer({
14701 is: 'history-synced-device-manager', 14712 is: 'history-synced-device-manager',
14702 14713
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
14737 14748
14738 /** @private */ 14749 /** @private */
14739 fetchingSyncedTabs_: { 14750 fetchingSyncedTabs_: {
14740 type: Boolean, 14751 type: Boolean,
14741 value: false, 14752 value: false,
14742 } 14753 }
14743 }, 14754 },
14744 14755
14745 listeners: { 14756 listeners: {
14746 'toggle-menu': 'onToggleMenu_', 14757 'toggle-menu': 'onToggleMenu_',
14758 'scroll': 'onListScroll_'
14747 }, 14759 },
14748 14760
14749 /** @override */ 14761 /** @override */
14750 attached: function() { 14762 attached: function() {
14751 // Update the sign in state. 14763 // Update the sign in state.
14752 chrome.send('otherDevicesInitialized'); 14764 chrome.send('otherDevicesInitialized');
14753 }, 14765 },
14754 14766
14755 /** 14767 /**
14756 * @param {!ForeignSession} session 14768 * @param {!ForeignSession} session
(...skipping 26 matching lines...) Expand all
14783 windowAdded = true; 14795 windowAdded = true;
14784 } 14796 }
14785 } 14797 }
14786 } 14798 }
14787 if (windowAdded && i != session.windows.length - 1) 14799 if (windowAdded && i != session.windows.length - 1)
14788 separatorIndexes.push(tabs.length - 1); 14800 separatorIndexes.push(tabs.length - 1);
14789 } 14801 }
14790 return { 14802 return {
14791 device: session.name, 14803 device: session.name,
14792 lastUpdateTime: '– ' + session.modifiedTime, 14804 lastUpdateTime: '– ' + session.modifiedTime,
14805 opened: true,
14793 separatorIndexes: separatorIndexes, 14806 separatorIndexes: separatorIndexes,
14794 timestamp: session.timestamp, 14807 timestamp: session.timestamp,
14795 tabs: tabs, 14808 tabs: tabs,
14796 tag: session.tag, 14809 tag: session.tag,
14797 }; 14810 };
14798 }, 14811 },
14799 14812
14800 onSignInTap_: function() { 14813 onSignInTap_: function() {
14801 chrome.send('startSignInFlow'); 14814 chrome.send('startSignInFlow');
14802 }, 14815 },
14803 14816
14817 onListScroll_: function() {
14818 var menu = this.$.menu.getIfExists();
14819 if (menu)
14820 menu.closeMenu();
14821 },
14822
14804 onToggleMenu_: function(e) { 14823 onToggleMenu_: function(e) {
14805 this.$.menu.get().then(function(menu) { 14824 this.$.menu.get().then(function(menu) {
14806 menu.toggleMenu(e.detail.target, e.detail.tag); 14825 menu.toggleMenu(e.detail.target, e.detail.tag);
14807 }); 14826 });
14808 }, 14827 },
14809 14828
14810 onOpenAllTap_: function() { 14829 onOpenAllTap_: function() {
14811 var menu = assert(this.$.menu.getIfExists()); 14830 var menu = assert(this.$.menu.getIfExists());
14812 md_history.BrowserService.getInstance().openForeignSessionAllTabs( 14831 md_history.BrowserService.getInstance().openForeignSessionAllTabs(
14813 menu.itemData); 14832 menu.itemData);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
14887 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); 14906 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length);
14888 for (var i = 0; i < updateCount; i++) { 14907 for (var i = 0; i < updateCount; i++) {
14889 var oldDevice = this.syncedDevices_[i]; 14908 var oldDevice = this.syncedDevices_[i];
14890 if (oldDevice.tag != sessionList[i].tag || 14909 if (oldDevice.tag != sessionList[i].tag ||
14891 oldDevice.timestamp != sessionList[i].timestamp) { 14910 oldDevice.timestamp != sessionList[i].timestamp) {
14892 this.splice( 14911 this.splice(
14893 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); 14912 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i]));
14894 } 14913 }
14895 } 14914 }
14896 14915
14897 // Then, append any new devices. 14916 if (sessionList.length >= this.syncedDevices_.length) {
14898 for (var i = updateCount; i < sessionList.length; i++) { 14917 // The list grew; append new items.
14899 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); 14918 for (var i = updateCount; i < sessionList.length; i++) {
14919 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i]));
14920 }
14921 } else {
14922 // The list shrank; remove deleted items.
14923 this.splice(
14924 'syncedDevices_', updateCount,
14925 this.syncedDevices_.length - updateCount);
14900 } 14926 }
14901 }, 14927 },
14902 14928
14903 /** 14929 /**
14904 * End fetching synced tabs when sync is disabled. 14930 * End fetching synced tabs when sync is disabled.
14905 */ 14931 */
14906 tabSyncDisabled: function() { 14932 tabSyncDisabled: function() {
14907 this.fetchingSyncedTabs_ = false; 14933 this.fetchingSyncedTabs_ = false;
14908 this.clearDisplayedSyncedDevices_(); 14934 this.clearDisplayedSyncedDevices_();
14909 }, 14935 },
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
15339 return selectedPage; 15365 return selectedPage;
15340 }, 15366 },
15341 15367
15342 /** @private */ 15368 /** @private */
15343 closeDrawer_: function() { 15369 closeDrawer_: function() {
15344 var drawer = this.$$('#drawer'); 15370 var drawer = this.$$('#drawer');
15345 if (drawer) 15371 if (drawer)
15346 drawer.close(); 15372 drawer.close();
15347 }, 15373 },
15348 }); 15374 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/md_history/app.vulcanized.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698