| OLD | NEW |
| 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 14571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14582 | 14582 |
| 14583 /** | 14583 /** |
| 14584 * The indexes where a window separator should be shown. The use of a | 14584 * The indexes where a window separator should be shown. The use of a |
| 14585 * separate array here is necessary for window separators to appear | 14585 * separate array here is necessary for window separators to appear |
| 14586 * correctly in search. See http://crrev.com/2022003002 for more details. | 14586 * correctly in search. See http://crrev.com/2022003002 for more details. |
| 14587 * @type {!Array<number>} | 14587 * @type {!Array<number>} |
| 14588 */ | 14588 */ |
| 14589 separatorIndexes: Array, | 14589 separatorIndexes: Array, |
| 14590 | 14590 |
| 14591 // Whether the card is open. | 14591 // Whether the card is open. |
| 14592 cardOpen_: {type: Boolean, value: true}, | 14592 opened: Boolean, |
| 14593 | 14593 |
| 14594 searchTerm: String, | 14594 searchTerm: String, |
| 14595 | 14595 |
| 14596 // Internal identifier for the device. | 14596 // Internal identifier for the device. |
| 14597 sessionTag: String, | 14597 sessionTag: String, |
| 14598 }, | 14598 }, |
| 14599 | 14599 |
| 14600 /** | 14600 /** |
| 14601 * Open a single synced tab. Listens to 'click' rather than 'tap' | 14601 * Open a single synced tab. Listens to 'click' rather than 'tap' |
| 14602 * to determine what modifier keys were pressed. | 14602 * to determine what modifier keys were pressed. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14634 } | 14634 } |
| 14635 }); | 14635 }); |
| 14636 }, | 14636 }, |
| 14637 | 14637 |
| 14638 /** @private */ | 14638 /** @private */ |
| 14639 isWindowSeparatorIndex_: function(index, separatorIndexes) { | 14639 isWindowSeparatorIndex_: function(index, separatorIndexes) { |
| 14640 return this.separatorIndexes.indexOf(index) != -1; | 14640 return this.separatorIndexes.indexOf(index) != -1; |
| 14641 }, | 14641 }, |
| 14642 | 14642 |
| 14643 /** | 14643 /** |
| 14644 * @param {boolean} cardOpen | 14644 * @param {boolean} opened |
| 14645 * @return {string} | 14645 * @return {string} |
| 14646 * @private |
| 14646 */ | 14647 */ |
| 14647 getCollapseTitle_: function(cardOpen) { | 14648 getCollapseIcon_: function(opened) { |
| 14648 return cardOpen ? loadTimeData.getString('collapseSessionButton') : | 14649 return opened ? 'cr:expand-less' : 'cr:expand-more'; |
| 14649 loadTimeData.getString('expandSessionButton'); | |
| 14650 }, | 14650 }, |
| 14651 | 14651 |
| 14652 /** | 14652 /** |
| 14653 * @param {boolean} opened |
| 14654 * @return {string} |
| 14655 * @private |
| 14656 */ |
| 14657 getCollapseTitle_: function(opened) { |
| 14658 return opened ? loadTimeData.getString('collapseSessionButton') : |
| 14659 loadTimeData.getString('expandSessionButton'); |
| 14660 }, |
| 14661 |
| 14662 /** |
| 14653 * @param {CustomEvent} e | 14663 * @param {CustomEvent} e |
| 14654 * @private | 14664 * @private |
| 14655 */ | 14665 */ |
| 14656 onMenuButtonTap_: function(e) { | 14666 onMenuButtonTap_: function(e) { |
| 14657 this.fire('toggle-menu', { | 14667 this.fire('toggle-menu', { |
| 14658 target: Polymer.dom(e).localTarget, | 14668 target: Polymer.dom(e).localTarget, |
| 14659 tag: this.sessionTag | 14669 tag: this.sessionTag |
| 14660 }); | 14670 }); |
| 14661 e.stopPropagation(); // Prevent iron-collapse. | 14671 e.stopPropagation(); // Prevent iron-collapse. |
| 14662 }, | 14672 }, |
| 14663 }); | 14673 }); |
| 14664 // Copyright 2016 The Chromium Authors. All rights reserved. | 14674 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 14665 // Use of this source code is governed by a BSD-style license that can be | 14675 // Use of this source code is governed by a BSD-style license that can be |
| 14666 // found in the LICENSE file. | 14676 // found in the LICENSE file. |
| 14667 | 14677 |
| 14668 /** | 14678 /** |
| 14669 * @typedef {{device: string, | 14679 * @typedef {{device: string, |
| 14670 * lastUpdateTime: string, | 14680 * lastUpdateTime: string, |
| 14681 * opened: boolean, |
| 14671 * separatorIndexes: !Array<number>, | 14682 * separatorIndexes: !Array<number>, |
| 14672 * timestamp: number, | 14683 * timestamp: number, |
| 14673 * tabs: !Array<!ForeignSessionTab>, | 14684 * tabs: !Array<!ForeignSessionTab>, |
| 14674 * tag: string}} | 14685 * tag: string}} |
| 14675 */ | 14686 */ |
| 14676 var ForeignDeviceInternal; | 14687 var ForeignDeviceInternal; |
| 14677 | 14688 |
| 14678 Polymer({ | 14689 Polymer({ |
| 14679 is: 'history-synced-device-manager', | 14690 is: 'history-synced-device-manager', |
| 14680 | 14691 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14715 | 14726 |
| 14716 /** @private */ | 14727 /** @private */ |
| 14717 fetchingSyncedTabs_: { | 14728 fetchingSyncedTabs_: { |
| 14718 type: Boolean, | 14729 type: Boolean, |
| 14719 value: false, | 14730 value: false, |
| 14720 } | 14731 } |
| 14721 }, | 14732 }, |
| 14722 | 14733 |
| 14723 listeners: { | 14734 listeners: { |
| 14724 'toggle-menu': 'onToggleMenu_', | 14735 'toggle-menu': 'onToggleMenu_', |
| 14736 'scroll': 'onListScroll_' |
| 14725 }, | 14737 }, |
| 14726 | 14738 |
| 14727 /** @override */ | 14739 /** @override */ |
| 14728 attached: function() { | 14740 attached: function() { |
| 14729 // Update the sign in state. | 14741 // Update the sign in state. |
| 14730 chrome.send('otherDevicesInitialized'); | 14742 chrome.send('otherDevicesInitialized'); |
| 14731 }, | 14743 }, |
| 14732 | 14744 |
| 14733 /** | 14745 /** |
| 14734 * @param {!ForeignSession} session | 14746 * @param {!ForeignSession} session |
| (...skipping 26 matching lines...) Expand all Loading... |
| 14761 windowAdded = true; | 14773 windowAdded = true; |
| 14762 } | 14774 } |
| 14763 } | 14775 } |
| 14764 } | 14776 } |
| 14765 if (windowAdded && i != session.windows.length - 1) | 14777 if (windowAdded && i != session.windows.length - 1) |
| 14766 separatorIndexes.push(tabs.length - 1); | 14778 separatorIndexes.push(tabs.length - 1); |
| 14767 } | 14779 } |
| 14768 return { | 14780 return { |
| 14769 device: session.name, | 14781 device: session.name, |
| 14770 lastUpdateTime: '– ' + session.modifiedTime, | 14782 lastUpdateTime: '– ' + session.modifiedTime, |
| 14783 opened: true, |
| 14771 separatorIndexes: separatorIndexes, | 14784 separatorIndexes: separatorIndexes, |
| 14772 timestamp: session.timestamp, | 14785 timestamp: session.timestamp, |
| 14773 tabs: tabs, | 14786 tabs: tabs, |
| 14774 tag: session.tag, | 14787 tag: session.tag, |
| 14775 }; | 14788 }; |
| 14776 }, | 14789 }, |
| 14777 | 14790 |
| 14778 onSignInTap_: function() { | 14791 onSignInTap_: function() { |
| 14779 chrome.send('startSignInFlow'); | 14792 chrome.send('startSignInFlow'); |
| 14780 }, | 14793 }, |
| 14781 | 14794 |
| 14795 onListScroll_: function() { |
| 14796 var menu = this.$.menu.getIfExists(); |
| 14797 if (menu) |
| 14798 menu.closeMenu(); |
| 14799 }, |
| 14800 |
| 14782 onToggleMenu_: function(e) { | 14801 onToggleMenu_: function(e) { |
| 14783 this.$.menu.get().then(function(menu) { | 14802 this.$.menu.get().then(function(menu) { |
| 14784 menu.toggleMenu(e.detail.target, e.detail.tag); | 14803 menu.toggleMenu(e.detail.target, e.detail.tag); |
| 14785 }); | 14804 }); |
| 14786 }, | 14805 }, |
| 14787 | 14806 |
| 14788 onOpenAllTap_: function() { | 14807 onOpenAllTap_: function() { |
| 14789 var menu = assert(this.$.menu.getIfExists()); | 14808 var menu = assert(this.$.menu.getIfExists()); |
| 14790 md_history.BrowserService.getInstance().openForeignSessionAllTabs( | 14809 md_history.BrowserService.getInstance().openForeignSessionAllTabs( |
| 14791 menu.itemData); | 14810 menu.itemData); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14865 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); | 14884 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); |
| 14866 for (var i = 0; i < updateCount; i++) { | 14885 for (var i = 0; i < updateCount; i++) { |
| 14867 var oldDevice = this.syncedDevices_[i]; | 14886 var oldDevice = this.syncedDevices_[i]; |
| 14868 if (oldDevice.tag != sessionList[i].tag || | 14887 if (oldDevice.tag != sessionList[i].tag || |
| 14869 oldDevice.timestamp != sessionList[i].timestamp) { | 14888 oldDevice.timestamp != sessionList[i].timestamp) { |
| 14870 this.splice( | 14889 this.splice( |
| 14871 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); | 14890 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); |
| 14872 } | 14891 } |
| 14873 } | 14892 } |
| 14874 | 14893 |
| 14875 // Then, append any new devices. | 14894 if (updateCount == this.syncedDevices_.length) { |
| 14876 for (var i = updateCount; i < sessionList.length; i++) { | 14895 // The list grew; append new items. |
| 14877 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); | 14896 for (var i = updateCount; i < sessionList.length; i++) { |
| 14897 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); |
| 14898 } |
| 14899 } else { |
| 14900 // The list shrank; remove deleted items. |
| 14901 this.splice( |
| 14902 'syncedDevices_', updateCount, |
| 14903 this.syncedDevices_.length - updateCount); |
| 14878 } | 14904 } |
| 14879 }, | 14905 }, |
| 14880 | 14906 |
| 14881 /** | 14907 /** |
| 14882 * End fetching synced tabs when sync is disabled. | 14908 * End fetching synced tabs when sync is disabled. |
| 14883 */ | 14909 */ |
| 14884 tabSyncDisabled: function() { | 14910 tabSyncDisabled: function() { |
| 14885 this.fetchingSyncedTabs_ = false; | 14911 this.fetchingSyncedTabs_ = false; |
| 14886 this.clearDisplayedSyncedDevices_(); | 14912 this.clearDisplayedSyncedDevices_(); |
| 14887 }, | 14913 }, |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15310 return selectedPage; | 15336 return selectedPage; |
| 15311 }, | 15337 }, |
| 15312 | 15338 |
| 15313 /** @private */ | 15339 /** @private */ |
| 15314 closeDrawer_: function() { | 15340 closeDrawer_: function() { |
| 15315 var drawer = this.$$('#drawer'); | 15341 var drawer = this.$$('#drawer'); |
| 15316 if (drawer) | 15342 if (drawer) |
| 15317 drawer.close(); | 15343 drawer.close(); |
| 15318 }, | 15344 }, |
| 15319 }); | 15345 }); |
| OLD | NEW |