Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <include src="../uber/uber_utils.js"> | 5 <include src="../uber/uber_utils.js"> |
| 6 <include src="history_focus_manager.js"> | 6 <include src="history_focus_manager.js"> |
| 7 | 7 |
| 8 /////////////////////////////////////////////////////////////////////////////// | 8 /////////////////////////////////////////////////////////////////////////////// |
| 9 // Globals: | 9 // Globals: |
| 10 /** @const */ var RESULTS_PER_PAGE = 150; | 10 /** @const */ var RESULTS_PER_PAGE = 150; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 * @param {number} maxBucketValue The max value for the last histogram bucket. | 68 * @param {number} maxBucketValue The max value for the last histogram bucket. |
| 69 * @param {number} value The value to record in the histogram. | 69 * @param {number} value The value to record in the histogram. |
| 70 */ | 70 */ |
| 71 function recordUmaHistogram(histogram, maxBucketValue, value) { | 71 function recordUmaHistogram(histogram, maxBucketValue, value) { |
| 72 chrome.send('metricsHandler:recordInHistogram', | 72 chrome.send('metricsHandler:recordInHistogram', |
| 73 [histogram, | 73 [histogram, |
| 74 ((value > maxBucketValue) ? maxBucketValue : value), | 74 ((value > maxBucketValue) ? maxBucketValue : value), |
| 75 maxBucketValue]); | 75 maxBucketValue]); |
| 76 } | 76 } |
| 77 | 77 |
| 78 /** | |
| 79 * Record the current time in milliseconds since pageload into a UMA histogram. | |
| 80 * @param {string} histogram The name of the histogram to be recorded in. | |
| 81 */ | |
| 82 function recordTimeHistogram(histogram) { | |
|
calamity
2016/08/03 08:23:22
Is this worth moving into cr_util.js?
calamity
2016/08/03 08:23:22
Param no longer needed?
Dan Beam
2016/08/03 21:05:17
why not just inline this method? it's only used o
tsergeant
2016/08/03 22:53:56
Sure, inlined.
| |
| 83 chrome.send('metricsHandler:recordTime', [histogram, performance.now()]); | |
| 84 } | |
| 85 | |
| 78 /////////////////////////////////////////////////////////////////////////////// | 86 /////////////////////////////////////////////////////////////////////////////// |
| 79 // Visit: | 87 // Visit: |
| 80 | 88 |
| 81 /** | 89 /** |
| 82 * Class to hold all the information about an entry in our model. | 90 * Class to hold all the information about an entry in our model. |
| 83 * @param {HistoryEntry} result An object containing the visit's data. | 91 * @param {HistoryEntry} result An object containing the visit's data. |
| 84 * @param {boolean} continued Whether this visit is on the same day as the | 92 * @param {boolean} continued Whether this visit is on the same day as the |
| 85 * visit before it. | 93 * visit before it. |
| 86 * @param {HistoryModel} model The model object this entry belongs to. | 94 * @param {HistoryModel} model The model object this entry belongs to. |
| 87 * @constructor | 95 * @constructor |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 */ | 940 */ |
| 933 function HistoryView(model) { | 941 function HistoryView(model) { |
| 934 this.editButtonTd_ = $('edit-button'); | 942 this.editButtonTd_ = $('edit-button'); |
| 935 this.editingControlsDiv_ = $('editing-controls'); | 943 this.editingControlsDiv_ = $('editing-controls'); |
| 936 this.resultDiv_ = $('results-display'); | 944 this.resultDiv_ = $('results-display'); |
| 937 this.focusGrid_ = new cr.ui.FocusGrid(); | 945 this.focusGrid_ = new cr.ui.FocusGrid(); |
| 938 this.pageDiv_ = $('results-pagination'); | 946 this.pageDiv_ = $('results-pagination'); |
| 939 this.model_ = model; | 947 this.model_ = model; |
| 940 this.pageIndex_ = 0; | 948 this.pageIndex_ = 0; |
| 941 this.lastDisplayed_ = []; | 949 this.lastDisplayed_ = []; |
| 950 this.hasRenderedResults_ = false; | |
| 942 | 951 |
| 943 this.model_.setView(this); | 952 this.model_.setView(this); |
| 944 | 953 |
| 945 this.currentVisits_ = []; | 954 this.currentVisits_ = []; |
| 946 | 955 |
| 947 // If there is no search button, use the search button label as placeholder | 956 // If there is no search button, use the search button label as placeholder |
| 948 // text in the search field. | 957 // text in the search field. |
| 949 if ($('search-button').offsetWidth == 0) | 958 if ($('search-button').offsetWidth == 0) |
| 950 $('search-field').placeholder = $('search-button').value; | 959 $('search-field').placeholder = $('search-button').value; |
| 951 | 960 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 document.body.classList.toggle('has-results', hasResults); | 1124 document.body.classList.toggle('has-results', hasResults); |
| 1116 | 1125 |
| 1117 this.updateFocusGrid_(); | 1126 this.updateFocusGrid_(); |
| 1118 this.updateNavBar_(); | 1127 this.updateNavBar_(); |
| 1119 | 1128 |
| 1120 if (isMobileVersion()) { | 1129 if (isMobileVersion()) { |
| 1121 // Hide the search field if it is empty and there are no results. | 1130 // Hide the search field if it is empty and there are no results. |
| 1122 var isSearch = this.model_.getSearchText().length > 0; | 1131 var isSearch = this.model_.getSearchText().length > 0; |
| 1123 $('search-field').hidden = !(hasResults || isSearch); | 1132 $('search-field').hidden = !(hasResults || isSearch); |
| 1124 } | 1133 } |
| 1134 | |
| 1135 if (!this.hasRenderedResults_) { | |
| 1136 this.hasRenderedResults_ = true; | |
| 1137 requestAnimationFrame(function() { | |
|
tsergeant
2016/08/03 07:37:04
I have two main options here:
* requestAnimationF
calamity
2016/08/03 08:23:23
rAF sgtm.
| |
| 1138 recordTimeHistogram('History.ResultsRenderedTime'); | |
| 1139 }); | |
| 1140 } | |
| 1125 }; | 1141 }; |
| 1126 | 1142 |
| 1127 /** | 1143 /** |
| 1128 * Enables or disables the buttons that control editing entries depending on | 1144 * Enables or disables the buttons that control editing entries depending on |
| 1129 * whether there are any checked boxes. | 1145 * whether there are any checked boxes. |
| 1130 */ | 1146 */ |
| 1131 HistoryView.prototype.updateSelectionEditButtons = function() { | 1147 HistoryView.prototype.updateSelectionEditButtons = function() { |
| 1132 if (loadTimeData.getBoolean('allowDeletingHistory')) { | 1148 if (loadTimeData.getBoolean('allowDeletingHistory')) { |
| 1133 var anyChecked = document.querySelector('.entry input:checked') != null; | 1149 var anyChecked = document.querySelector('.entry input:checked') != null; |
| 1134 $('remove-selected').disabled = !anyChecked; | 1150 $('remove-selected').disabled = !anyChecked; |
| (...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2403 historyView.reload(); | 2419 historyView.reload(); |
| 2404 } | 2420 } |
| 2405 | 2421 |
| 2406 // Add handlers to HTML elements. | 2422 // Add handlers to HTML elements. |
| 2407 document.addEventListener('DOMContentLoaded', load); | 2423 document.addEventListener('DOMContentLoaded', load); |
| 2408 | 2424 |
| 2409 // This event lets us enable and disable menu items before the menu is shown. | 2425 // This event lets us enable and disable menu items before the menu is shown. |
| 2410 document.addEventListener('canExecute', function(e) { | 2426 document.addEventListener('canExecute', function(e) { |
| 2411 e.canExecute = true; | 2427 e.canExecute = true; |
| 2412 }); | 2428 }); |
| OLD | NEW |