| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 var SupervisedUserFilteringBehavior = { | 43 var SupervisedUserFilteringBehavior = { |
| 44 ALLOW: 0, | 44 ALLOW: 0, |
| 45 WARN: 1, | 45 WARN: 1, |
| 46 BLOCK: 2 | 46 BLOCK: 2 |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The type of the history result object. The definition is based on | 50 * The type of the history result object. The definition is based on |
| 51 * chrome/browser/ui/webui/history_ui.cc: | 51 * chrome/browser/ui/webui/history_ui.cc: |
| 52 * BrowsingHistoryHandler::HistoryEntry::ToValue() | 52 * BrowsingHistoryHandler::HistoryEntry::ToValue() |
| 53 * @typedef {{allTimestamps: Array.<number>, | 53 * @typedef {{allTimestamps: Array<number>, |
| 54 * blockedVisit: (boolean|undefined), | 54 * blockedVisit: (boolean|undefined), |
| 55 * dateRelativeDay: (string|undefined), | 55 * dateRelativeDay: (string|undefined), |
| 56 * dateShort: string, | 56 * dateShort: string, |
| 57 * dateTimeOfDay: (string|undefined), | 57 * dateTimeOfDay: (string|undefined), |
| 58 * deviceName: string, | 58 * deviceName: string, |
| 59 * deviceType: string, | 59 * deviceType: string, |
| 60 * domain: string, | 60 * domain: string, |
| 61 * hostFilteringBehavior: (number|undefined), | 61 * hostFilteringBehavior: (number|undefined), |
| 62 * snippet: (string|undefined), | 62 * snippet: (string|undefined), |
| 63 * starred: boolean, | 63 * starred: boolean, |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 * @param {number} page The page we want to view. | 624 * @param {number} page The page we want to view. |
| 625 */ | 625 */ |
| 626 HistoryModel.prototype.requestPage = function(page) { | 626 HistoryModel.prototype.requestPage = function(page) { |
| 627 this.requestedPage_ = page; | 627 this.requestedPage_ = page; |
| 628 this.updateSearch_(); | 628 this.updateSearch_(); |
| 629 }; | 629 }; |
| 630 | 630 |
| 631 /** | 631 /** |
| 632 * Receiver for history query. | 632 * Receiver for history query. |
| 633 * @param {HistoryQuery} info An object containing information about the query. | 633 * @param {HistoryQuery} info An object containing information about the query. |
| 634 * @param {Array.<HistoryEntry>} results A list of results. | 634 * @param {Array<HistoryEntry>} results A list of results. |
| 635 */ | 635 */ |
| 636 HistoryModel.prototype.addResults = function(info, results) { | 636 HistoryModel.prototype.addResults = function(info, results) { |
| 637 // If no requests are in flight then this was an old request so we drop the | 637 // If no requests are in flight then this was an old request so we drop the |
| 638 // results. Double check the search term as well. | 638 // results. Double check the search term as well. |
| 639 if (!this.inFlight_ || info.term != this.searchText_) | 639 if (!this.inFlight_ || info.term != this.searchText_) |
| 640 return; | 640 return; |
| 641 | 641 |
| 642 $('loading-spinner').hidden = true; | 642 $('loading-spinner').hidden = true; |
| 643 this.inFlight_ = false; | 643 this.inFlight_ = false; |
| 644 this.isQueryFinished_ = info.finished; | 644 this.isQueryFinished_ = info.finished; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 668 * @return {number} The number of visits in the model. | 668 * @return {number} The number of visits in the model. |
| 669 */ | 669 */ |
| 670 HistoryModel.prototype.getSize = function() { | 670 HistoryModel.prototype.getSize = function() { |
| 671 return this.visits_.length; | 671 return this.visits_.length; |
| 672 }; | 672 }; |
| 673 | 673 |
| 674 /** | 674 /** |
| 675 * Get a list of visits between specified index positions. | 675 * Get a list of visits between specified index positions. |
| 676 * @param {number} start The start index. | 676 * @param {number} start The start index. |
| 677 * @param {number} end The end index. | 677 * @param {number} end The end index. |
| 678 * @return {Array.<Visit>} A list of visits. | 678 * @return {Array<Visit>} A list of visits. |
| 679 */ | 679 */ |
| 680 HistoryModel.prototype.getNumberedRange = function(start, end) { | 680 HistoryModel.prototype.getNumberedRange = function(start, end) { |
| 681 return this.visits_.slice(start, end); | 681 return this.visits_.slice(start, end); |
| 682 }; | 682 }; |
| 683 | 683 |
| 684 /** | 684 /** |
| 685 * Return true if there are more results beyond the current page. | 685 * Return true if there are more results beyond the current page. |
| 686 * @return {boolean} true if the there are more results, otherwise false. | 686 * @return {boolean} true if the there are more results, otherwise false. |
| 687 */ | 687 */ |
| 688 HistoryModel.prototype.hasMoreResults = function() { | 688 HistoryModel.prototype.hasMoreResults = function() { |
| 689 return this.haveDataForPage_(this.requestedPage_ + 1) || | 689 return this.haveDataForPage_(this.requestedPage_ + 1) || |
| 690 !this.isQueryFinished_; | 690 !this.isQueryFinished_; |
| 691 }; | 691 }; |
| 692 | 692 |
| 693 /** | 693 /** |
| 694 * Removes a list of visits from the history, and calls |callback| when the | 694 * Removes a list of visits from the history, and calls |callback| when the |
| 695 * removal has successfully completed. | 695 * removal has successfully completed. |
| 696 * @param {Array.<Visit>} visits The visits to remove. | 696 * @param {Array<Visit>} visits The visits to remove. |
| 697 * @param {Function} callback The function to call after removal succeeds. | 697 * @param {Function} callback The function to call after removal succeeds. |
| 698 */ | 698 */ |
| 699 HistoryModel.prototype.removeVisitsFromHistory = function(visits, callback) { | 699 HistoryModel.prototype.removeVisitsFromHistory = function(visits, callback) { |
| 700 assert(this.deletingHistoryAllowed); | 700 assert(this.deletingHistoryAllowed); |
| 701 | 701 |
| 702 var toBeRemoved = []; | 702 var toBeRemoved = []; |
| 703 for (var i = 0; i < visits.length; i++) { | 703 for (var i = 0; i < visits.length; i++) { |
| 704 toBeRemoved.push({ | 704 toBeRemoved.push({ |
| 705 url: visits[i].url_, | 705 url: visits[i].url_, |
| 706 timestamps: visits[i].allTimestamps | 706 timestamps: visits[i].allTimestamps |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 recordUmaAction('HistoryPage_NewerHistoryClick'); | 1015 recordUmaAction('HistoryPage_NewerHistoryClick'); |
| 1016 self.setPage(self.pageIndex_ - 1); | 1016 self.setPage(self.pageIndex_ - 1); |
| 1017 }); | 1017 }); |
| 1018 $('older-button').addEventListener('click', function() { | 1018 $('older-button').addEventListener('click', function() { |
| 1019 recordUmaAction('HistoryPage_OlderHistoryClick'); | 1019 recordUmaAction('HistoryPage_OlderHistoryClick'); |
| 1020 self.setPage(self.pageIndex_ + 1); | 1020 self.setPage(self.pageIndex_ + 1); |
| 1021 }); | 1021 }); |
| 1022 | 1022 |
| 1023 $('timeframe-controls').onchange = function(e) { | 1023 $('timeframe-controls').onchange = function(e) { |
| 1024 var value = parseInt(e.target.value, 10); | 1024 var value = parseInt(e.target.value, 10); |
| 1025 self.setRangeInDays(/** @type {HistoryModel.Range.<number>} */(value)); | 1025 self.setRangeInDays(/** @type {HistoryModel.Range<number>} */(value)); |
| 1026 }; | 1026 }; |
| 1027 | 1027 |
| 1028 $('range-previous').addEventListener('click', function(e) { | 1028 $('range-previous').addEventListener('click', function(e) { |
| 1029 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) | 1029 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) |
| 1030 self.setPage(self.pageIndex_ + 1); | 1030 self.setPage(self.pageIndex_ + 1); |
| 1031 else | 1031 else |
| 1032 self.setOffset(self.getOffset() + 1); | 1032 self.setOffset(self.getOffset() + 1); |
| 1033 }); | 1033 }); |
| 1034 $('range-next').addEventListener('click', function(e) { | 1034 $('range-next').addEventListener('click', function(e) { |
| 1035 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) | 1035 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1996 // visibility, otherwise the button will flash on the screen before the | 1996 // visibility, otherwise the button will flash on the screen before the |
| 1997 // keyboard animates away. | 1997 // keyboard animates away. |
| 1998 searchField.addEventListener('blur', function() { | 1998 searchField.addEventListener('blur', function() { |
| 1999 setTimeout(historyView.updateClearBrowsingDataButton_, 250); | 1999 setTimeout(historyView.updateClearBrowsingDataButton_, 250); |
| 2000 }); | 2000 }); |
| 2001 | 2001 |
| 2002 // Move the button to the bottom of the page. | 2002 // Move the button to the bottom of the page. |
| 2003 $('history-page').appendChild($('clear-browsing-data')); | 2003 $('history-page').appendChild($('clear-browsing-data')); |
| 2004 } else { | 2004 } else { |
| 2005 window.addEventListener('message', function(e) { | 2005 window.addEventListener('message', function(e) { |
| 2006 e = /** @type {!MessageEvent.<!{method: string}>} */(e); | 2006 e = /** @type {!MessageEvent<!{method: string}>} */(e); |
| 2007 if (e.data.method == 'frameSelected') | 2007 if (e.data.method == 'frameSelected') |
| 2008 searchField.focus(); | 2008 searchField.focus(); |
| 2009 }); | 2009 }); |
| 2010 searchField.focus(); | 2010 searchField.focus(); |
| 2011 } | 2011 } |
| 2012 | 2012 |
| 2013 <if expr="is_ios"> | 2013 <if expr="is_ios"> |
| 2014 function checkKeyboardVisibility() { | 2014 function checkKeyboardVisibility() { |
| 2015 // Figure out the real height based on the orientation, becauase | 2015 // Figure out the real height based on the orientation, becauase |
| 2016 // screen.width and screen.height don't update after rotation. | 2016 // screen.width and screen.height don't update after rotation. |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 return filterStatusDiv; | 2357 return filterStatusDiv; |
| 2358 } | 2358 } |
| 2359 | 2359 |
| 2360 | 2360 |
| 2361 /////////////////////////////////////////////////////////////////////////////// | 2361 /////////////////////////////////////////////////////////////////////////////// |
| 2362 // Chrome callbacks: | 2362 // Chrome callbacks: |
| 2363 | 2363 |
| 2364 /** | 2364 /** |
| 2365 * Our history system calls this function with results from searches. | 2365 * Our history system calls this function with results from searches. |
| 2366 * @param {HistoryQuery} info An object containing information about the query. | 2366 * @param {HistoryQuery} info An object containing information about the query. |
| 2367 * @param {Array.<HistoryEntry>} results A list of results. | 2367 * @param {Array<HistoryEntry>} results A list of results. |
| 2368 */ | 2368 */ |
| 2369 function historyResult(info, results) { | 2369 function historyResult(info, results) { |
| 2370 historyModel.addResults(info, results); | 2370 historyModel.addResults(info, results); |
| 2371 } | 2371 } |
| 2372 | 2372 |
| 2373 /** | 2373 /** |
| 2374 * Called by the history backend when history removal is successful. | 2374 * Called by the history backend when history removal is successful. |
| 2375 */ | 2375 */ |
| 2376 function deleteComplete() { | 2376 function deleteComplete() { |
| 2377 historyModel.deleteComplete(); | 2377 historyModel.deleteComplete(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2395 historyView.reload(); | 2395 historyView.reload(); |
| 2396 } | 2396 } |
| 2397 | 2397 |
| 2398 // Add handlers to HTML elements. | 2398 // Add handlers to HTML elements. |
| 2399 document.addEventListener('DOMContentLoaded', load); | 2399 document.addEventListener('DOMContentLoaded', load); |
| 2400 | 2400 |
| 2401 // This event lets us enable and disable menu items before the menu is shown. | 2401 // This event lets us enable and disable menu items before the menu is shown. |
| 2402 document.addEventListener('canExecute', function(e) { | 2402 document.addEventListener('canExecute', function(e) { |
| 2403 e.canExecute = true; | 2403 e.canExecute = true; |
| 2404 }); | 2404 }); |
| OLD | NEW |