Chromium Code Reviews| 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. | 9 // Name of the synced device. |
| 10 device: String, | 10 device: String, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 | 32 |
| 33 // Whether the card is open. | 33 // Whether the card is open. |
| 34 opened: Boolean, | 34 opened: Boolean, |
| 35 | 35 |
| 36 searchTerm: String, | 36 searchTerm: String, |
| 37 | 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_'}, | |
| 43 | |
| 44 /** | |
| 45 * Create FocusRows for this card. One is always made for the card heading and | |
| 46 * one for each result if the card is open. | |
| 47 * @return {Array<cr.ui.FocusRow>} | |
|
tsergeant
2016/10/04 06:09:02
Nit: !Array<!cr.ui.FocusRow>
calamity
2016/10/05 04:20:25
Done.
| |
| 48 */ | |
| 49 createFocusRows: function() { | |
| 50 var titleRow = new cr.ui.FocusRow(this.$['card-heading'], null); | |
| 51 titleRow.addItem('menu', '#menu-button'); | |
| 52 titleRow.addItem('collapse', '#collapse-button'); | |
| 53 var rows = [titleRow]; | |
| 54 if (this.opened) { | |
| 55 Polymer.dom(this.root) | |
| 56 .querySelectorAll('.item-container') | |
| 57 .forEach(function(el) { | |
| 58 var row = new cr.ui.FocusRow(el, null); | |
| 59 row.addItem('title', '.website-title'); | |
| 60 rows.push(row); | |
| 61 }); | |
| 62 } | |
| 63 return rows; | |
| 64 }, | |
| 65 | |
| 42 /** | 66 /** |
| 43 * Open a single synced tab. Listens to 'click' rather than 'tap' | 67 * Open a single synced tab. Listens to 'click' rather than 'tap' |
| 44 * to determine what modifier keys were pressed. | 68 * to determine what modifier keys were pressed. |
| 45 * @param {DomRepeatClickEvent} e | 69 * @param {DomRepeatClickEvent} e |
| 46 * @private | 70 * @private |
| 47 */ | 71 */ |
| 48 openTab_: function(e) { | 72 openTab_: function(e) { |
| 49 var tab = /** @type {ForeignSessionTab} */(e.model.tab); | 73 var tab = /** @type {ForeignSessionTab} */(e.model.tab); |
| 50 var browserService = md_history.BrowserService.getInstance(); | 74 var browserService = md_history.BrowserService.getInstance(); |
| 51 browserService.recordHistogram( | 75 browserService.recordHistogram( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 64 SyncedTabsHistogram.COLLAPSE_SESSION : | 88 SyncedTabsHistogram.COLLAPSE_SESSION : |
| 65 SyncedTabsHistogram.EXPAND_SESSION; | 89 SyncedTabsHistogram.EXPAND_SESSION; |
| 66 | 90 |
| 67 md_history.BrowserService.getInstance().recordHistogram( | 91 md_history.BrowserService.getInstance().recordHistogram( |
| 68 SYNCED_TABS_HISTOGRAM_NAME, histogramValue, | 92 SYNCED_TABS_HISTOGRAM_NAME, histogramValue, |
| 69 SyncedTabsHistogram.LIMIT); | 93 SyncedTabsHistogram.LIMIT); |
| 70 | 94 |
| 71 this.$.collapse.toggle(); | 95 this.$.collapse.toggle(); |
| 72 this.$['dropdown-indicator'].icon = | 96 this.$['dropdown-indicator'].icon = |
| 73 this.$.collapse.opened ? 'cr:expand-less' : 'cr:expand-more'; | 97 this.$.collapse.opened ? 'cr:expand-less' : 'cr:expand-more'; |
| 98 | |
| 99 this.fire('update-focus-grid'); | |
| 100 }, | |
| 101 | |
| 102 notifyFocusUpdate_: function() { | |
| 103 // Refresh focus after all rows are rendered. | |
| 104 this.fire('update-focus-grid'); | |
| 74 }, | 105 }, |
| 75 | 106 |
| 76 /** | 107 /** |
| 77 * When the synced tab information is set, the icon associated with the tab | 108 * When the synced tab information is set, the icon associated with the tab |
| 78 * website is also set. | 109 * website is also set. |
| 79 * @private | 110 * @private |
| 80 */ | 111 */ |
| 81 updateIcons_: function() { | 112 updateIcons_: function() { |
| 82 this.async(function() { | 113 this.async(function() { |
| 83 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon'); | 114 var icons = Polymer.dom(this.root).querySelectorAll('.website-icon'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 }); | 154 }); |
| 124 e.stopPropagation(); // Prevent iron-collapse. | 155 e.stopPropagation(); // Prevent iron-collapse. |
| 125 }, | 156 }, |
| 126 | 157 |
| 127 onLinkRightClick_: function() { | 158 onLinkRightClick_: function() { |
| 128 md_history.BrowserService.getInstance().recordHistogram( | 159 md_history.BrowserService.getInstance().recordHistogram( |
| 129 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_RIGHT_CLICKED, | 160 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_RIGHT_CLICKED, |
| 130 SyncedTabsHistogram.LIMIT); | 161 SyncedTabsHistogram.LIMIT); |
| 131 }, | 162 }, |
| 132 }); | 163 }); |
| OLD | NEW |