Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: chrome/browser/resources/md_history/history_item.js

Issue 2255033002: [MD History] Copy stats from the old history page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sidebar_stats
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 cr.define('md_history', function() { 5 cr.define('md_history', function() {
6 var HistoryItem = Polymer({ 6 var HistoryItem = Polymer({
7 is: 'history-item', 7 is: 'history-item',
8 8
9 properties: { 9 properties: {
10 // Underlying HistoryEntry data for this item. Contains read-only fields 10 // Underlying HistoryEntry data for this item. Contains read-only fields
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 * Remove bookmark of current item when bookmark-star is clicked. 63 * Remove bookmark of current item when bookmark-star is clicked.
64 * @private 64 * @private
65 */ 65 */
66 onRemoveBookmarkTap_: function() { 66 onRemoveBookmarkTap_: function() {
67 if (!this.item.starred) 67 if (!this.item.starred)
68 return; 68 return;
69 69
70 if (this.$$('#bookmark-star') == this.root.activeElement) 70 if (this.$$('#bookmark-star') == this.root.activeElement)
71 this.$['menu-button'].focus(); 71 this.$['menu-button'].focus();
72 72
73 md_history.BrowserService.getInstance() 73 var browserService = md_history.BrowserService.getInstance();
74 .removeBookmark(this.item.url); 74 browserService.removeBookmark(this.item.url);
75 browserService.recordAction('BookmarkStarClicked');
76
75 this.fire('remove-bookmark-stars', this.item.url); 77 this.fire('remove-bookmark-stars', this.item.url);
76 }, 78 },
77 79
78 /** 80 /**
79 * Fires a custom event when the menu button is clicked. Sends the details 81 * Fires a custom event when the menu button is clicked. Sends the details
80 * of the history item and where the menu should appear. 82 * of the history item and where the menu should appear.
81 */ 83 */
82 onMenuButtonTap_: function(e) { 84 onMenuButtonTap_: function(e) {
83 this.fire('toggle-menu', { 85 this.fire('toggle-menu', {
84 target: Polymer.dom(e).localTarget, 86 target: Polymer.dom(e).localTarget,
85 item: this.item, 87 item: this.item,
86 path: this.path, 88 path: this.path,
87 }); 89 });
88 90
89 // Stops the 'tap' event from closing the menu when it opens. 91 // Stops the 'tap' event from closing the menu when it opens.
90 e.stopPropagation(); 92 e.stopPropagation();
91 }, 93 },
92 94
93 /** 95 /**
96 * Record metrics when a result is clicked. This is deliberately tied to
97 * on-click rather than on-tap, as on-click triggers from middle clicks.
98 */
99 onLinkClick_: function() {
100 var browserService = md_history.BrowserService.getInstance();
101 browserService.recordAction('EntryLinkClick');
102 browserService.recordHistogram(
103 'HistoryPage.ClickPosition', this.item.index, UMA_MAX_BUCKET_VALUE);
104
105 if (this.item.index <= UMA_MAX_SUBSET_BUCKET_VALUE) {
106 browserService.recordHistogram(
107 'HistoryPage.ClickPositionSubset', this.item.index,
108 UMA_MAX_SUBSET_BUCKET_VALUE);
109 }
110
111 if (this.searchTerm)
112 browserService.recordAction('SearchResultClick');
113 },
114
115 onLinkRightClick_: function() {
116 md_history.BrowserService.getInstance().recordAction(
117 'EntryLinkRightClick');
118 },
119
120 /**
94 * Set the favicon image, based on the URL of the history item. 121 * Set the favicon image, based on the URL of the history item.
95 * @private 122 * @private
96 */ 123 */
97 showIcon_: function() { 124 showIcon_: function() {
98 this.$.icon.style.backgroundImage = 125 this.$.icon.style.backgroundImage =
99 cr.icon.getFaviconImageSet(this.item.url); 126 cr.icon.getFaviconImageSet(this.item.url);
100 }, 127 },
101 128
102 selectionNotAllowed_: function() { 129 selectionNotAllowed_: function() {
103 return !loadTimeData.getBoolean('allowDeletingHistory'); 130 return !loadTimeData.getBoolean('allowDeletingHistory');
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 176
150 if (searchedTerm) 177 if (searchedTerm)
151 return currentItem.dateShort != nextItem.dateShort; 178 return currentItem.dateShort != nextItem.dateShort;
152 179
153 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && 180 return currentItem.time - nextItem.time > BROWSING_GAP_TIME &&
154 currentItem.dateRelativeDay == nextItem.dateRelativeDay; 181 currentItem.dateRelativeDay == nextItem.dateRelativeDay;
155 }; 182 };
156 183
157 return { HistoryItem: HistoryItem }; 184 return { HistoryItem: HistoryItem };
158 }); 185 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698