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 10728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10739 Polymer.IronControlState, | 10739 Polymer.IronControlState, |
10740 Polymer.PaperItemBehaviorImpl | 10740 Polymer.PaperItemBehaviorImpl |
10741 ]; | 10741 ]; |
10742 Polymer({ | 10742 Polymer({ |
10743 is: 'paper-item', | 10743 is: 'paper-item', |
10744 | 10744 |
10745 behaviors: [ | 10745 behaviors: [ |
10746 Polymer.PaperItemBehavior | 10746 Polymer.PaperItemBehavior |
10747 ] | 10747 ] |
10748 }); | 10748 }); |
| 10749 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 10750 // Use of this source code is governed by a BSD-style license that can be |
| 10751 // found in the LICENSE file. |
| 10752 |
| 10753 /** |
| 10754 * @fileoverview Defines a singleton object, md_history.BrowserService, which |
| 10755 * provides access to chrome.send APIs. |
| 10756 */ |
| 10757 |
| 10758 cr.define('md_history', function() { |
| 10759 /** @constructor */ |
| 10760 function BrowserService() { |
| 10761 /** @private {Array<!HistoryEntry>} */ |
| 10762 this.pendingDeleteItems_ = null; |
| 10763 /** @private {PromiseResolver} */ |
| 10764 this.pendingDeletePromise_ = null; |
| 10765 } |
| 10766 |
| 10767 BrowserService.prototype = { |
| 10768 /** |
| 10769 * @param {!Array<!HistoryEntry>} items |
| 10770 * @return {Promise<!Array<!HistoryEntry>>} |
| 10771 */ |
| 10772 deleteItems: function(items) { |
| 10773 if (this.pendingDeleteItems_ != null) { |
| 10774 // There's already a deletion in progress, reject immediately. |
| 10775 return new Promise(function(resolve, reject) { reject(items); }); |
| 10776 } |
| 10777 |
| 10778 var removalList = items.map(function(item) { |
| 10779 return { |
| 10780 url: item.url, |
| 10781 timestamps: item.allTimestamps |
| 10782 }; |
| 10783 }); |
| 10784 |
| 10785 this.pendingDeleteItems_ = items; |
| 10786 this.pendingDeletePromise_ = new PromiseResolver(); |
| 10787 |
| 10788 chrome.send('removeVisits', removalList); |
| 10789 |
| 10790 return this.pendingDeletePromise_.promise; |
| 10791 }, |
| 10792 |
| 10793 /** |
| 10794 * @param {!string} url |
| 10795 */ |
| 10796 removeBookmark: function(url) { |
| 10797 chrome.send('removeBookmark', [url]); |
| 10798 }, |
| 10799 |
| 10800 /** |
| 10801 * @param {string} sessionTag |
| 10802 */ |
| 10803 openForeignSessionAllTabs: function(sessionTag) { |
| 10804 chrome.send('openForeignSession', [sessionTag]); |
| 10805 }, |
| 10806 |
| 10807 /** |
| 10808 * @param {string} sessionTag |
| 10809 * @param {number} windowId |
| 10810 * @param {number} tabId |
| 10811 * @param {MouseEvent} e |
| 10812 */ |
| 10813 openForeignSessionTab: function(sessionTag, windowId, tabId, e) { |
| 10814 chrome.send('openForeignSession', [ |
| 10815 sessionTag, String(windowId), String(tabId), e.button || 0, e.altKey, |
| 10816 e.ctrlKey, e.metaKey, e.shiftKey |
| 10817 ]); |
| 10818 }, |
| 10819 |
| 10820 /** |
| 10821 * @param {string} sessionTag |
| 10822 */ |
| 10823 deleteForeignSession: function(sessionTag) { |
| 10824 chrome.send('deleteForeignSession', [sessionTag]); |
| 10825 }, |
| 10826 |
| 10827 openClearBrowsingData: function() { |
| 10828 chrome.send('clearBrowsingData'); |
| 10829 }, |
| 10830 |
| 10831 /** |
| 10832 * @param {string} histogram |
| 10833 * @param {number} value |
| 10834 * @param {number} max |
| 10835 */ |
| 10836 recordHistogram: function(histogram, value, max) { |
| 10837 chrome.send('metricsHandler:recordInHistogram', [histogram, value, max]); |
| 10838 }, |
| 10839 |
| 10840 /** |
| 10841 * Record an action in UMA. |
| 10842 * @param {string} action The name of the action to be logged. |
| 10843 */ |
| 10844 recordAction: function(action) { |
| 10845 if (action.indexOf('_') == -1) |
| 10846 action = 'HistoryPage_' + action; |
| 10847 chrome.send('metricsHandler:recordAction', [action]); |
| 10848 }, |
| 10849 |
| 10850 /** |
| 10851 * @param {boolean} successful |
| 10852 * @private |
| 10853 */ |
| 10854 resolveDelete_: function(successful) { |
| 10855 if (this.pendingDeleteItems_ == null || |
| 10856 this.pendingDeletePromise_ == null) { |
| 10857 return; |
| 10858 } |
| 10859 |
| 10860 if (successful) |
| 10861 this.pendingDeletePromise_.resolve(this.pendingDeleteItems_); |
| 10862 else |
| 10863 this.pendingDeletePromise_.reject(this.pendingDeleteItems_); |
| 10864 |
| 10865 this.pendingDeleteItems_ = null; |
| 10866 this.pendingDeletePromise_ = null; |
| 10867 }, |
| 10868 }; |
| 10869 |
| 10870 cr.addSingletonGetter(BrowserService); |
| 10871 |
| 10872 return {BrowserService: BrowserService}; |
| 10873 }); |
| 10874 |
| 10875 /** |
| 10876 * Called by the history backend when deletion was succesful. |
| 10877 */ |
| 10878 function deleteComplete() { |
| 10879 md_history.BrowserService.getInstance().resolveDelete_(true); |
| 10880 } |
| 10881 |
| 10882 /** |
| 10883 * Called by the history backend when the deletion failed. |
| 10884 */ |
| 10885 function deleteFailed() { |
| 10886 md_history.BrowserService.getInstance().resolveDelete_(false); |
| 10887 }; |
10749 Polymer({ | 10888 Polymer({ |
10750 | 10889 |
10751 is: 'iron-collapse', | 10890 is: 'iron-collapse', |
10752 | 10891 |
10753 behaviors: [ | 10892 behaviors: [ |
10754 Polymer.IronResizableBehavior | 10893 Polymer.IronResizableBehavior |
10755 ], | 10894 ], |
10756 | 10895 |
10757 properties: { | 10896 properties: { |
10758 | 10897 |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11353 return { | 11492 return { |
11354 getSupportedScaleFactors: getSupportedScaleFactors, | 11493 getSupportedScaleFactors: getSupportedScaleFactors, |
11355 getProfileAvatarIcon: getProfileAvatarIcon, | 11494 getProfileAvatarIcon: getProfileAvatarIcon, |
11356 getFaviconImageSet: getFaviconImageSet, | 11495 getFaviconImageSet: getFaviconImageSet, |
11357 }; | 11496 }; |
11358 }); | 11497 }); |
11359 // Copyright 2016 The Chromium Authors. All rights reserved. | 11498 // Copyright 2016 The Chromium Authors. All rights reserved. |
11360 // Use of this source code is governed by a BSD-style license that can be | 11499 // Use of this source code is governed by a BSD-style license that can be |
11361 // found in the LICENSE file. | 11500 // found in the LICENSE file. |
11362 | 11501 |
11363 /** | |
11364 * @fileoverview Defines a singleton object, md_history.BrowserService, which | |
11365 * provides access to chrome.send APIs. | |
11366 */ | |
11367 | |
11368 cr.define('md_history', function() { | |
11369 /** @constructor */ | |
11370 function BrowserService() { | |
11371 /** @private {Array<!HistoryEntry>} */ | |
11372 this.pendingDeleteItems_ = null; | |
11373 /** @private {PromiseResolver} */ | |
11374 this.pendingDeletePromise_ = null; | |
11375 } | |
11376 | |
11377 BrowserService.prototype = { | |
11378 /** | |
11379 * @param {!Array<!HistoryEntry>} items | |
11380 * @return {Promise<!Array<!HistoryEntry>>} | |
11381 */ | |
11382 deleteItems: function(items) { | |
11383 if (this.pendingDeleteItems_ != null) { | |
11384 // There's already a deletion in progress, reject immediately. | |
11385 return new Promise(function(resolve, reject) { reject(items); }); | |
11386 } | |
11387 | |
11388 var removalList = items.map(function(item) { | |
11389 return { | |
11390 url: item.url, | |
11391 timestamps: item.allTimestamps | |
11392 }; | |
11393 }); | |
11394 | |
11395 this.pendingDeleteItems_ = items; | |
11396 this.pendingDeletePromise_ = new PromiseResolver(); | |
11397 | |
11398 chrome.send('removeVisits', removalList); | |
11399 | |
11400 return this.pendingDeletePromise_.promise; | |
11401 }, | |
11402 | |
11403 /** | |
11404 * @param {!string} url | |
11405 */ | |
11406 removeBookmark: function(url) { | |
11407 chrome.send('removeBookmark', [url]); | |
11408 }, | |
11409 | |
11410 /** | |
11411 * @param {string} sessionTag | |
11412 */ | |
11413 openForeignSessionAllTabs: function(sessionTag) { | |
11414 chrome.send('openForeignSession', [sessionTag]); | |
11415 }, | |
11416 | |
11417 /** | |
11418 * @param {string} sessionTag | |
11419 * @param {number} windowId | |
11420 * @param {number} tabId | |
11421 * @param {MouseEvent} e | |
11422 */ | |
11423 openForeignSessionTab: function(sessionTag, windowId, tabId, e) { | |
11424 chrome.send('openForeignSession', [ | |
11425 sessionTag, String(windowId), String(tabId), e.button || 0, e.altKey, | |
11426 e.ctrlKey, e.metaKey, e.shiftKey | |
11427 ]); | |
11428 }, | |
11429 | |
11430 /** | |
11431 * @param {string} sessionTag | |
11432 */ | |
11433 deleteForeignSession: function(sessionTag) { | |
11434 chrome.send('deleteForeignSession', [sessionTag]); | |
11435 }, | |
11436 | |
11437 openClearBrowsingData: function() { | |
11438 chrome.send('clearBrowsingData'); | |
11439 }, | |
11440 | |
11441 /** | |
11442 * @param {string} histogram | |
11443 * @param {number} value | |
11444 * @param {number} max | |
11445 */ | |
11446 recordHistogram: function(histogram, value, max) { | |
11447 chrome.send('metricsHandler:recordInHistogram', [histogram, value, max]); | |
11448 }, | |
11449 | |
11450 /** | |
11451 * Record an action in UMA. | |
11452 * @param {string} actionDesc The name of the action to be logged. | |
11453 */ | |
11454 recordAction: function(actionDesc) { | |
11455 chrome.send('metricsHandler:recordAction', [actionDesc]); | |
11456 }, | |
11457 | |
11458 /** | |
11459 * @param {boolean} successful | |
11460 * @private | |
11461 */ | |
11462 resolveDelete_: function(successful) { | |
11463 if (this.pendingDeleteItems_ == null || | |
11464 this.pendingDeletePromise_ == null) { | |
11465 return; | |
11466 } | |
11467 | |
11468 if (successful) | |
11469 this.pendingDeletePromise_.resolve(this.pendingDeleteItems_); | |
11470 else | |
11471 this.pendingDeletePromise_.reject(this.pendingDeleteItems_); | |
11472 | |
11473 this.pendingDeleteItems_ = null; | |
11474 this.pendingDeletePromise_ = null; | |
11475 }, | |
11476 }; | |
11477 | |
11478 cr.addSingletonGetter(BrowserService); | |
11479 | |
11480 return {BrowserService: BrowserService}; | |
11481 }); | |
11482 | |
11483 /** | |
11484 * Called by the history backend when deletion was succesful. | |
11485 */ | |
11486 function deleteComplete() { | |
11487 md_history.BrowserService.getInstance().resolveDelete_(true); | |
11488 } | |
11489 | |
11490 /** | |
11491 * Called by the history backend when the deletion failed. | |
11492 */ | |
11493 function deleteFailed() { | |
11494 md_history.BrowserService.getInstance().resolveDelete_(false); | |
11495 }; | |
11496 // Copyright 2016 The Chromium Authors. All rights reserved. | |
11497 // Use of this source code is governed by a BSD-style license that can be | |
11498 // found in the LICENSE file. | |
11499 | |
11500 Polymer({ | 11502 Polymer({ |
11501 is: 'history-searched-label', | 11503 is: 'history-searched-label', |
11502 | 11504 |
11503 properties: { | 11505 properties: { |
11504 // The text to show in this label. | 11506 // The text to show in this label. |
11505 title: String, | 11507 title: String, |
11506 | 11508 |
11507 // The search term to bold within the title. | 11509 // The search term to bold within the title. |
11508 searchTerm: String, | 11510 searchTerm: String, |
11509 }, | 11511 }, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11608 * Remove bookmark of current item when bookmark-star is clicked. | 11610 * Remove bookmark of current item when bookmark-star is clicked. |
11609 * @private | 11611 * @private |
11610 */ | 11612 */ |
11611 onRemoveBookmarkTap_: function() { | 11613 onRemoveBookmarkTap_: function() { |
11612 if (!this.item.starred) | 11614 if (!this.item.starred) |
11613 return; | 11615 return; |
11614 | 11616 |
11615 if (this.$$('#bookmark-star') == this.root.activeElement) | 11617 if (this.$$('#bookmark-star') == this.root.activeElement) |
11616 this.$['menu-button'].focus(); | 11618 this.$['menu-button'].focus(); |
11617 | 11619 |
11618 md_history.BrowserService.getInstance() | 11620 var browserService = md_history.BrowserService.getInstance(); |
11619 .removeBookmark(this.item.url); | 11621 browserService.removeBookmark(this.item.url); |
| 11622 browserService.recordAction('BookmarkStarClicked'); |
| 11623 |
11620 this.fire('remove-bookmark-stars', this.item.url); | 11624 this.fire('remove-bookmark-stars', this.item.url); |
11621 }, | 11625 }, |
11622 | 11626 |
11623 /** | 11627 /** |
11624 * Fires a custom event when the menu button is clicked. Sends the details | 11628 * Fires a custom event when the menu button is clicked. Sends the details |
11625 * of the history item and where the menu should appear. | 11629 * of the history item and where the menu should appear. |
11626 */ | 11630 */ |
11627 onMenuButtonTap_: function(e) { | 11631 onMenuButtonTap_: function(e) { |
11628 this.fire('toggle-menu', { | 11632 this.fire('toggle-menu', { |
11629 target: Polymer.dom(e).localTarget, | 11633 target: Polymer.dom(e).localTarget, |
11630 item: this.item, | 11634 item: this.item, |
11631 path: this.path, | 11635 path: this.path, |
11632 }); | 11636 }); |
11633 | 11637 |
11634 // Stops the 'tap' event from closing the menu when it opens. | 11638 // Stops the 'tap' event from closing the menu when it opens. |
11635 e.stopPropagation(); | 11639 e.stopPropagation(); |
11636 }, | 11640 }, |
11637 | 11641 |
11638 /** | 11642 /** |
| 11643 * Record metrics when a result is clicked. This is deliberately tied to |
| 11644 * on-click rather than on-tap, as on-click triggers from middle clicks. |
| 11645 */ |
| 11646 onLinkClick_: function() { |
| 11647 var browserService = md_history.BrowserService.getInstance(); |
| 11648 browserService.recordAction('EntryLinkClick'); |
| 11649 browserService.recordHistogram( |
| 11650 'HistoryPage.ClickPosition', this.item.index, UMA_MAX_BUCKET_VALUE); |
| 11651 |
| 11652 if (this.item.index <= UMA_MAX_SUBSET_BUCKET_VALUE) { |
| 11653 browserService.recordHistogram( |
| 11654 'HistoryPage.ClickPositionSubset', this.item.index, |
| 11655 UMA_MAX_SUBSET_BUCKET_VALUE); |
| 11656 } |
| 11657 |
| 11658 if (this.searchTerm) |
| 11659 browserService.recordAction('SearchResultClick'); |
| 11660 }, |
| 11661 |
| 11662 onLinkRightClick_: function() { |
| 11663 md_history.BrowserService.getInstance().recordAction( |
| 11664 'EntryLinkRightClick'); |
| 11665 }, |
| 11666 |
| 11667 /** |
11639 * Set the favicon image, based on the URL of the history item. | 11668 * Set the favicon image, based on the URL of the history item. |
11640 * @private | 11669 * @private |
11641 */ | 11670 */ |
11642 showIcon_: function() { | 11671 showIcon_: function() { |
11643 this.$.icon.style.backgroundImage = | 11672 this.$.icon.style.backgroundImage = |
11644 cr.icon.getFaviconImageSet(this.item.url); | 11673 cr.icon.getFaviconImageSet(this.item.url); |
11645 }, | 11674 }, |
11646 | 11675 |
11647 selectionNotAllowed_: function() { | 11676 selectionNotAllowed_: function() { |
11648 return !loadTimeData.getBoolean('allowDeletingHistory'); | 11677 return !loadTimeData.getBoolean('allowDeletingHistory'); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11868 node.indexes.forEach(function(index) { | 11897 node.indexes.forEach(function(index) { |
11869 if (node.leaf || this.removeItemsBeneathNode_(node.children[index])) { | 11898 if (node.leaf || this.removeItemsBeneathNode_(node.children[index])) { |
11870 var item = array.splice(index, 1); | 11899 var item = array.splice(index, 1); |
11871 splices.push({ | 11900 splices.push({ |
11872 index: index, | 11901 index: index, |
11873 removed: [item], | 11902 removed: [item], |
11874 addedCount: 0, | 11903 addedCount: 0, |
11875 object: array, | 11904 object: array, |
11876 type: 'splice' | 11905 type: 'splice' |
11877 }); | 11906 }); |
| 11907 var browserService = md_history.BrowserService.getInstance(); |
| 11908 browserService.recordHistogram( |
| 11909 'HistoryPage.RemoveEntryPosition', index, UMA_MAX_BUCKET_VALUE); |
| 11910 if (index <= UMA_MAX_SUBSET_BUCKET_VALUE) { |
| 11911 browserService.recordHistogram( |
| 11912 'HistoryPage.RemoveEntryPositionSubset', index, |
| 11913 UMA_MAX_SUBSET_BUCKET_VALUE); |
| 11914 } |
11878 } | 11915 } |
11879 }.bind(this)); | 11916 }.bind(this)); |
11880 | 11917 |
11881 if (array.length == 0) | 11918 if (array.length == 0) |
11882 return true; | 11919 return true; |
11883 | 11920 |
11884 // notifySplices gives better performance than individually splicing as it | 11921 // notifySplices gives better performance than individually splicing as it |
11885 // batches all of the updates together. | 11922 // batches all of the updates together. |
11886 this.notifySplices(node.currentPath, splices); | 11923 this.notifySplices(node.currentPath, splices); |
11887 return false; | 11924 return false; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12051 pushCurrentDay(); | 12088 pushCurrentDay(); |
12052 | 12089 |
12053 this.groupedHistoryData_ = days; | 12090 this.groupedHistoryData_ = days; |
12054 } else if (this.range == HistoryRange.MONTH) { | 12091 } else if (this.range == HistoryRange.MONTH) { |
12055 // Group each all visits into a single list. | 12092 // Group each all visits into a single list. |
12056 this.groupedHistoryData_ = [{ | 12093 this.groupedHistoryData_ = [{ |
12057 title: this.queryStartTime + ' – ' + this.queryEndTime, | 12094 title: this.queryStartTime + ' – ' + this.queryEndTime, |
12058 domains: this.createHistoryDomains_(this.historyData) | 12095 domains: this.createHistoryDomains_(this.historyData) |
12059 }]; | 12096 }]; |
12060 } | 12097 } |
| 12098 |
| 12099 this.addItemIndexes(); |
| 12100 }, |
| 12101 |
| 12102 addItemIndexes: function() { |
| 12103 var index = 0; |
| 12104 this.groupedHistoryData_.forEach(function(group) { |
| 12105 group.domains.forEach(function(domain) { |
| 12106 domain.visits.forEach(function(visit) { |
| 12107 visit.index = index++; |
| 12108 }); |
| 12109 }); |
| 12110 }); |
12061 }, | 12111 }, |
12062 | 12112 |
12063 /** | 12113 /** |
12064 * @param {{model:Object, currentTarget:IronCollapseElement}} e | 12114 * @param {{model:Object, currentTarget:IronCollapseElement}} e |
12065 */ | 12115 */ |
12066 toggleDomainExpanded_: function(e) { | 12116 toggleDomainExpanded_: function(e) { |
12067 var collapse = e.currentTarget.parentNode.querySelector('iron-collapse'); | 12117 var collapse = e.currentTarget.parentNode.querySelector('iron-collapse'); |
12068 e.model.set('domain.rendered', true); | 12118 e.model.set('domain.rendered', true); |
12069 | 12119 |
12070 // Give the history-items time to render. | 12120 // Give the history-items time to render. |
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14152 .clearTriggers(); | 14202 .clearTriggers(); |
14153 | 14203 |
14154 if (this.lastSearchedTerm_ != this.searchedTerm) { | 14204 if (this.lastSearchedTerm_ != this.searchedTerm) { |
14155 this.resultLoadingDisabled_ = false; | 14205 this.resultLoadingDisabled_ = false; |
14156 if (this.historyData_) | 14206 if (this.historyData_) |
14157 this.splice('historyData_', 0, this.historyData_.length); | 14207 this.splice('historyData_', 0, this.historyData_.length); |
14158 this.fire('unselect-all'); | 14208 this.fire('unselect-all'); |
14159 this.lastSearchedTerm_ = this.searchedTerm; | 14209 this.lastSearchedTerm_ = this.searchedTerm; |
14160 } | 14210 } |
14161 | 14211 |
| 14212 results.forEach(function(item, index) { |
| 14213 item.index = index + (this.historyData_ ? this.historyData_.length : 0); |
| 14214 }); |
| 14215 |
14162 if (this.historyData_) { | 14216 if (this.historyData_) { |
14163 // If we have previously received data, push the new items onto the | 14217 // If we have previously received data, push the new items onto the |
14164 // existing array. | 14218 // existing array. |
14165 results.unshift('historyData_'); | 14219 results.unshift('historyData_'); |
14166 this.push.apply(this, results); | 14220 this.push.apply(this, results); |
14167 } else { | 14221 } else { |
14168 // The first time we receive data, use set() to ensure the iron-list is | 14222 // The first time we receive data, use set() to ensure the iron-list is |
14169 // initialized correctly. | 14223 // initialized correctly. |
14170 this.set('historyData_', results); | 14224 this.set('historyData_', results); |
14171 } | 14225 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14446 this.getSelectedList_().unselectAllItems(count); | 14500 this.getSelectedList_().unselectAllItems(count); |
14447 }, | 14501 }, |
14448 | 14502 |
14449 /** | 14503 /** |
14450 * Delete all the currently selected history items. Will prompt the user with | 14504 * Delete all the currently selected history items. Will prompt the user with |
14451 * a dialog to confirm that the deletion should be performed. | 14505 * a dialog to confirm that the deletion should be performed. |
14452 */ | 14506 */ |
14453 deleteSelectedWithPrompt: function() { | 14507 deleteSelectedWithPrompt: function() { |
14454 if (!loadTimeData.getBoolean('allowDeletingHistory')) | 14508 if (!loadTimeData.getBoolean('allowDeletingHistory')) |
14455 return; | 14509 return; |
| 14510 |
| 14511 var browserService = md_history.BrowserService.getInstance(); |
| 14512 browserService.recordAction('RemoveSelected'); |
| 14513 if (this.searchTerm != '') |
| 14514 browserService.recordAction('SearchResultRemove'); |
14456 this.$.dialog.get().then(function(dialog) { | 14515 this.$.dialog.get().then(function(dialog) { |
14457 dialog.showModal(); | 14516 dialog.showModal(); |
14458 }); | 14517 }); |
14459 }, | 14518 }, |
14460 | 14519 |
14461 /** | 14520 /** |
14462 * @param {HistoryRange} range | 14521 * @param {HistoryRange} range |
14463 * @private | 14522 * @private |
14464 */ | 14523 */ |
14465 groupedRangeChanged_: function(range, oldRange) { | 14524 groupedRangeChanged_: function(range, oldRange) { |
(...skipping 28 matching lines...) Expand all Loading... |
14494 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort; | 14553 info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort; |
14495 | 14554 |
14496 if (results[i].dateRelativeDay != currentDate) { | 14555 if (results[i].dateRelativeDay != currentDate) { |
14497 currentDate = results[i].dateRelativeDay; | 14556 currentDate = results[i].dateRelativeDay; |
14498 } | 14557 } |
14499 } | 14558 } |
14500 }, | 14559 }, |
14501 | 14560 |
14502 /** @private */ | 14561 /** @private */ |
14503 onDialogConfirmTap_: function() { | 14562 onDialogConfirmTap_: function() { |
| 14563 md_history.BrowserService.getInstance().recordAction( |
| 14564 'ConfirmRemoveSelected'); |
| 14565 |
14504 this.getSelectedList_().deleteSelected(); | 14566 this.getSelectedList_().deleteSelected(); |
14505 var dialog = assert(this.$.dialog.getIfExists()); | 14567 var dialog = assert(this.$.dialog.getIfExists()); |
14506 dialog.close(); | 14568 dialog.close(); |
14507 }, | 14569 }, |
14508 | 14570 |
14509 /** @private */ | 14571 /** @private */ |
14510 onDialogCancelTap_: function() { | 14572 onDialogCancelTap_: function() { |
| 14573 md_history.BrowserService.getInstance().recordAction( |
| 14574 'CancelRemoveSelected'); |
| 14575 |
14511 var dialog = assert(this.$.dialog.getIfExists()); | 14576 var dialog = assert(this.$.dialog.getIfExists()); |
14512 dialog.close(); | 14577 dialog.close(); |
14513 }, | 14578 }, |
14514 | 14579 |
14515 /** | 14580 /** |
14516 * Closes the overflow menu. | 14581 * Closes the overflow menu. |
14517 * @private | 14582 * @private |
14518 */ | 14583 */ |
14519 closeMenu_: function() { | 14584 closeMenu_: function() { |
14520 var menu = this.$.sharedMenu.getIfExists(); | 14585 var menu = this.$.sharedMenu.getIfExists(); |
(...skipping 11 matching lines...) Expand all Loading... |
14532 toggleMenu_: function(e) { | 14597 toggleMenu_: function(e) { |
14533 var target = e.detail.target; | 14598 var target = e.detail.target; |
14534 return this.$.sharedMenu.get().then(function(menu) { | 14599 return this.$.sharedMenu.get().then(function(menu) { |
14535 /** @type {CrSharedMenuElement} */(menu).toggleMenu( | 14600 /** @type {CrSharedMenuElement} */(menu).toggleMenu( |
14536 target, e.detail); | 14601 target, e.detail); |
14537 }); | 14602 }); |
14538 }, | 14603 }, |
14539 | 14604 |
14540 /** @private */ | 14605 /** @private */ |
14541 onMoreFromSiteTap_: function() { | 14606 onMoreFromSiteTap_: function() { |
| 14607 md_history.BrowserService.getInstance().recordAction( |
| 14608 'EntryMenuShowMoreFromSite'); |
| 14609 |
14542 var menu = assert(this.$.sharedMenu.getIfExists()); | 14610 var menu = assert(this.$.sharedMenu.getIfExists()); |
14543 this.fire('search-domain', {domain: menu.itemData.item.domain}); | 14611 this.fire('search-domain', {domain: menu.itemData.item.domain}); |
14544 menu.closeMenu(); | 14612 menu.closeMenu(); |
14545 }, | 14613 }, |
14546 | 14614 |
14547 /** @private */ | 14615 /** @private */ |
14548 onRemoveFromHistoryTap_: function() { | 14616 onRemoveFromHistoryTap_: function() { |
| 14617 var browserService = md_history.BrowserService.getInstance(); |
| 14618 browserService.recordAction('EntryMenuRemoveFromHistory'); |
14549 var menu = assert(this.$.sharedMenu.getIfExists()); | 14619 var menu = assert(this.$.sharedMenu.getIfExists()); |
14550 var itemData = menu.itemData; | 14620 var itemData = menu.itemData; |
14551 md_history.BrowserService.getInstance() | 14621 browserService.deleteItems([itemData.item]) |
14552 .deleteItems([itemData.item]) | |
14553 .then(function(items) { | 14622 .then(function(items) { |
14554 this.getSelectedList_().removeItemsByPath([itemData.path]); | 14623 this.getSelectedList_().removeItemsByPath([itemData.path]); |
14555 // This unselect-all is to reset the toolbar when deleting a selected | 14624 // This unselect-all is to reset the toolbar when deleting a selected |
14556 // item. TODO(tsergeant): Make this automatic based on observing list | 14625 // item. TODO(tsergeant): Make this automatic based on observing list |
14557 // modifications. | 14626 // modifications. |
14558 this.fire('unselect-all'); | 14627 this.fire('unselect-all'); |
14559 }.bind(this)); | 14628 }.bind(this)); |
14560 menu.closeMenu(); | 14629 menu.closeMenu(); |
14561 }, | 14630 }, |
14562 | 14631 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14610 }, | 14679 }, |
14611 | 14680 |
14612 /** | 14681 /** |
14613 * Open a single synced tab. Listens to 'click' rather than 'tap' | 14682 * Open a single synced tab. Listens to 'click' rather than 'tap' |
14614 * to determine what modifier keys were pressed. | 14683 * to determine what modifier keys were pressed. |
14615 * @param {DomRepeatClickEvent} e | 14684 * @param {DomRepeatClickEvent} e |
14616 * @private | 14685 * @private |
14617 */ | 14686 */ |
14618 openTab_: function(e) { | 14687 openTab_: function(e) { |
14619 var tab = /** @type {ForeignSessionTab} */(e.model.tab); | 14688 var tab = /** @type {ForeignSessionTab} */(e.model.tab); |
14620 md_history.BrowserService.getInstance().openForeignSessionTab( | 14689 var browserService = md_history.BrowserService.getInstance(); |
| 14690 browserService.recordHistogram( |
| 14691 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.LINK_CLICKED, |
| 14692 SyncedTabsHistogram.LIMIT); |
| 14693 browserService.openForeignSessionTab( |
14621 this.sessionTag, tab.windowId, tab.sessionId, e); | 14694 this.sessionTag, tab.windowId, tab.sessionId, e); |
14622 e.preventDefault(); | 14695 e.preventDefault(); |
14623 }, | 14696 }, |
14624 | 14697 |
14625 /** | 14698 /** |
14626 * Toggles the dropdown display of synced tabs for each device card. | 14699 * Toggles the dropdown display of synced tabs for each device card. |
14627 */ | 14700 */ |
14628 toggleTabCard: function() { | 14701 toggleTabCard: function() { |
| 14702 var histogramValue = this.$.collapse.opened ? |
| 14703 SyncedTabsHistogram.COLLAPSE_SESSION : |
| 14704 SyncedTabsHistogram.EXPAND_SESSION; |
| 14705 |
| 14706 md_history.BrowserService.getInstance().recordHistogram( |
| 14707 SYNCED_TABS_HISTOGRAM_NAME, histogramValue, |
| 14708 SyncedTabsHistogram.LIMIT); |
| 14709 |
14629 this.$.collapse.toggle(); | 14710 this.$.collapse.toggle(); |
14630 this.$['dropdown-indicator'].icon = | 14711 this.$['dropdown-indicator'].icon = |
14631 this.$.collapse.opened ? 'cr:expand-less' : 'cr:expand-more'; | 14712 this.$.collapse.opened ? 'cr:expand-less' : 'cr:expand-more'; |
14632 }, | 14713 }, |
14633 | 14714 |
14634 /** | 14715 /** |
14635 * When the synced tab information is set, the icon associated with the tab | 14716 * When the synced tab information is set, the icon associated with the tab |
14636 * website is also set. | 14717 * website is also set. |
14637 * @private | 14718 * @private |
14638 */ | 14719 */ |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14709 * @type {!Array<!ForeignDeviceInternal>} | 14790 * @type {!Array<!ForeignDeviceInternal>} |
14710 */ | 14791 */ |
14711 syncedDevices_: { | 14792 syncedDevices_: { |
14712 type: Array, | 14793 type: Array, |
14713 value: function() { return []; } | 14794 value: function() { return []; } |
14714 }, | 14795 }, |
14715 | 14796 |
14716 /** @private */ | 14797 /** @private */ |
14717 signInState: { | 14798 signInState: { |
14718 type: Boolean, | 14799 type: Boolean, |
14719 // Updated on attach by chrome.sending 'otherDevicesInitialized'. | |
14720 value: loadTimeData.getBoolean('isUserSignedIn'), | |
14721 observer: 'signInStateChanged_', | 14800 observer: 'signInStateChanged_', |
14722 }, | 14801 }, |
14723 | 14802 |
14724 /** @private */ | 14803 /** @private */ |
14725 guestSession_: { | 14804 guestSession_: { |
14726 type: Boolean, | 14805 type: Boolean, |
14727 value: loadTimeData.getBoolean('isGuestSession'), | 14806 value: loadTimeData.getBoolean('isGuestSession'), |
14728 }, | 14807 }, |
14729 | 14808 |
14730 /** @private */ | 14809 /** @private */ |
14731 fetchingSyncedTabs_: { | 14810 fetchingSyncedTabs_: { |
14732 type: Boolean, | 14811 type: Boolean, |
14733 value: false, | 14812 value: false, |
14734 } | 14813 }, |
| 14814 |
| 14815 hasSeenForeignData_: Boolean, |
14735 }, | 14816 }, |
14736 | 14817 |
14737 listeners: { | 14818 listeners: { |
14738 'toggle-menu': 'onToggleMenu_', | 14819 'toggle-menu': 'onToggleMenu_', |
14739 }, | 14820 }, |
14740 | 14821 |
14741 /** @override */ | 14822 /** @override */ |
14742 attached: function() { | 14823 attached: function() { |
14743 // Update the sign in state. | 14824 // Update the sign in state. |
14744 chrome.send('otherDevicesInitialized'); | 14825 chrome.send('otherDevicesInitialized'); |
| 14826 md_history.BrowserService.getInstance().recordHistogram( |
| 14827 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.INITIALIZED, |
| 14828 SyncedTabsHistogram.LIMIT); |
14745 }, | 14829 }, |
14746 | 14830 |
14747 /** | 14831 /** |
14748 * @param {!ForeignSession} session | 14832 * @param {!ForeignSession} session |
14749 * @return {!ForeignDeviceInternal} | 14833 * @return {!ForeignDeviceInternal} |
14750 */ | 14834 */ |
14751 createInternalDevice_: function(session) { | 14835 createInternalDevice_: function(session) { |
14752 var tabs = []; | 14836 var tabs = []; |
14753 var separatorIndexes = []; | 14837 var separatorIndexes = []; |
14754 for (var i = 0; i < session.windows.length; i++) { | 14838 for (var i = 0; i < session.windows.length; i++) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14794 }, | 14878 }, |
14795 | 14879 |
14796 onToggleMenu_: function(e) { | 14880 onToggleMenu_: function(e) { |
14797 this.$.menu.get().then(function(menu) { | 14881 this.$.menu.get().then(function(menu) { |
14798 menu.toggleMenu(e.detail.target, e.detail.tag); | 14882 menu.toggleMenu(e.detail.target, e.detail.tag); |
14799 }); | 14883 }); |
14800 }, | 14884 }, |
14801 | 14885 |
14802 onOpenAllTap_: function() { | 14886 onOpenAllTap_: function() { |
14803 var menu = assert(this.$.menu.getIfExists()); | 14887 var menu = assert(this.$.menu.getIfExists()); |
14804 md_history.BrowserService.getInstance().openForeignSessionAllTabs( | 14888 var browserService = md_history.BrowserService.getInstance(); |
| 14889 browserService.recordHistogram( |
| 14890 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.OPEN_ALL, |
| 14891 SyncedTabsHistogram.LIMIT); |
| 14892 browserService.openForeignSessionAllTabs( |
14805 menu.itemData); | 14893 menu.itemData); |
14806 menu.closeMenu(); | 14894 menu.closeMenu(); |
14807 }, | 14895 }, |
14808 | 14896 |
14809 onDeleteSessionTap_: function() { | 14897 onDeleteSessionTap_: function() { |
14810 var menu = assert(this.$.menu.getIfExists()); | 14898 var menu = assert(this.$.menu.getIfExists()); |
14811 md_history.BrowserService.getInstance().deleteForeignSession( | 14899 var browserService = md_history.BrowserService.getInstance(); |
14812 menu.itemData); | 14900 browserService.recordHistogram( |
| 14901 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HIDE_FOR_NOW, |
| 14902 SyncedTabsHistogram.LIMIT); |
| 14903 browserService.deleteForeignSession(menu.itemData); |
14813 menu.closeMenu(); | 14904 menu.closeMenu(); |
14814 }, | 14905 }, |
14815 | 14906 |
14816 /** @private */ | 14907 /** @private */ |
14817 clearDisplayedSyncedDevices_: function() { | 14908 clearDisplayedSyncedDevices_: function() { |
14818 this.syncedDevices_ = []; | 14909 this.syncedDevices_ = []; |
14819 }, | 14910 }, |
14820 | 14911 |
14821 /** | 14912 /** |
14822 * Decide whether or not should display no synced tabs message. | 14913 * Decide whether or not should display no synced tabs message. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14868 * about updating individual tabs rather than replacing whole sessions, but | 14959 * about updating individual tabs rather than replacing whole sessions, but |
14869 * this approach seems to have acceptable performance. | 14960 * this approach seems to have acceptable performance. |
14870 * @param {?Array<!ForeignSession>} sessionList | 14961 * @param {?Array<!ForeignSession>} sessionList |
14871 */ | 14962 */ |
14872 updateSyncedDevices: function(sessionList) { | 14963 updateSyncedDevices: function(sessionList) { |
14873 this.fetchingSyncedTabs_ = false; | 14964 this.fetchingSyncedTabs_ = false; |
14874 | 14965 |
14875 if (!sessionList) | 14966 if (!sessionList) |
14876 return; | 14967 return; |
14877 | 14968 |
| 14969 if (sessionList.length > 0 && !this.hasSeenForeignData_) { |
| 14970 this.hasSeenForeignData_ = true; |
| 14971 md_history.BrowserService.getInstance().recordHistogram( |
| 14972 SYNCED_TABS_HISTOGRAM_NAME, SyncedTabsHistogram.HAS_FOREIGN_DATA, |
| 14973 SyncedTabsHistogram.LIMIT); |
| 14974 } |
| 14975 |
14878 // First, update any existing devices that have changed. | 14976 // First, update any existing devices that have changed. |
14879 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); | 14977 var updateCount = Math.min(sessionList.length, this.syncedDevices_.length); |
14880 for (var i = 0; i < updateCount; i++) { | 14978 for (var i = 0; i < updateCount; i++) { |
14881 var oldDevice = this.syncedDevices_[i]; | 14979 var oldDevice = this.syncedDevices_[i]; |
14882 if (oldDevice.tag != sessionList[i].tag || | 14980 if (oldDevice.tag != sessionList[i].tag || |
14883 oldDevice.timestamp != sessionList[i].timestamp) { | 14981 oldDevice.timestamp != sessionList[i].timestamp) { |
14884 this.splice( | 14982 this.splice( |
14885 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); | 14983 'syncedDevices_', i, 1, this.createInternalDevice_(sessionList[i])); |
14886 } | 14984 } |
14887 } | 14985 } |
(...skipping 11 matching lines...) Expand all Loading... |
14899 this.fetchingSyncedTabs_ = false; | 14997 this.fetchingSyncedTabs_ = false; |
14900 this.clearDisplayedSyncedDevices_(); | 14998 this.clearDisplayedSyncedDevices_(); |
14901 }, | 14999 }, |
14902 | 15000 |
14903 /** | 15001 /** |
14904 * Get called when user's sign in state changes, this will affect UI of synced | 15002 * Get called when user's sign in state changes, this will affect UI of synced |
14905 * tabs page. Sign in promo gets displayed when user is signed out, and | 15003 * tabs page. Sign in promo gets displayed when user is signed out, and |
14906 * different messages are shown when there are no synced tabs. | 15004 * different messages are shown when there are no synced tabs. |
14907 * @param {boolean} signInState | 15005 * @param {boolean} signInState |
14908 */ | 15006 */ |
14909 signInStateChanged_: function(signInState) { | 15007 signInStateChanged_: function() { |
14910 this.fire('history-view-changed'); | 15008 this.fire('history-view-changed'); |
14911 | 15009 |
14912 // User signed out, clear synced device list and show the sign in promo. | 15010 // User signed out, clear synced device list and show the sign in promo. |
14913 if (!signInState) { | 15011 if (!this.signInState) { |
14914 this.clearDisplayedSyncedDevices_(); | 15012 this.clearDisplayedSyncedDevices_(); |
14915 return; | 15013 return; |
14916 } | 15014 } |
14917 // User signed in, show the loading message when querying for synced | 15015 // User signed in, show the loading message when querying for synced |
14918 // devices. | 15016 // devices. |
14919 this.fetchingSyncedTabs_ = true; | 15017 this.fetchingSyncedTabs_ = true; |
14920 }, | 15018 }, |
14921 | 15019 |
14922 searchTermChanged: function(searchTerm) { | 15020 searchTermChanged: function(searchTerm) { |
14923 this.clearDisplayedSyncedDevices_(); | 15021 this.clearDisplayedSyncedDevices_(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15016 * @private | 15114 * @private |
15017 */ | 15115 */ |
15018 onSelectorActivate_: function() { this.fire('history-close-drawer'); }, | 15116 onSelectorActivate_: function() { this.fire('history-close-drawer'); }, |
15019 | 15117 |
15020 /** | 15118 /** |
15021 * Relocates the user to the clear browsing data section of the settings page. | 15119 * Relocates the user to the clear browsing data section of the settings page. |
15022 * @param {Event} e | 15120 * @param {Event} e |
15023 * @private | 15121 * @private |
15024 */ | 15122 */ |
15025 onClearBrowsingDataTap_: function(e) { | 15123 onClearBrowsingDataTap_: function(e) { |
15026 md_history.BrowserService.getInstance().recordAction( | 15124 var browserService = md_history.BrowserService.getInstance(); |
15027 'HistoryPage_InitClearBrowsingData'); | 15125 browserService.getInstance().recordAction('InitClearBrowsingData'); |
15028 md_history.BrowserService.getInstance().openClearBrowsingData(); | 15126 browserService.openClearBrowsingData(); |
15029 e.preventDefault(); | 15127 e.preventDefault(); |
15030 }, | 15128 }, |
15031 | 15129 |
15032 /** | 15130 /** |
15033 * @param {Object} route | 15131 * @param {Object} route |
15034 * @private | 15132 * @private |
15035 */ | 15133 */ |
15036 getQueryString_: function(route) { return window.location.search; } | 15134 getQueryString_: function(route) { return window.location.search; } |
15037 }); | 15135 }); |
15038 // Copyright 2016 The Chromium Authors. All rights reserved. | 15136 // Copyright 2016 The Chromium Authors. All rights reserved. |
(...skipping 26 matching lines...) Expand all Loading... |
15065 searchTerm: '', | 15163 searchTerm: '', |
15066 // TODO(calamity): Make history toolbar buttons change the offset | 15164 // TODO(calamity): Make history toolbar buttons change the offset |
15067 groupedOffset: 0, | 15165 groupedOffset: 0, |
15068 | 15166 |
15069 set range(val) { this._range = Number(val); }, | 15167 set range(val) { this._range = Number(val); }, |
15070 get range() { return this._range; }, | 15168 get range() { return this._range; }, |
15071 }; | 15169 }; |
15072 } | 15170 } |
15073 }, | 15171 }, |
15074 | 15172 |
15075 /** @type {!QueryResult} */ | 15173 /** @type {!QueryResult} */ |
15076 queryResult_: { | 15174 queryResult_: { |
15077 type: Object, | 15175 type: Object, |
15078 value: function() { | 15176 value: function() { |
15079 return { | 15177 return { |
15080 info: null, | 15178 info: null, |
15081 results: null, | 15179 results: null, |
15082 sessionList: null, | 15180 sessionList: null, |
15083 }; | 15181 }; |
15084 } | 15182 } |
15085 }, | 15183 }, |
15086 | 15184 |
15087 // Route data for the current page. | 15185 // Route data for the current page. |
15088 routeData_: Object, | 15186 routeData_: Object, |
15089 | 15187 |
15090 // The query params for the page. | 15188 // The query params for the page. |
15091 queryParams_: Object, | 15189 queryParams_: Object, |
15092 | 15190 |
15093 // True if the window is narrow enough for the page to have a drawer. | 15191 // True if the window is narrow enough for the page to have a drawer. |
15094 hasDrawer: Boolean, | 15192 hasDrawer: Boolean, |
| 15193 |
| 15194 isUserSignedIn_: { |
| 15195 type: Boolean, |
| 15196 // Updated on synced-device-manager attach by chrome.sending |
| 15197 // 'otherDevicesInitialized'. |
| 15198 value: loadTimeData.getBoolean('isUserSignedIn'), |
| 15199 }, |
15095 }, | 15200 }, |
15096 | 15201 |
15097 observers: [ | 15202 observers: [ |
15098 // routeData_.page <=> selectedPage | 15203 // routeData_.page <=> selectedPage |
15099 'routeDataChanged_(routeData_.page)', | 15204 'routeDataChanged_(routeData_.page)', |
15100 'selectedPageChanged_(selectedPage_)', | 15205 'selectedPageChanged_(selectedPage_)', |
15101 | 15206 |
15102 // queryParams_.q <=> queryState.searchTerm | 15207 // queryParams_.q <=> queryState.searchTerm |
15103 'searchTermChanged_(queryState_.searchTerm)', | 15208 'searchTermChanged_(queryState_.searchTerm)', |
15104 'searchQueryParamChanged_(queryParams_.q)', | 15209 'searchQueryParamChanged_(queryParams_.q)', |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15155 * @private | 15260 * @private |
15156 */ | 15261 */ |
15157 unselectAll: function() { | 15262 unselectAll: function() { |
15158 var listContainer = | 15263 var listContainer = |
15159 /** @type {HistoryListContainerElement} */ (this.$.history); | 15264 /** @type {HistoryListContainerElement} */ (this.$.history); |
15160 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); | 15265 var toolbar = /** @type {HistoryToolbarElement} */ (this.$.toolbar); |
15161 listContainer.unselectAllItems(toolbar.count); | 15266 listContainer.unselectAllItems(toolbar.count); |
15162 toolbar.count = 0; | 15267 toolbar.count = 0; |
15163 }, | 15268 }, |
15164 | 15269 |
15165 deleteSelected: function() { | 15270 deleteSelected: function() { this.$.history.deleteSelectedWithPrompt(); }, |
15166 this.$.history.deleteSelectedWithPrompt(); | |
15167 }, | |
15168 | 15271 |
15169 /** | 15272 /** |
15170 * @param {HistoryQuery} info An object containing information about the | 15273 * @param {HistoryQuery} info An object containing information about the |
15171 * query. | 15274 * query. |
15172 * @param {!Array<HistoryEntry>} results A list of results. | 15275 * @param {!Array<HistoryEntry>} results A list of results. |
15173 */ | 15276 */ |
15174 historyResult: function(info, results) { | 15277 historyResult: function(info, results) { |
15175 this.set('queryState_.querying', false); | 15278 this.set('queryState_.querying', false); |
15176 this.set('queryResult_.info', info); | 15279 this.set('queryResult_.info', info); |
15177 this.set('queryResult_.results', results); | 15280 this.set('queryResult_.results', results); |
15178 var listContainer = | 15281 var listContainer = |
15179 /** @type {HistoryListContainerElement} */ (this.$['history']); | 15282 /** @type {HistoryListContainerElement} */ (this.$['history']); |
15180 listContainer.historyResult(info, results); | 15283 listContainer.historyResult(info, results); |
15181 }, | 15284 }, |
15182 | 15285 |
15183 /** | 15286 /** |
15184 * Focuses the search bar in the toolbar. | 15287 * Focuses the search bar in the toolbar. |
15185 */ | 15288 */ |
15186 focusToolbarSearchField: function() { | 15289 focusToolbarSearchField: function() { this.$.toolbar.showSearchField(); }, |
15187 this.$.toolbar.showSearchField(); | |
15188 }, | |
15189 | 15290 |
15190 /** | 15291 /** |
15191 * Fired when the user presses 'More from this site'. | 15292 * Fired when the user presses 'More from this site'. |
15192 * @param {{detail: {domain: string}}} e | 15293 * @param {{detail: {domain: string}}} e |
15193 */ | 15294 */ |
15194 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, | 15295 searchDomain_: function(e) { this.$.toolbar.setSearchTerm(e.detail.domain); }, |
15195 | 15296 |
15196 /** | 15297 /** |
15197 * @param {Event} e | 15298 * @param {Event} e |
15198 * @private | 15299 * @private |
(...skipping 13 matching lines...) Expand all Loading... |
15212 } | 15313 } |
15213 }, | 15314 }, |
15214 | 15315 |
15215 /** | 15316 /** |
15216 * @param {string} searchTerm | 15317 * @param {string} searchTerm |
15217 * @private | 15318 * @private |
15218 */ | 15319 */ |
15219 searchTermChanged_: function(searchTerm) { | 15320 searchTermChanged_: function(searchTerm) { |
15220 this.set('queryParams_.q', searchTerm || null); | 15321 this.set('queryParams_.q', searchTerm || null); |
15221 this.$['history'].queryHistory(false); | 15322 this.$['history'].queryHistory(false); |
| 15323 // TODO(tsergeant): Ignore incremental searches in this metric. |
| 15324 if (this.queryState_.searchTerm) |
| 15325 md_history.BrowserService.getInstance().recordAction('Search'); |
15222 }, | 15326 }, |
15223 | 15327 |
15224 /** | 15328 /** |
15225 * @param {string} searchQuery | 15329 * @param {string} searchQuery |
15226 * @private | 15330 * @private |
15227 */ | 15331 */ |
15228 searchQueryParamChanged_: function(searchQuery) { | 15332 searchQueryParamChanged_: function(searchQuery) { |
15229 this.$.toolbar.setSearchTerm(searchQuery || ''); | 15333 this.$.toolbar.setSearchTerm(searchQuery || ''); |
15230 }, | 15334 }, |
15231 | 15335 |
(...skipping 24 matching lines...) Expand all Loading... |
15256 } | 15360 } |
15257 | 15361 |
15258 this.set('queryResult_.sessionList', sessionList); | 15362 this.set('queryResult_.sessionList', sessionList); |
15259 }, | 15363 }, |
15260 | 15364 |
15261 /** | 15365 /** |
15262 * Update sign in state of synced device manager after user logs in or out. | 15366 * Update sign in state of synced device manager after user logs in or out. |
15263 * @param {boolean} isUserSignedIn | 15367 * @param {boolean} isUserSignedIn |
15264 */ | 15368 */ |
15265 updateSignInState: function(isUserSignedIn) { | 15369 updateSignInState: function(isUserSignedIn) { |
15266 var syncedDeviceManagerElem = | 15370 this.isUserSignedIn_ = isUserSignedIn; |
15267 /** @type {HistorySyncedDeviceManagerElement} */this | |
15268 .$$('history-synced-device-manager'); | |
15269 if (syncedDeviceManagerElem) | |
15270 syncedDeviceManagerElem.signInState = isUserSignedIn; | |
15271 }, | 15371 }, |
15272 | 15372 |
15273 /** | 15373 /** |
15274 * @param {string} selectedPage | 15374 * @param {string} selectedPage |
15275 * @return {boolean} | 15375 * @return {boolean} |
15276 * @private | 15376 * @private |
15277 */ | 15377 */ |
15278 syncedTabsSelected_: function(selectedPage) { | 15378 syncedTabsSelected_: function(selectedPage) { |
15279 return selectedPage == 'syncedTabs'; | 15379 return selectedPage == 'syncedTabs'; |
15280 }, | 15380 }, |
15281 | 15381 |
15282 /** | 15382 /** |
15283 * @param {boolean} querying | 15383 * @param {boolean} querying |
15284 * @param {boolean} incremental | 15384 * @param {boolean} incremental |
15285 * @param {string} searchTerm | 15385 * @param {string} searchTerm |
15286 * @return {boolean} Whether a loading spinner should be shown (implies the | 15386 * @return {boolean} Whether a loading spinner should be shown (implies the |
15287 * backend is querying a new search term). | 15387 * backend is querying a new search term). |
15288 * @private | 15388 * @private |
15289 */ | 15389 */ |
15290 shouldShowSpinner_: function(querying, incremental, searchTerm) { | 15390 shouldShowSpinner_: function(querying, incremental, searchTerm) { |
15291 return querying && !incremental && searchTerm != ''; | 15391 return querying && !incremental && searchTerm != ''; |
15292 }, | 15392 }, |
15293 | 15393 |
15294 /** | 15394 /** |
15295 * @param {string} page | 15395 * @param {string} page |
15296 * @private | 15396 * @private |
15297 */ | 15397 */ |
15298 routeDataChanged_: function(page) { | 15398 routeDataChanged_: function(page) { this.selectedPage_ = page; }, |
15299 this.selectedPage_ = page; | |
15300 }, | |
15301 | 15399 |
15302 /** | 15400 /** |
15303 * @param {string} selectedPage | 15401 * @param {string} selectedPage |
15304 * @private | 15402 * @private |
15305 */ | 15403 */ |
15306 selectedPageChanged_: function(selectedPage) { | 15404 selectedPageChanged_: function(selectedPage) { |
15307 this.set('routeData_.page', selectedPage); | 15405 this.set('routeData_.page', selectedPage); |
15308 | 15406 this.recordHistoryView_(); |
15309 // Log the current view on the next animation frame to allow the iron-pages | |
15310 // to detect that the synced-device-manager has been rendered. | |
15311 requestAnimationFrame(function() { | |
15312 this.recordHistoryView_(); | |
15313 }.bind(this)); | |
15314 }, | 15407 }, |
15315 | 15408 |
15316 /** | 15409 /** |
15317 * This computed binding is needed to make the iron-pages selector update when | 15410 * This computed binding is needed to make the iron-pages selector update when |
15318 * the synced-device-manager is instantiated for the first time. Otherwise the | 15411 * the synced-device-manager is instantiated for the first time. Otherwise the |
15319 * fallback selection will continue to be used after the corresponding item is | 15412 * fallback selection will continue to be used after the corresponding item is |
15320 * added as a child of iron-pages. | 15413 * added as a child of iron-pages. |
15321 * @param {string} selectedPage | 15414 * @param {string} selectedPage |
15322 * @param {Array} items | 15415 * @param {Array} items |
15323 * @return {string} | 15416 * @return {string} |
15324 * @private | 15417 * @private |
15325 */ | 15418 */ |
15326 getSelectedPage_: function(selectedPage, items) { | 15419 getSelectedPage_: function(selectedPage, items) { return selectedPage; }, |
15327 return selectedPage; | |
15328 }, | |
15329 | 15420 |
15330 /** @private */ | 15421 /** @private */ |
15331 closeDrawer_: function() { | 15422 closeDrawer_: function() { |
15332 var drawer = this.$$('#drawer'); | 15423 var drawer = this.$$('#drawer'); |
15333 if (drawer) | 15424 if (drawer) |
15334 drawer.close(); | 15425 drawer.close(); |
15335 }, | 15426 }, |
15336 | 15427 |
15337 /** @private */ | 15428 /** @private */ |
15338 recordHistoryView_: function() { | 15429 recordHistoryView_: function() { |
15339 var histogramValue = HistoryViewHistogram.END; | 15430 var histogramValue = HistoryViewHistogram.END; |
15340 switch (this.$.content.selectedItem.id) { | 15431 switch (this.selectedPage_) { |
15341 case 'history': | 15432 case 'syncedTabs': |
| 15433 histogramValue = this.isUserSignedIn_ ? |
| 15434 HistoryViewHistogram.SYNCED_TABS : |
| 15435 HistoryViewHistogram.SIGNIN_PROMO; |
| 15436 break; |
| 15437 default: |
15342 switch (this.queryState_.range) { | 15438 switch (this.queryState_.range) { |
15343 case HistoryRange.ALL_TIME: | 15439 case HistoryRange.ALL_TIME: |
15344 histogramValue = HistoryViewHistogram.HISTORY; | 15440 histogramValue = HistoryViewHistogram.HISTORY; |
15345 break; | 15441 break; |
15346 case HistoryRange.WEEK: | 15442 case HistoryRange.WEEK: |
15347 histogramValue = HistoryViewHistogram.GROUPED_WEEK; | 15443 histogramValue = HistoryViewHistogram.GROUPED_WEEK; |
15348 break; | 15444 break; |
15349 case HistoryRange.MONTH: | 15445 case HistoryRange.MONTH: |
15350 histogramValue = HistoryViewHistogram.GROUPED_MONTH; | 15446 histogramValue = HistoryViewHistogram.GROUPED_MONTH; |
15351 break; | 15447 break; |
15352 } | 15448 } |
15353 break; | 15449 break; |
15354 case 'synced-devices': | |
15355 var syncedDeviceManager = | |
15356 /** @type {HistorySyncedDeviceManagerElement} */ this.$.content | |
15357 .selectedItem; | |
15358 histogramValue = syncedDeviceManager.signInState ? | |
15359 HistoryViewHistogram.SYNCED_TABS : | |
15360 HistoryViewHistogram.SIGNIN_PROMO; | |
15361 break; | |
15362 } | 15450 } |
15363 | 15451 |
15364 md_history.BrowserService.getInstance().recordHistogram( | 15452 md_history.BrowserService.getInstance().recordHistogram( |
15365 'History.HistoryView', histogramValue, HistoryViewHistogram.END | 15453 'History.HistoryView', histogramValue, HistoryViewHistogram.END |
15366 ); | 15454 ); |
15367 }, | 15455 }, |
15368 }); | 15456 }); |
OLD | NEW |