| 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 function PromiseResolver() { | 4 function PromiseResolver() { |
| 5 this.resolve_; | 5 this.resolve_; |
| 6 this.reject_; | 6 this.reject_; |
| 7 this.promise_ = new Promise(function(resolve, reject) { | 7 this.promise_ = new Promise(function(resolve, reject) { |
| 8 this.resolve_ = resolve; | 8 this.resolve_ = resolve; |
| 9 this.reject_ = reject; | 9 this.reject_ = reject; |
| 10 }.bind(this)); | 10 }.bind(this)); |
| (...skipping 6588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6599 }, | 6599 }, |
| 6600 openForeignSessionTab: function(sessionTag, windowId, tabId, e) { | 6600 openForeignSessionTab: function(sessionTag, windowId, tabId, e) { |
| 6601 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t
abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]); | 6601 chrome.send('openForeignSession', [ sessionTag, String(windowId), String(t
abId), e.button || 0, e.altKey, e.ctrlKey, e.metaKey, e.shiftKey ]); |
| 6602 }, | 6602 }, |
| 6603 deleteForeignSession: function(sessionTag) { | 6603 deleteForeignSession: function(sessionTag) { |
| 6604 chrome.send('deleteForeignSession', [ sessionTag ]); | 6604 chrome.send('deleteForeignSession', [ sessionTag ]); |
| 6605 }, | 6605 }, |
| 6606 openClearBrowsingData: function() { | 6606 openClearBrowsingData: function() { |
| 6607 chrome.send('clearBrowsingData'); | 6607 chrome.send('clearBrowsingData'); |
| 6608 }, | 6608 }, |
| 6609 recordHistogram: function(histogram, value, max) { |
| 6610 chrome.send('metricsHandler:recordInHistogram', [ histogram, value, max ])
; |
| 6611 }, |
| 6609 recordAction: function(actionDesc) { | 6612 recordAction: function(actionDesc) { |
| 6610 chrome.send('metricsHandler:recordAction', [ actionDesc ]); | 6613 chrome.send('metricsHandler:recordAction', [ actionDesc ]); |
| 6611 }, | 6614 }, |
| 6612 resolveDelete_: function(successful) { | 6615 resolveDelete_: function(successful) { |
| 6613 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null
) { | 6616 if (this.pendingDeleteItems_ == null || this.pendingDeletePromise_ == null
) { |
| 6614 return; | 6617 return; |
| 6615 } | 6618 } |
| 6616 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems
_); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_); | 6619 if (successful) this.pendingDeletePromise_.resolve(this.pendingDeleteItems
_); else this.pendingDeletePromise_.reject(this.pendingDeleteItems_); |
| 6617 this.pendingDeleteItems_ = null; | 6620 this.pendingDeleteItems_ = null; |
| 6618 this.pendingDeletePromise_ = null; | 6621 this.pendingDeletePromise_ = null; |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8143 }); | 8146 }); |
| 8144 | 8147 |
| 8145 // Copyright 2016 The Chromium Authors. All rights reserved. | 8148 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 8146 // Use of this source code is governed by a BSD-style license that can be | 8149 // Use of this source code is governed by a BSD-style license that can be |
| 8147 // found in the LICENSE file. | 8150 // found in the LICENSE file. |
| 8148 Polymer({ | 8151 Polymer({ |
| 8149 is: 'history-list-container', | 8152 is: 'history-list-container', |
| 8150 properties: { | 8153 properties: { |
| 8151 selectedPage_: String, | 8154 selectedPage_: String, |
| 8152 grouped: Boolean, | 8155 grouped: Boolean, |
| 8156 groupedRange: { |
| 8157 type: Number, |
| 8158 observer: 'groupedRangeChanged_' |
| 8159 }, |
| 8153 queryState: Object, | 8160 queryState: Object, |
| 8154 queryResult: Object | 8161 queryResult: Object |
| 8155 }, | 8162 }, |
| 8156 observers: [ 'groupedRangeChanged_(queryState.range)' ], | |
| 8157 listeners: { | 8163 listeners: { |
| 8158 'history-list-scrolled': 'closeMenu_', | 8164 'history-list-scrolled': 'closeMenu_', |
| 8159 'load-more-history': 'loadMoreHistory_', | 8165 'load-more-history': 'loadMoreHistory_', |
| 8160 'toggle-menu': 'toggleMenu_' | 8166 'toggle-menu': 'toggleMenu_' |
| 8161 }, | 8167 }, |
| 8162 historyResult: function(info, results) { | 8168 historyResult: function(info, results) { |
| 8163 this.initializeResults_(info, results); | 8169 this.initializeResults_(info, results); |
| 8164 this.closeMenu_(); | 8170 this.closeMenu_(); |
| 8165 if (this.selectedPage_ == 'grouped-list') { | 8171 if (this.selectedPage_ == 'grouped-list') { |
| 8166 this.$$('#grouped-list').historyData = results; | 8172 this.$$('#grouped-list').historyData = results; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 8178 } | 8184 } |
| 8179 var dialog = this.$.dialog.getIfExists(); | 8185 var dialog = this.$.dialog.getIfExists(); |
| 8180 if (!incremental && dialog && dialog.open) dialog.close(); | 8186 if (!incremental && dialog && dialog.open) dialog.close(); |
| 8181 this.set('queryState.querying', true); | 8187 this.set('queryState.querying', true); |
| 8182 this.set('queryState.incremental', incremental); | 8188 this.set('queryState.incremental', incremental); |
| 8183 var lastVisitTime = 0; | 8189 var lastVisitTime = 0; |
| 8184 if (incremental) { | 8190 if (incremental) { |
| 8185 var lastVisit = this.queryResult.results.slice(-1)[0]; | 8191 var lastVisit = this.queryResult.results.slice(-1)[0]; |
| 8186 lastVisitTime = lastVisit ? lastVisit.time : 0; | 8192 lastVisitTime = lastVisit ? lastVisit.time : 0; |
| 8187 } | 8193 } |
| 8188 var maxResults = queryState.range == HistoryRange.ALL_TIME ? RESULTS_PER_PAG
E : 0; | 8194 var maxResults = this.groupedRange == HistoryRange.ALL_TIME ? RESULTS_PER_PA
GE : 0; |
| 8189 chrome.send('queryHistory', [ queryState.searchTerm, queryState.groupedOffse
t, queryState.range, lastVisitTime, maxResults ]); | 8195 chrome.send('queryHistory', [ queryState.searchTerm, queryState.groupedOffse
t, queryState.range, lastVisitTime, maxResults ]); |
| 8190 }, | 8196 }, |
| 8191 historyDeleted: function() { | 8197 historyDeleted: function() { |
| 8192 if (this.getSelectedItemCount() > 0) return; | 8198 if (this.getSelectedItemCount() > 0) return; |
| 8193 this.queryHistory(false); | 8199 this.queryHistory(false); |
| 8194 }, | 8200 }, |
| 8195 getSelectedItemCount: function() { | 8201 getSelectedItemCount: function() { |
| 8196 return this.getSelectedList_().selectedPaths.size; | 8202 return this.getSelectedList_().selectedPaths.size; |
| 8197 }, | 8203 }, |
| 8198 unselectAllItems: function(count) { | 8204 unselectAllItems: function(count) { |
| 8199 var selectedList = this.getSelectedList_(); | 8205 var selectedList = this.getSelectedList_(); |
| 8200 if (selectedList) selectedList.unselectAllItems(count); | 8206 if (selectedList) selectedList.unselectAllItems(count); |
| 8201 }, | 8207 }, |
| 8202 deleteSelectedWithPrompt: function() { | 8208 deleteSelectedWithPrompt: function() { |
| 8203 if (!loadTimeData.getBoolean('allowDeletingHistory')) return; | 8209 if (!loadTimeData.getBoolean('allowDeletingHistory')) return; |
| 8204 this.$.dialog.get().then(function(dialog) { | 8210 this.$.dialog.get().then(function(dialog) { |
| 8205 dialog.showModal(); | 8211 dialog.showModal(); |
| 8206 }); | 8212 }); |
| 8207 }, | 8213 }, |
| 8208 groupedRangeChanged_: function(range) { | 8214 groupedRangeChanged_: function(range, oldRange) { |
| 8209 this.selectedPage_ = this.queryState.range == HistoryRange.ALL_TIME ? 'infin
ite-list' : 'grouped-list'; | 8215 this.selectedPage_ = range == HistoryRange.ALL_TIME ? 'infinite-list' : 'gro
uped-list'; |
| 8216 if (oldRange == undefined) return; |
| 8210 this.queryHistory(false); | 8217 this.queryHistory(false); |
| 8218 this.fire('history-view-changed'); |
| 8211 }, | 8219 }, |
| 8212 loadMoreHistory_: function() { | 8220 loadMoreHistory_: function() { |
| 8213 this.queryHistory(true); | 8221 this.queryHistory(true); |
| 8214 }, | 8222 }, |
| 8215 initializeResults_: function(info, results) { | 8223 initializeResults_: function(info, results) { |
| 8216 if (results.length == 0) return; | 8224 if (results.length == 0) return; |
| 8217 var currentDate = results[0].dateRelativeDay; | 8225 var currentDate = results[0].dateRelativeDay; |
| 8218 for (var i = 0; i < results.length; i++) { | 8226 for (var i = 0; i < results.length; i++) { |
| 8219 results[i].selected = false; | 8227 results[i].selected = false; |
| 8220 results[i].readableTimestamp = info.term == '' ? results[i].dateTimeOfDay
: results[i].dateShort; | 8228 results[i].readableTimestamp = info.term == '' ? results[i].dateTimeOfDay
: results[i].dateShort; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8333 searchTerm: { | 8341 searchTerm: { |
| 8334 type: String, | 8342 type: String, |
| 8335 observer: 'searchTermChanged' | 8343 observer: 'searchTermChanged' |
| 8336 }, | 8344 }, |
| 8337 syncedDevices_: { | 8345 syncedDevices_: { |
| 8338 type: Array, | 8346 type: Array, |
| 8339 value: function() { | 8347 value: function() { |
| 8340 return []; | 8348 return []; |
| 8341 } | 8349 } |
| 8342 }, | 8350 }, |
| 8343 signInState_: { | 8351 signInState: { |
| 8344 type: Boolean, | 8352 type: Boolean, |
| 8345 value: loadTimeData.getBoolean('isUserSignedIn') | 8353 observer: 'signInStateChanged_' |
| 8346 }, | 8354 }, |
| 8347 guestSession_: { | 8355 guestSession_: { |
| 8348 type: Boolean, | 8356 type: Boolean, |
| 8349 value: loadTimeData.getBoolean('isGuestSession') | 8357 value: loadTimeData.getBoolean('isGuestSession') |
| 8350 }, | 8358 }, |
| 8351 fetchingSyncedTabs_: { | 8359 fetchingSyncedTabs_: { |
| 8352 type: Boolean, | 8360 type: Boolean, |
| 8353 value: false | 8361 value: false |
| 8354 } | 8362 } |
| 8355 }, | 8363 }, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8450 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); | 8458 this.push('syncedDevices_', this.createInternalDevice_(sessionList[i])); |
| 8451 } | 8459 } |
| 8452 } else { | 8460 } else { |
| 8453 this.splice('syncedDevices_', updateCount, this.syncedDevices_.length - up
dateCount); | 8461 this.splice('syncedDevices_', updateCount, this.syncedDevices_.length - up
dateCount); |
| 8454 } | 8462 } |
| 8455 }, | 8463 }, |
| 8456 tabSyncDisabled: function() { | 8464 tabSyncDisabled: function() { |
| 8457 this.fetchingSyncedTabs_ = false; | 8465 this.fetchingSyncedTabs_ = false; |
| 8458 this.clearDisplayedSyncedDevices_(); | 8466 this.clearDisplayedSyncedDevices_(); |
| 8459 }, | 8467 }, |
| 8460 updateSignInState: function(isUserSignedIn) { | 8468 signInStateChanged_: function() { |
| 8461 if (this.signInState_ == isUserSignedIn) return; | 8469 this.fire('history-view-changed'); |
| 8462 this.signInState_ = isUserSignedIn; | 8470 if (!this.signInState) { |
| 8463 if (!isUserSignedIn) { | |
| 8464 this.clearDisplayedSyncedDevices_(); | 8471 this.clearDisplayedSyncedDevices_(); |
| 8465 return; | 8472 return; |
| 8466 } | 8473 } |
| 8467 this.fetchingSyncedTabs_ = true; | 8474 this.fetchingSyncedTabs_ = true; |
| 8468 }, | 8475 }, |
| 8469 searchTermChanged: function(searchTerm) { | 8476 searchTermChanged: function(searchTerm) { |
| 8470 this.clearDisplayedSyncedDevices_(); | 8477 this.clearDisplayedSyncedDevices_(); |
| 8471 this.updateSyncedDevices(this.sessionList); | 8478 this.updateSyncedDevices(this.sessionList); |
| 8472 } | 8479 } |
| 8473 }); | 8480 }); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8491 showFooter: Boolean, | 8498 showFooter: Boolean, |
| 8492 drawer: { | 8499 drawer: { |
| 8493 type: Boolean, | 8500 type: Boolean, |
| 8494 reflectToAttribute: true | 8501 reflectToAttribute: true |
| 8495 } | 8502 } |
| 8496 }, | 8503 }, |
| 8497 onSelectorActivate_: function() { | 8504 onSelectorActivate_: function() { |
| 8498 this.fire('history-close-drawer'); | 8505 this.fire('history-close-drawer'); |
| 8499 }, | 8506 }, |
| 8500 onClearBrowsingDataTap_: function(e) { | 8507 onClearBrowsingDataTap_: function(e) { |
| 8508 md_history.BrowserService.getInstance().recordAction('HistoryPage_InitClearB
rowsingData'); |
| 8501 md_history.BrowserService.getInstance().openClearBrowsingData(); | 8509 md_history.BrowserService.getInstance().openClearBrowsingData(); |
| 8502 e.preventDefault(); | 8510 e.preventDefault(); |
| 8503 }, | 8511 }, |
| 8504 getQueryString_: function(route) { | 8512 getQueryString_: function(route) { |
| 8505 return window.location.search; | 8513 return window.location.search; |
| 8506 } | 8514 } |
| 8507 }); | 8515 }); |
| 8508 | 8516 |
| 8509 // Copyright 2016 The Chromium Authors. All rights reserved. | 8517 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 8510 // Use of this source code is governed by a BSD-style license that can be | 8518 // Use of this source code is governed by a BSD-style license that can be |
| 8511 // found in the LICENSE file. | 8519 // found in the LICENSE file. |
| 8512 Polymer({ | 8520 Polymer({ |
| 8513 is: 'history-app', | 8521 is: 'history-app', |
| 8514 properties: { | 8522 properties: { |
| 8515 showSidebarFooter: Boolean, | 8523 showSidebarFooter: Boolean, |
| 8516 selectedPage_: { | 8524 selectedPage_: { |
| 8517 type: String, | 8525 type: String, |
| 8518 value: 'history', | |
| 8519 observer: 'unselectAll' | 8526 observer: 'unselectAll' |
| 8520 }, | 8527 }, |
| 8521 grouped_: { | 8528 grouped_: { |
| 8522 type: Boolean, | 8529 type: Boolean, |
| 8523 reflectToAttribute: true | 8530 reflectToAttribute: true |
| 8524 }, | 8531 }, |
| 8525 queryState_: { | 8532 queryState_: { |
| 8526 type: Object, | 8533 type: Object, |
| 8527 value: function() { | 8534 value: function() { |
| 8528 return { | 8535 return { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8546 value: function() { | 8553 value: function() { |
| 8547 return { | 8554 return { |
| 8548 info: null, | 8555 info: null, |
| 8549 results: null, | 8556 results: null, |
| 8550 sessionList: null | 8557 sessionList: null |
| 8551 }; | 8558 }; |
| 8552 } | 8559 } |
| 8553 }, | 8560 }, |
| 8554 routeData_: Object, | 8561 routeData_: Object, |
| 8555 queryParams_: Object, | 8562 queryParams_: Object, |
| 8556 hasDrawer_: Boolean | 8563 hasDrawer_: Boolean, |
| 8564 isUserSignedIn_: { |
| 8565 type: Boolean, |
| 8566 value: loadTimeData.getBoolean('isUserSignedIn') |
| 8567 } |
| 8557 }, | 8568 }, |
| 8558 observers: [ 'routeDataChanged_(routeData_.page)', 'selectedPageChanged_(selec
tedPage_)', 'searchTermChanged_(queryState_.searchTerm)', 'searchQueryParamChang
ed_(queryParams_.q)' ], | 8569 observers: [ 'routeDataChanged_(routeData_.page)', 'selectedPageChanged_(selec
tedPage_)', 'searchTermChanged_(queryState_.searchTerm)', 'searchQueryParamChang
ed_(queryParams_.q)' ], |
| 8559 listeners: { | 8570 listeners: { |
| 8560 'cr-menu-tap': 'onMenuTap_', | 8571 'cr-menu-tap': 'onMenuTap_', |
| 8561 'history-checkbox-select': 'checkboxSelected', | 8572 'history-checkbox-select': 'checkboxSelected', |
| 8562 'unselect-all': 'unselectAll', | 8573 'unselect-all': 'unselectAll', |
| 8563 'delete-selected': 'deleteSelected', | 8574 'delete-selected': 'deleteSelected', |
| 8564 'search-domain': 'searchDomain_', | 8575 'search-domain': 'searchDomain_', |
| 8565 'history-close-drawer': 'closeDrawer_' | 8576 'history-close-drawer': 'closeDrawer_', |
| 8577 'history-view-changed': 'recordHistoryPageView_' |
| 8566 }, | 8578 }, |
| 8567 ready: function() { | 8579 ready: function() { |
| 8568 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); | 8580 this.grouped_ = loadTimeData.getBoolean('groupByDomain'); |
| 8569 cr.ui.decorate('command', cr.ui.Command); | 8581 cr.ui.decorate('command', cr.ui.Command); |
| 8570 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); | 8582 document.addEventListener('canExecute', this.onCanExecute_.bind(this)); |
| 8571 document.addEventListener('command', this.onCommand_.bind(this)); | 8583 document.addEventListener('command', this.onCommand_.bind(this)); |
| 8572 if (window.location.hash) { | 8584 if (window.location.hash) { |
| 8573 window.location.href = window.location.href.split('#')[0] + '?' + window.l
ocation.hash.substr(1); | 8585 window.location.href = window.location.href.split('#')[0] + '?' + window.l
ocation.hash.substr(1); |
| 8574 } | 8586 } |
| 8575 }, | 8587 }, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8643 var syncedDeviceManagerElem = this.$$('history-synced-device-manager'); | 8655 var syncedDeviceManagerElem = this.$$('history-synced-device-manager'); |
| 8644 if (syncedDeviceManagerElem) syncedDeviceManagerElem.tabSyncDisabled(); | 8656 if (syncedDeviceManagerElem) syncedDeviceManagerElem.tabSyncDisabled(); |
| 8645 return; | 8657 return; |
| 8646 } | 8658 } |
| 8647 this.set('queryResult_.sessionList', sessionList); | 8659 this.set('queryResult_.sessionList', sessionList); |
| 8648 }, | 8660 }, |
| 8649 historyDeleted: function() { | 8661 historyDeleted: function() { |
| 8650 this.$.history.historyDeleted(); | 8662 this.$.history.historyDeleted(); |
| 8651 }, | 8663 }, |
| 8652 updateSignInState: function(isUserSignedIn) { | 8664 updateSignInState: function(isUserSignedIn) { |
| 8653 var syncedDeviceManagerElem = this.$$('history-synced-device-manager'); | 8665 this.isUserSignedIn_ = isUserSignedIn; |
| 8654 if (syncedDeviceManagerElem) syncedDeviceManagerElem.updateSignInState(isUse
rSignedIn); | |
| 8655 }, | 8666 }, |
| 8656 syncedTabsSelected_: function(selectedPage) { | 8667 syncedTabsSelected_: function(selectedPage) { |
| 8657 return selectedPage == 'syncedTabs'; | 8668 return selectedPage == 'syncedTabs'; |
| 8658 }, | 8669 }, |
| 8659 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 8670 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
| 8660 return querying && !incremental && searchTerm != ''; | 8671 return querying && !incremental && searchTerm != ''; |
| 8661 }, | 8672 }, |
| 8662 routeDataChanged_: function(page) { | 8673 routeDataChanged_: function(page) { |
| 8663 this.selectedPage_ = page; | 8674 this.selectedPage_ = page; |
| 8664 }, | 8675 }, |
| 8665 selectedPageChanged_: function(selectedPage) { | 8676 selectedPageChanged_: function(selectedPage) { |
| 8666 this.set('routeData_.page', selectedPage); | 8677 this.set('routeData_.page', selectedPage); |
| 8678 this.recordHistoryPageView_(); |
| 8667 }, | 8679 }, |
| 8668 getSelectedPage_: function(selectedPage, items) { | 8680 getSelectedPage_: function(selectedPage, items) { |
| 8669 return selectedPage; | 8681 return selectedPage; |
| 8670 }, | 8682 }, |
| 8671 closeDrawer_: function() { | 8683 closeDrawer_: function() { |
| 8672 var drawer = this.$$('#drawer'); | 8684 var drawer = this.$$('#drawer'); |
| 8673 if (drawer) drawer.close(); | 8685 if (drawer) drawer.close(); |
| 8686 }, |
| 8687 recordHistoryPageView_: function() { |
| 8688 var histogramValue = HistoryPageViewHistogram.END; |
| 8689 switch (this.selectedPage_) { |
| 8690 case 'syncedTabs': |
| 8691 histogramValue = this.isUserSignedIn_ ? HistoryPageViewHistogram.SYNCED_TA
BS : HistoryPageViewHistogram.SIGNIN_PROMO; |
| 8692 break; |
| 8693 |
| 8694 default: |
| 8695 switch (this.queryState_.range) { |
| 8696 case HistoryRange.ALL_TIME: |
| 8697 histogramValue = HistoryPageViewHistogram.HISTORY; |
| 8698 break; |
| 8699 |
| 8700 case HistoryRange.WEEK: |
| 8701 histogramValue = HistoryPageViewHistogram.GROUPED_WEEK; |
| 8702 break; |
| 8703 |
| 8704 case HistoryRange.MONTH: |
| 8705 histogramValue = HistoryPageViewHistogram.GROUPED_MONTH; |
| 8706 break; |
| 8707 } |
| 8708 break; |
| 8709 } |
| 8710 md_history.BrowserService.getInstance().recordHistogram('History.HistoryPage
View', histogramValue, HistoryPageViewHistogram.END); |
| 8674 } | 8711 } |
| 8675 }); | 8712 }); |
| OLD | NEW |