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-list-container', | 6 is: 'history-list-container', |
| 7 | 7 |
| 8 properties: { | 8 properties: { |
| 9 // The path of the currently selected page. | 9 // The path of the currently selected page. |
| 10 selectedPage_: String, | 10 selectedPage_: String, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 | 78 |
| 79 var maxResults = | 79 var maxResults = |
| 80 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; | 80 queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAGE : 0; |
| 81 chrome.send('queryHistory', [ | 81 chrome.send('queryHistory', [ |
| 82 queryState.searchTerm, queryState.groupedOffset, queryState.range, | 82 queryState.searchTerm, queryState.groupedOffset, queryState.range, |
| 83 lastVisitTime, maxResults | 83 lastVisitTime, maxResults |
| 84 ]); | 84 ]); |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 unselectAllItems: function(count) { | 87 unselectAllItems: function(count) { |
| 88 /** @type {HistoryListElement} */ (this.$['infinite-list']) | 88 this.getSelectedList_().unselectAllItems(count); |
| 89 .unselectAllItems(count); | |
| 90 }, | 89 }, |
| 91 | 90 |
| 92 /** | 91 /** |
| 93 * Delete all the currently selected history items. Will prompt the user with | 92 * Delete all the currently selected history items. Will prompt the user with |
| 94 * a dialog to confirm that the deletion should be performed. | 93 * a dialog to confirm that the deletion should be performed. |
| 95 */ | 94 */ |
| 96 deleteSelectedWithPrompt: function() { | 95 deleteSelectedWithPrompt: function() { |
| 97 if (!loadTimeData.getBoolean('allowDeletingHistory')) | 96 if (!loadTimeData.getBoolean('allowDeletingHistory')) |
| 98 return; | 97 return; |
| 99 | 98 |
| 100 this.$.dialog.showModal(); | 99 this.$.dialog.showModal(); |
| 101 }, | 100 }, |
| 102 | 101 |
| 103 /** | 102 /** |
| 104 * @param {HistoryRange} range | 103 * @param {HistoryRange} range |
| 105 * @private | 104 * @private |
| 106 */ | 105 */ |
| 107 groupedRangeChanged_: function(range) { | 106 groupedRangeChanged_: function(range) { |
| 108 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? | 107 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? |
| 109 'infinite-list' : 'grouped-list'; | 108 'infinite-list' : 'grouped-list'; |
| 110 | 109 |
| 111 this.queryHistory(false); | 110 this.queryHistory(false); |
| 112 }, | 111 }, |
| 113 | 112 |
| 114 /** @private */ | 113 /** @private */ |
| 115 loadMoreHistory_: function() { this.queryHistory(true); }, | 114 loadMoreHistory_: function() { this.queryHistory(true); }, |
| 116 | 115 |
| 117 | |
| 118 /** | 116 /** |
| 119 * @param {HistoryQuery} info | 117 * @param {HistoryQuery} info |
| 120 * @param {!Array<HistoryEntry>} results | 118 * @param {!Array<HistoryEntry>} results |
| 121 * @private | 119 * @private |
| 122 */ | 120 */ |
| 123 initializeResults_: function(info, results) { | 121 initializeResults_: function(info, results) { |
| 124 if (results.length == 0) | 122 if (results.length == 0) |
| 125 return; | 123 return; |
| 126 | 124 |
| 127 var currentDate = results[0].dateRelativeDay; | 125 var currentDate = results[0].dateRelativeDay; |
| 128 | 126 |
| 129 for (var i = 0; i < results.length; i++) { | 127 for (var i = 0; i < results.length; i++) { |
| 130 // Sets the default values for these fields to prevent undefined types. | 128 // Sets the default values for these fields to prevent undefined types. |
| 131 results[i].selected = false; | 129 results[i].selected = false; |
| 132 results[i].readableTimestamp = | 130 results[i].readableTimestamp = |
| 133 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort; | 131 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort; |
| 134 | 132 |
| 135 if (results[i].dateRelativeDay != currentDate) { | 133 if (results[i].dateRelativeDay != currentDate) { |
| 136 currentDate = results[i].dateRelativeDay; | 134 currentDate = results[i].dateRelativeDay; |
| 137 } | 135 } |
| 138 } | 136 } |
| 139 }, | 137 }, |
| 140 | 138 |
| 141 /** @private */ | 139 /** @private */ |
| 142 onDialogConfirmTap_: function() { | 140 onDialogConfirmTap_: function() { |
| 143 this.$['infinite-list'].deleteSelected(); | 141 this.$.content.selectedItem.deleteSelected(); |
|
tsergeant
2016/08/09 23:20:00
Nit: Change this one as well.
calamity
2016/08/10 04:25:38
Done.
| |
| 144 this.$.dialog.close(); | 142 this.$.dialog.close(); |
| 145 }, | 143 }, |
| 146 | 144 |
| 147 /** @private */ | 145 /** @private */ |
| 148 onDialogCancelTap_: function() { | 146 onDialogCancelTap_: function() { |
| 149 this.$.dialog.close(); | 147 this.$.dialog.close(); |
| 150 }, | 148 }, |
| 151 | 149 |
| 152 /** | 150 /** |
| 153 * Closes the overflow menu. | 151 * Closes the overflow menu. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 169 target, e.detail.item); | 167 target, e.detail.item); |
| 170 }, | 168 }, |
| 171 | 169 |
| 172 /** @private */ | 170 /** @private */ |
| 173 onMoreFromSiteTap_: function() { | 171 onMoreFromSiteTap_: function() { |
| 174 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); | 172 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); |
| 175 this.fire('search-domain', {domain: menu.itemData.domain}); | 173 this.fire('search-domain', {domain: menu.itemData.domain}); |
| 176 menu.closeMenu(); | 174 menu.closeMenu(); |
| 177 }, | 175 }, |
| 178 | 176 |
| 177 /** | |
| 178 * @return {HTMLElement} | |
| 179 * @private | |
| 180 */ | |
| 181 getSelectedList_: function() { | |
|
tsergeant
2016/08/09 23:20:00
Ultra nit: Move this up or down so that it's not b
calamity
2016/08/10 04:25:38
Done.
| |
| 182 return this.$.content.selectedItem; | |
| 183 }, | |
| 184 | |
| 179 /** @private */ | 185 /** @private */ |
| 180 onRemoveFromHistoryTap_: function() { | 186 onRemoveFromHistoryTap_: function() { |
| 181 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); | 187 var menu = /** @type {CrSharedMenuElement} */(this.$.sharedMenu); |
| 182 md_history.BrowserService.getInstance() | 188 md_history.BrowserService.getInstance() |
| 183 .deleteItems([menu.itemData]) | 189 .deleteItems([menu.itemData]) |
| 184 .then(function(items) { | 190 .then(function(items) { |
| 185 this.$['infinite-list'].removeDeletedHistory_(items); | 191 this.$.content.selectedItem.removeItemsByPath(items[0].path); |
|
tsergeant
2016/08/09 23:20:00
Nit: And this one
calamity
2016/08/10 04:25:38
Done.
| |
| 186 // This unselect-all is to reset the toolbar when deleting a selected | 192 // This unselect-all is to reset the toolbar when deleting a selected |
| 187 // item. TODO(tsergeant): Make this automatic based on observing list | 193 // item. TODO(tsergeant): Make this automatic based on observing list |
| 188 // modifications. | 194 // modifications. |
| 189 this.fire('unselect-all'); | 195 this.fire('unselect-all'); |
| 190 }.bind(this)); | 196 }.bind(this)); |
| 191 menu.closeMenu(); | 197 menu.closeMenu(); |
| 192 }, | 198 }, |
| 193 }); | 199 }); |
| OLD | NEW |