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

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: learn_the_alphabet 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 14 matching lines...) Expand all
25 // True if the item is being displayed embedded in another element and 25 // True if the item is being displayed embedded in another element and
26 // should not manage its own borders or size. 26 // should not manage its own borders or size.
27 embedded: {type: Boolean, reflectToAttribute: true}, 27 embedded: {type: Boolean, reflectToAttribute: true},
28 28
29 hasTimeGap: {type: Boolean}, 29 hasTimeGap: {type: Boolean},
30 30
31 numberOfItems: {type: Number}, 31 numberOfItems: {type: Number},
32 32
33 // The path of this history item inside its parent. 33 // The path of this history item inside its parent.
34 path: String, 34 path: String,
35
36 index: Number,
35 }, 37 },
36 38
37 /** 39 /**
38 * When a history-item is selected the toolbar is notified and increases 40 * When a history-item is selected the toolbar is notified and increases
39 * or decreases its count of selected items accordingly. 41 * or decreases its count of selected items accordingly.
40 * @param {MouseEvent} e 42 * @param {MouseEvent} e
41 * @private 43 * @private
42 */ 44 */
43 onCheckboxSelected_: function(e) { 45 onCheckboxSelected_: function(e) {
44 // TODO(calamity): Fire this event whenever |selected| changes. 46 // TODO(calamity): Fire this event whenever |selected| changes.
(...skipping 18 matching lines...) Expand all
63 * Remove bookmark of current item when bookmark-star is clicked. 65 * Remove bookmark of current item when bookmark-star is clicked.
64 * @private 66 * @private
65 */ 67 */
66 onRemoveBookmarkTap_: function() { 68 onRemoveBookmarkTap_: function() {
67 if (!this.item.starred) 69 if (!this.item.starred)
68 return; 70 return;
69 71
70 if (this.$$('#bookmark-star') == this.root.activeElement) 72 if (this.$$('#bookmark-star') == this.root.activeElement)
71 this.$['menu-button'].focus(); 73 this.$['menu-button'].focus();
72 74
73 md_history.BrowserService.getInstance() 75 var browserService = md_history.BrowserService.getInstance();
74 .removeBookmark(this.item.url); 76 browserService.removeBookmark(this.item.url);
77 browserService.recordAction('BookmarkStarClicked');
78
75 this.fire('remove-bookmark-stars', this.item.url); 79 this.fire('remove-bookmark-stars', this.item.url);
76 }, 80 },
77 81
78 /** 82 /**
79 * Fires a custom event when the menu button is clicked. Sends the details 83 * Fires a custom event when the menu button is clicked. Sends the details
80 * of the history item and where the menu should appear. 84 * of the history item and where the menu should appear.
81 */ 85 */
82 onMenuButtonTap_: function(e) { 86 onMenuButtonTap_: function(e) {
83 this.fire('toggle-menu', { 87 this.fire('toggle-menu', {
84 target: Polymer.dom(e).localTarget, 88 target: Polymer.dom(e).localTarget,
89 index: this.index,
85 item: this.item, 90 item: this.item,
86 path: this.path, 91 path: this.path,
87 }); 92 });
88 93
89 // Stops the 'tap' event from closing the menu when it opens. 94 // Stops the 'tap' event from closing the menu when it opens.
90 e.stopPropagation(); 95 e.stopPropagation();
91 }, 96 },
92 97
93 /** 98 /**
99 * Record metrics when a result is clicked. This is deliberately tied to
100 * on-click rather than on-tap, as on-click triggers from middle clicks.
101 */
102 onLinkClick_: function() {
103 var browserService = md_history.BrowserService.getInstance();
104 browserService.recordAction('EntryLinkClick');
105
106 if (this.searchTerm)
107 browserService.recordAction('SearchResultClick');
108
109 if (this.index == undefined)
110 return;
111
112 browserService.recordHistogram(
113 'HistoryPage.ClickPosition', this.index, UMA_MAX_BUCKET_VALUE);
114
115 if (this.index <= UMA_MAX_SUBSET_BUCKET_VALUE) {
116 browserService.recordHistogram(
117 'HistoryPage.ClickPositionSubset', this.index,
118 UMA_MAX_SUBSET_BUCKET_VALUE);
119 }
120 },
121
122 onLinkRightClick_: function() {
123 md_history.BrowserService.getInstance().recordAction(
124 'EntryLinkRightClick');
125 },
126
127 /**
94 * Set the favicon image, based on the URL of the history item. 128 * Set the favicon image, based on the URL of the history item.
95 * @private 129 * @private
96 */ 130 */
97 showIcon_: function() { 131 showIcon_: function() {
98 this.$.icon.style.backgroundImage = 132 this.$.icon.style.backgroundImage =
99 cr.icon.getFaviconImageSet(this.item.url); 133 cr.icon.getFaviconImageSet(this.item.url);
100 }, 134 },
101 135
102 selectionNotAllowed_: function() { 136 selectionNotAllowed_: function() {
103 return !loadTimeData.getBoolean('allowDeletingHistory'); 137 return !loadTimeData.getBoolean('allowDeletingHistory');
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 183
150 if (searchedTerm) 184 if (searchedTerm)
151 return currentItem.dateShort != nextItem.dateShort; 185 return currentItem.dateShort != nextItem.dateShort;
152 186
153 return currentItem.time - nextItem.time > BROWSING_GAP_TIME && 187 return currentItem.time - nextItem.time > BROWSING_GAP_TIME &&
154 currentItem.dateRelativeDay == nextItem.dateRelativeDay; 188 currentItem.dateRelativeDay == nextItem.dateRelativeDay;
155 }; 189 };
156 190
157 return { HistoryItem: HistoryItem }; 191 return { HistoryItem: HistoryItem };
158 }); 192 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/md_history/history_item.html ('k') | chrome/browser/resources/md_history/history_list.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698