| 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 Polymer({ | 5 Polymer({ |
| 6 is: 'history-synced-device-card', | 6 is: 'history-synced-device-card', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 // Name of the synced device. | |
| 10 device: String, | |
| 11 | |
| 12 // When the device information was last updated. | |
| 13 lastUpdateTime: String, | |
| 14 | |
| 15 /** | 9 /** |
| 16 * The list of tabs open for this device. | 10 * The list of tabs open for this device. |
| 17 * @type {!Array<!ForeignSessionTab>} | 11 * @type {!Array<!ForeignSessionTab>} |
| 18 */ | 12 */ |
| 19 tabs: { | 13 tabs: { |
| 20 type: Array, | 14 type: Array, |
| 21 value: function() { return []; }, | 15 value: function() { return []; }, |
| 22 observer: 'updateIcons_' | 16 observer: 'updateIcons_' |
| 23 }, | 17 }, |
| 24 | 18 |
| 19 // Name of the synced device. |
| 20 device: String, |
| 21 |
| 22 // When the device information was last updated. |
| 23 lastUpdateTime: String, |
| 24 |
| 25 // Whether the card is open. |
| 26 opened: Boolean, |
| 27 |
| 28 searchTerm: String, |
| 29 |
| 25 /** | 30 /** |
| 26 * The indexes where a window separator should be shown. The use of a | 31 * The indexes where a window separator should be shown. The use of a |
| 27 * separate array here is necessary for window separators to appear | 32 * separate array here is necessary for window separators to appear |
| 28 * correctly in search. See http://crrev.com/2022003002 for more details. | 33 * correctly in search. See http://crrev.com/2022003002 for more details. |
| 29 * @type {!Array<number>} | 34 * @type {!Array<number>} |
| 30 */ | 35 */ |
| 31 separatorIndexes: Array, | 36 separatorIndexes: Array, |
| 32 | 37 |
| 33 // Whether the card is open. | |
| 34 opened: Boolean, | |
| 35 | |
| 36 searchTerm: String, | |
| 37 | |
| 38 // Internal identifier for the device. | 38 // Internal identifier for the device. |
| 39 sessionTag: String, | 39 sessionTag: String, |
| 40 }, | 40 }, |
| 41 | 41 |
| 42 listeners: {'dom-change': 'notifyFocusUpdate_'}, | 42 listeners: { |
| 43 'dom-change': 'notifyFocusUpdate_', |
| 44 }, |
| 43 | 45 |
| 44 /** | 46 /** |
| 45 * Create FocusRows for this card. One is always made for the card heading and | 47 * Create FocusRows for this card. One is always made for the card heading and |
| 46 * one for each result if the card is open. | 48 * one for each result if the card is open. |
| 47 * @return {!Array<!cr.ui.FocusRow>} | 49 * @return {!Array<!cr.ui.FocusRow>} |
| 48 */ | 50 */ |
| 49 createFocusRows: function() { | 51 createFocusRows: function() { |
| 50 var titleRow = new cr.ui.FocusRow(this.$['card-heading'], null); | 52 var titleRow = new cr.ui.FocusRow(this.$['card-heading'], null); |
| 51 titleRow.addItem('menu', '#menu-button'); | 53 titleRow.addItem('menu', '#menu-button'); |
| 52 titleRow.addItem('collapse', '#collapse-button'); | 54 titleRow.addItem('collapse', '#collapse-button'); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 63 return rows; | 65 return rows; |
| 64 }, | 66 }, |
| 65 | 67 |
| 66 /** | 68 /** |
| 67 * Open a single synced tab. Listens to 'click' rather than 'tap' | 69 * Open a single synced tab. Listens to 'click' rather than 'tap' |
| 68 * to determine what modifier keys were pressed. | 70 * to determine what modifier keys were pressed. |
| 69 * @param {DomRepeatClickEvent} e | 71 * @param {DomRepeatClickEvent} e |
| 70 * @private | 72 * @private |
| 71 */ | 73 */ |
| 72 openTab_: function(e) { | 74 openTab_: function(e) { |
| 73 var tab = /** @type {ForeignSessionTab} */(e.model.tab); | 75 var tab = /** @type {ForeignSessionTab} */ (e.model.tab); |
| 74 var browserService = md_history.BrowserService.getInstance(); | 76 var browserService = md_history.BrowserService.getInstance(); |
| 75 browserService.recordHistogram( | 77 browserService.recordHistogram( |
| 76 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_CLICKED, | 78 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_CLICKED, |
| 77 SyncedTabsHistogram.LIMIT); | 79 SyncedTabsHistogram.LIMIT); |
| 78 browserService.openForeignSessionTab( | 80 browserService.openForeignSessionTab( |
| 79 this.sessionTag, tab.windowId, tab.sessionId, e); | 81 this.sessionTag, tab.windowId, tab.sessionId, e); |
| 80 e.preventDefault(); | 82 e.preventDefault(); |
| 81 }, | 83 }, |
| 82 | 84 |
| 83 /** | 85 /** |
| 84 * Toggles the dropdown display of synced tabs for each device card. | 86 * Toggles the dropdown display of synced tabs for each device card. |
| 85 */ | 87 */ |
| 86 toggleTabCard: function() { | 88 toggleTabCard: function() { |
| 87 var histogramValue = this.$.collapse.opened ? | 89 var histogramValue = this.$.collapse.opened ? |
| 88 SyncedTabsHistogram.COLLAPSE_SESSION : | 90 SyncedTabsHistogram.COLLAPSE_SESSION : |
| 89 SyncedTabsHistogram.EXPAND_SESSION; | 91 SyncedTabsHistogram.EXPAND_SESSION; |
| 90 | 92 |
| 91 md_history.BrowserService.getInstance().recordHistogram( | 93 md_history.BrowserService.getInstance().recordHistogram( |
| 92 SYNCED_TABS_HISTOGRAM_NAME, histogramValue, | 94 SYNCED_TABS_HISTOGRAM_NAME, histogramValue, SyncedTabsHistogram.LIMIT); |
| 93 SyncedTabsHistogram.LIMIT); | |
| 94 | 95 |
| 95 this.$.collapse.toggle(); | 96 this.$.collapse.toggle(); |
| 96 this.$['dropdown-indicator'].icon = | 97 this.$['dropdown-indicator'].icon = |
| 97 this.$.collapse.opened ? 'cr:expand-less' : 'cr:expand-more'; | 98 this.$.collapse.opened ? 'cr:expand-less' : 'cr:expand-more'; |
| 98 | 99 |
| 99 this.fire('update-focus-grid'); | 100 this.fire('update-focus-grid'); |
| 100 }, | 101 }, |
| 101 | 102 |
| 102 /** @private */ | 103 /** @private */ |
| 103 notifyFocusUpdate_: function() { | 104 notifyFocusUpdate_: function() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 loadTimeData.getString('expandSessionButton'); | 145 loadTimeData.getString('expandSessionButton'); |
| 145 }, | 146 }, |
| 146 | 147 |
| 147 /** | 148 /** |
| 148 * @param {CustomEvent} e | 149 * @param {CustomEvent} e |
| 149 * @private | 150 * @private |
| 150 */ | 151 */ |
| 151 onMenuButtonTap_: function(e) { | 152 onMenuButtonTap_: function(e) { |
| 152 this.fire('toggle-menu', { | 153 this.fire('toggle-menu', { |
| 153 target: Polymer.dom(e).localTarget, | 154 target: Polymer.dom(e).localTarget, |
| 154 tag: this.sessionTag | 155 tag: this.sessionTag, |
| 155 }); | 156 }); |
| 156 e.stopPropagation(); // Prevent iron-collapse. | 157 e.stopPropagation(); // Prevent iron-collapse. |
| 157 }, | 158 }, |
| 158 | 159 |
| 159 onLinkRightClick_: function() { | 160 onLinkRightClick_: function() { |
| 160 md_history.BrowserService.getInstance().recordHistogram( | 161 md_history.BrowserService.getInstance().recordHistogram( |
| 161 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_RIGHT_CLICKED, | 162 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_RIGHT_CLICKED, |
| 162 SyncedTabsHistogram.LIMIT); | 163 SyncedTabsHistogram.LIMIT); |
| 163 }, | 164 }, |
| 164 }); | 165 }); |
| OLD | NEW |