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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 * visit before it. | 121 * visit before it. |
122 * @param {HistoryModel} model The model object this entry belongs to. | 122 * @param {HistoryModel} model The model object this entry belongs to. |
123 * @constructor | 123 * @constructor |
124 */ | 124 */ |
125 function Visit(result, continued, model) { | 125 function Visit(result, continued, model) { |
126 this.model_ = model; | 126 this.model_ = model; |
127 this.title_ = result.title; | 127 this.title_ = result.title; |
128 this.url_ = result.url; | 128 this.url_ = result.url; |
129 this.domain_ = result.domain; | 129 this.domain_ = result.domain; |
130 this.starred_ = result.starred; | 130 this.starred_ = result.starred; |
| 131 this.context_ = result.context; |
131 | 132 |
132 // These identify the name and type of the device on which this visit | 133 // These identify the name and type of the device on which this visit |
133 // occurred. They will be empty if the visit occurred on the current device. | 134 // occurred. They will be empty if the visit occurred on the current device. |
134 this.deviceName = result.deviceName; | 135 this.deviceName = result.deviceName; |
135 this.deviceType = result.deviceType; | 136 this.deviceType = result.deviceType; |
136 | 137 |
137 // The ID will be set according to when the visit was displayed, not | 138 // The ID will be set according to when the visit was displayed, not |
138 // received. Set to -1 to show that it has not been set yet. | 139 // received. Set to -1 to show that it has not been set yet. |
139 this.id_ = -1; | 140 this.id_ = -1; |
140 | 141 |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 var maxResults = | 852 var maxResults = |
852 (this.rangeInDays_ == HistoryModel.Range.ALL_TIME) ? RESULTS_PER_PAGE : 0; | 853 (this.rangeInDays_ == HistoryModel.Range.ALL_TIME) ? RESULTS_PER_PAGE : 0; |
853 | 854 |
854 // If there are already some visits, pick up the previous query where it | 855 // If there are already some visits, pick up the previous query where it |
855 // left off. | 856 // left off. |
856 var lastVisit = this.visits_.slice(-1)[0]; | 857 var lastVisit = this.visits_.slice(-1)[0]; |
857 var endTime = lastVisit ? lastVisit.date.getTime() : 0; | 858 var endTime = lastVisit ? lastVisit.date.getTime() : 0; |
858 | 859 |
859 $('loading-spinner').hidden = false; | 860 $('loading-spinner').hidden = false; |
860 this.inFlight_ = true; | 861 this.inFlight_ = true; |
| 862 this.context = $('context-chooser').selectedIndex; |
861 chrome.send('queryHistory', | 863 chrome.send('queryHistory', |
862 [this.searchText_, this.offset_, this.rangeInDays_, endTime, maxResults]); | 864 [this.searchText_, this.offset_, this.rangeInDays_, endTime, this.context,
maxResults]); |
863 }; | 865 }; |
864 | 866 |
865 /** | 867 /** |
866 * Check to see if we have data for the given page. | 868 * Check to see if we have data for the given page. |
867 * @param {number} page The page number. | 869 * @param {number} page The page number. |
868 * @return {boolean} Whether we have any data for the given page. | 870 * @return {boolean} Whether we have any data for the given page. |
869 * @private | 871 * @private |
870 */ | 872 */ |
871 HistoryModel.prototype.haveDataForPage_ = function(page) { | 873 HistoryModel.prototype.haveDataForPage_ = function(page) { |
872 return page * RESULTS_PER_PAGE < this.getSize(); | 874 return page * RESULTS_PER_PAGE < this.getSize(); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1001 | 1003 |
1002 // If there is no search button, use the search button label as placeholder | 1004 // If there is no search button, use the search button label as placeholder |
1003 // text in the search field. | 1005 // text in the search field. |
1004 if ($('search-button').offsetWidth == 0) | 1006 if ($('search-button').offsetWidth == 0) |
1005 $('search-field').placeholder = $('search-button').value; | 1007 $('search-field').placeholder = $('search-button').value; |
1006 | 1008 |
1007 var self = this; | 1009 var self = this; |
1008 | 1010 |
1009 $('clear-browsing-data').addEventListener('click', openClearBrowsingData); | 1011 $('clear-browsing-data').addEventListener('click', openClearBrowsingData); |
1010 $('remove-selected').addEventListener('click', removeItems); | 1012 $('remove-selected').addEventListener('click', removeItems); |
| 1013 $('context-chooser').addEventListener('change', onChange); |
1011 | 1014 |
1012 // Add handlers for the page navigation buttons at the bottom. | 1015 // Add handlers for the page navigation buttons at the bottom. |
1013 $('newest-button').addEventListener('click', function() { | 1016 $('newest-button').addEventListener('click', function() { |
1014 recordUmaAction('HistoryPage_NewestHistoryClick'); | 1017 recordUmaAction('HistoryPage_NewestHistoryClick'); |
1015 self.setPage(0); | 1018 self.setPage(0); |
1016 }); | 1019 }); |
1017 $('newer-button').addEventListener('click', function() { | 1020 $('newer-button').addEventListener('click', function() { |
1018 recordUmaAction('HistoryPage_NewerHistoryClick'); | 1021 recordUmaAction('HistoryPage_NewerHistoryClick'); |
1019 self.setPage(self.pageIndex_ - 1); | 1022 self.setPage(self.pageIndex_ - 1); |
1020 }); | 1023 }); |
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2140 alertOverlay.setValues( | 2143 alertOverlay.setValues( |
2141 loadTimeData.getString('removeSelected'), | 2144 loadTimeData.getString('removeSelected'), |
2142 loadTimeData.getString('deleteWarning'), | 2145 loadTimeData.getString('deleteWarning'), |
2143 loadTimeData.getString('deleteConfirm'), | 2146 loadTimeData.getString('deleteConfirm'), |
2144 loadTimeData.getString('cancel'), | 2147 loadTimeData.getString('cancel'), |
2145 okCallback, | 2148 okCallback, |
2146 cancelCallback); | 2149 cancelCallback); |
2147 showConfirmationOverlay(); | 2150 showConfirmationOverlay(); |
2148 } | 2151 } |
2149 | 2152 |
| 2153 function onChange() { |
| 2154 historyModel.reload(); |
| 2155 } |
| 2156 |
2150 /** | 2157 /** |
2151 * Click handler for the 'Remove selected items' button. | 2158 * Click handler for the 'Remove selected items' button. |
2152 * Confirms the deletion with the user, and then deletes the selected visits. | 2159 * Confirms the deletion with the user, and then deletes the selected visits. |
2153 */ | 2160 */ |
2154 function removeItems() { | 2161 function removeItems() { |
2155 recordUmaAction('HistoryPage_RemoveSelected'); | 2162 recordUmaAction('HistoryPage_RemoveSelected'); |
2156 if (!loadTimeData.getBoolean('allowDeletingHistory')) | 2163 if (!loadTimeData.getBoolean('allowDeletingHistory')) |
2157 return; | 2164 return; |
2158 | 2165 |
2159 var checked = $('results-display').querySelectorAll( | 2166 var checked = $('results-display').querySelectorAll( |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2409 historyView.reload(); | 2416 historyView.reload(); |
2410 } | 2417 } |
2411 | 2418 |
2412 // Add handlers to HTML elements. | 2419 // Add handlers to HTML elements. |
2413 document.addEventListener('DOMContentLoaded', load); | 2420 document.addEventListener('DOMContentLoaded', load); |
2414 | 2421 |
2415 // This event lets us enable and disable menu items before the menu is shown. | 2422 // This event lets us enable and disable menu items before the menu is shown. |
2416 document.addEventListener('canExecute', function(e) { | 2423 document.addEventListener('canExecute', function(e) { |
2417 e.canExecute = true; | 2424 e.canExecute = true; |
2418 }); | 2425 }); |
OLD | NEW |