| 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 15 matching lines...) Expand all Loading... |
| 26 var historyView; | 26 var historyView; |
| 27 var pageState; | 27 var pageState; |
| 28 var selectionAnchor = -1; | 28 var selectionAnchor = -1; |
| 29 var activeVisit = null; | 29 var activeVisit = null; |
| 30 | 30 |
| 31 /** @const */ var Command = cr.ui.Command; | 31 /** @const */ var Command = cr.ui.Command; |
| 32 /** @const */ var Menu = cr.ui.Menu; | 32 /** @const */ var Menu = cr.ui.Menu; |
| 33 /** @const */ var MenuButton = cr.ui.MenuButton; | 33 /** @const */ var MenuButton = cr.ui.MenuButton; |
| 34 | 34 |
| 35 /** | 35 /** |
| 36 * Enum that shows the filtering behavior for a host or URL to a managed user. | 36 * Enum that shows the filtering behavior for a host or URL to a supervised |
| 37 * Must behave like the FilteringBehavior enum from managed_mode_url_filter.h. | 37 * user. Must behave like the FilteringBehavior enum from |
| 38 * supervised_user_url_filter.h. |
| 38 * @enum {number} | 39 * @enum {number} |
| 39 */ | 40 */ |
| 40 ManagedModeFilteringBehavior = { | 41 SupervisedUserFilteringBehavior = { |
| 41 ALLOW: 0, | 42 ALLOW: 0, |
| 42 WARN: 1, | 43 WARN: 1, |
| 43 BLOCK: 2 | 44 BLOCK: 2 |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 MenuButton.createDropDownArrows(); | 47 MenuButton.createDropDownArrows(); |
| 47 | 48 |
| 48 /** | 49 /** |
| 49 * Returns true if the mobile (non-desktop) version is being shown. | 50 * Returns true if the mobile (non-desktop) version is being shown. |
| 50 * @return {boolean} true if the mobile version is being shown. | 51 * @return {boolean} true if the mobile version is being shown. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // two items easily. | 109 // two items easily. |
| 109 | 110 |
| 110 this.date = new Date(result.time); | 111 this.date = new Date(result.time); |
| 111 | 112 |
| 112 // See comment in BrowsingHistoryHandler::QueryComplete - we won't always | 113 // See comment in BrowsingHistoryHandler::QueryComplete - we won't always |
| 113 // get all of these. | 114 // get all of these. |
| 114 this.dateRelativeDay = result.dateRelativeDay || ''; | 115 this.dateRelativeDay = result.dateRelativeDay || ''; |
| 115 this.dateTimeOfDay = result.dateTimeOfDay || ''; | 116 this.dateTimeOfDay = result.dateTimeOfDay || ''; |
| 116 this.dateShort = result.dateShort || ''; | 117 this.dateShort = result.dateShort || ''; |
| 117 | 118 |
| 118 // Shows the filtering behavior for that host (only used for managed users). | 119 // Shows the filtering behavior for that host (only used for supervised |
| 119 // A value of |ManagedModeFilteringBehavior.ALLOW| is not displayed so it is | 120 // users). |
| 120 // used as the default value. | 121 // A value of |SupervisedUserFilteringBehavior.ALLOW| is not displayed so it |
| 121 this.hostFilteringBehavior = ManagedModeFilteringBehavior.ALLOW; | 122 // is used as the default value. |
| 123 this.hostFilteringBehavior = SupervisedUserFilteringBehavior.ALLOW; |
| 122 if (typeof result.hostFilteringBehavior != 'undefined') | 124 if (typeof result.hostFilteringBehavior != 'undefined') |
| 123 this.hostFilteringBehavior = result.hostFilteringBehavior; | 125 this.hostFilteringBehavior = result.hostFilteringBehavior; |
| 124 | 126 |
| 125 this.blockedVisit = result.blockedVisit || false; | 127 this.blockedVisit = result.blockedVisit || false; |
| 126 | 128 |
| 127 // Whether this is the continuation of a previous day. | 129 // Whether this is the continuation of a previous day. |
| 128 this.continued = continued; | 130 this.continued = continued; |
| 129 | 131 |
| 130 this.allTimestamps = result.allTimestamps; | 132 this.allTimestamps = result.allTimestamps; |
| 131 } | 133 } |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 752 |
| 751 // HistoryModel, Private: ----------------------------------------------------- | 753 // HistoryModel, Private: ----------------------------------------------------- |
| 752 | 754 |
| 753 /** | 755 /** |
| 754 * Clear the history model. | 756 * Clear the history model. |
| 755 * @private | 757 * @private |
| 756 */ | 758 */ |
| 757 HistoryModel.prototype.clearModel_ = function() { | 759 HistoryModel.prototype.clearModel_ = function() { |
| 758 this.inFlight_ = false; // Whether a query is inflight. | 760 this.inFlight_ = false; // Whether a query is inflight. |
| 759 this.searchText_ = ''; | 761 this.searchText_ = ''; |
| 760 // Whether this user is a managed user. | 762 // Whether this user is a supervised user. |
| 761 this.isManagedProfile = loadTimeData.getBoolean('isManagedProfile'); | 763 this.isSupervisedProfile = loadTimeData.getBoolean('isSupervisedProfile'); |
| 762 this.deletingHistoryAllowed = loadTimeData.getBoolean('allowDeletingHistory'); | 764 this.deletingHistoryAllowed = loadTimeData.getBoolean('allowDeletingHistory'); |
| 763 | 765 |
| 764 // Only create checkboxes for editing entries if they can be used either to | 766 // Only create checkboxes for editing entries if they can be used either to |
| 765 // delete an entry or to block/allow it. | 767 // delete an entry or to block/allow it. |
| 766 this.editingEntriesAllowed = this.deletingHistoryAllowed; | 768 this.editingEntriesAllowed = this.deletingHistoryAllowed; |
| 767 | 769 |
| 768 // Flag to show that the results are grouped by domain or not. | 770 // Flag to show that the results are grouped by domain or not. |
| 769 this.groupByDomain_ = false; | 771 this.groupByDomain_ = false; |
| 770 | 772 |
| 771 this.visits_ = []; // Date-sorted list of visits (most recent first). | 773 this.visits_ = []; // Date-sorted list of visits (most recent first). |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 var domainElement = document.createElement('span'); | 1287 var domainElement = document.createElement('span'); |
| 1286 | 1288 |
| 1287 numberOfVisits.textContent = loadTimeData.getStringF('numberVisits', | 1289 numberOfVisits.textContent = loadTimeData.getStringF('numberVisits', |
| 1288 domainVisits.length); | 1290 domainVisits.length); |
| 1289 siteDomain.appendChild(numberOfVisits); | 1291 siteDomain.appendChild(numberOfVisits); |
| 1290 | 1292 |
| 1291 domainVisits[0].addFaviconToElement_(siteDomain); | 1293 domainVisits[0].addFaviconToElement_(siteDomain); |
| 1292 | 1294 |
| 1293 siteDomainWrapper.addEventListener('click', toggleHandler); | 1295 siteDomainWrapper.addEventListener('click', toggleHandler); |
| 1294 | 1296 |
| 1295 if (this.model_.isManagedProfile) { | 1297 if (this.model_.isSupervisedProfile) { |
| 1296 siteDomainWrapper.appendChild( | 1298 siteDomainWrapper.appendChild( |
| 1297 getManagedStatusDOM(domainVisits[0].hostFilteringBehavior)); | 1299 getFilteringStatusDOM(domainVisits[0].hostFilteringBehavior)); |
| 1298 } | 1300 } |
| 1299 | 1301 |
| 1300 siteResults.appendChild(siteDomainWrapper); | 1302 siteResults.appendChild(siteDomainWrapper); |
| 1301 var resultsList = siteResults.appendChild( | 1303 var resultsList = siteResults.appendChild( |
| 1302 createElementWithClassName('ol', 'site-results')); | 1304 createElementWithClassName('ol', 'site-results')); |
| 1303 resultsList.classList.add('grouped'); | 1305 resultsList.classList.add('grouped'); |
| 1304 | 1306 |
| 1305 // Collapse until it gets toggled. | 1307 // Collapse until it gets toggled. |
| 1306 resultsList.style.height = 0; | 1308 resultsList.style.height = 0; |
| 1307 | 1309 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1556 this.setTimeColumnWidth_(this.resultDiv_); | 1558 this.setTimeColumnWidth_(this.resultDiv_); |
| 1557 }; | 1559 }; |
| 1558 | 1560 |
| 1559 /** | 1561 /** |
| 1560 * Update the visibility of the page navigation buttons. | 1562 * Update the visibility of the page navigation buttons. |
| 1561 * @private | 1563 * @private |
| 1562 */ | 1564 */ |
| 1563 HistoryView.prototype.updateNavBar_ = function() { | 1565 HistoryView.prototype.updateNavBar_ = function() { |
| 1564 this.updateRangeButtons_(); | 1566 this.updateRangeButtons_(); |
| 1565 | 1567 |
| 1566 // Managed users have the control bar on top, don't show it on the bottom | 1568 // Supervised users have the control bar on top, don't show it on the bottom |
| 1567 // as well. | 1569 // as well. |
| 1568 if (!loadTimeData.getBoolean('isManagedProfile')) { | 1570 if (!loadTimeData.getBoolean('isSupervisedProfile')) { |
| 1569 $('newest-button').hidden = this.pageIndex_ == 0; | 1571 $('newest-button').hidden = this.pageIndex_ == 0; |
| 1570 $('newer-button').hidden = this.pageIndex_ == 0; | 1572 $('newer-button').hidden = this.pageIndex_ == 0; |
| 1571 $('older-button').hidden = | 1573 $('older-button').hidden = |
| 1572 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || | 1574 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || |
| 1573 !this.model_.hasMoreResults(); | 1575 !this.model_.hasMoreResults(); |
| 1574 } | 1576 } |
| 1575 }; | 1577 }; |
| 1576 | 1578 |
| 1577 /** | 1579 /** |
| 1578 * Updates the visibility of the 'Clear browsing data' button. | 1580 * Updates the visibility of the 'Clear browsing data' button. |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1912 searchField.addEventListener('search', doSearch); | 1914 searchField.addEventListener('search', doSearch); |
| 1913 $('search-button').addEventListener('click', doSearch); | 1915 $('search-button').addEventListener('click', doSearch); |
| 1914 | 1916 |
| 1915 $('more-from-site').addEventListener('activate', function(e) { | 1917 $('more-from-site').addEventListener('activate', function(e) { |
| 1916 activeVisit.showMoreFromSite_(); | 1918 activeVisit.showMoreFromSite_(); |
| 1917 activeVisit = null; | 1919 activeVisit = null; |
| 1918 }); | 1920 }); |
| 1919 | 1921 |
| 1920 // Only show the controls if the command line switch is activated. | 1922 // Only show the controls if the command line switch is activated. |
| 1921 if (loadTimeData.getBoolean('groupByDomain') || | 1923 if (loadTimeData.getBoolean('groupByDomain') || |
| 1922 loadTimeData.getBoolean('isManagedProfile')) { | 1924 loadTimeData.getBoolean('isSupervisedProfile')) { |
| 1923 // Hide the top container which has the "Clear browsing data" and "Remove | 1925 // Hide the top container which has the "Clear browsing data" and "Remove |
| 1924 // selected entries" buttons since they're unavailable in managed mode | 1926 // selected entries" buttons since they're unavailable for supervised users. |
| 1925 $('top-container').hidden = true; | 1927 $('top-container').hidden = true; |
| 1926 $('history-page').classList.add('big-topbar-page'); | 1928 $('history-page').classList.add('big-topbar-page'); |
| 1927 $('filter-controls').hidden = false; | 1929 $('filter-controls').hidden = false; |
| 1928 } | 1930 } |
| 1929 | 1931 |
| 1930 uber.setTitle(loadTimeData.getString('title')); | 1932 uber.setTitle(loadTimeData.getString('title')); |
| 1931 | 1933 |
| 1932 // Adjust the position of the notification bar when the window size changes. | 1934 // Adjust the position of the notification bar when the window size changes. |
| 1933 window.addEventListener('resize', | 1935 window.addEventListener('resize', |
| 1934 historyView.positionNotificationBar.bind(historyView)); | 1936 historyView.positionNotificationBar.bind(historyView)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 var isKeyboardVisible = (window.innerHeight / screenHeight) < 0.7; | 1973 var isKeyboardVisible = (window.innerHeight / screenHeight) < 0.7; |
| 1972 | 1974 |
| 1973 document.body.classList.toggle('ios-keyboard-visible', isKeyboardVisible); | 1975 document.body.classList.toggle('ios-keyboard-visible', isKeyboardVisible); |
| 1974 } | 1976 } |
| 1975 window.addEventListener('orientationchange', checkKeyboardVisibility); | 1977 window.addEventListener('orientationchange', checkKeyboardVisibility); |
| 1976 window.addEventListener('resize', checkKeyboardVisibility); | 1978 window.addEventListener('resize', checkKeyboardVisibility); |
| 1977 </if> /* is_ios */ | 1979 </if> /* is_ios */ |
| 1978 } | 1980 } |
| 1979 | 1981 |
| 1980 /** | 1982 /** |
| 1981 * Updates the managed filter status labels of a host/URL entry to the current | 1983 * Updates the filter status labels of a host/URL entry to the current value. |
| 1982 * value. | |
| 1983 * @param {Element} statusElement The div which contains the status labels. | 1984 * @param {Element} statusElement The div which contains the status labels. |
| 1984 * @param {ManagedModeFilteringBehavior} newStatus The filter status of the | 1985 * @param {SupervisedUserFilteringBehavior} newStatus The filter status of the |
| 1985 * current domain/URL. | 1986 * current domain/URL. |
| 1986 */ | 1987 */ |
| 1987 function updateHostStatus(statusElement, newStatus) { | 1988 function updateHostStatus(statusElement, newStatus) { |
| 1988 var filteringBehaviorDiv = | 1989 var filteringBehaviorDiv = |
| 1989 statusElement.querySelector('.filtering-behavior'); | 1990 statusElement.querySelector('.filtering-behavior'); |
| 1990 // Reset to the base class first, then add modifier classes if needed. | 1991 // Reset to the base class first, then add modifier classes if needed. |
| 1991 filteringBehaviorDiv.className = 'filtering-behavior'; | 1992 filteringBehaviorDiv.className = 'filtering-behavior'; |
| 1992 if (newStatus == ManagedModeFilteringBehavior.BLOCK) { | 1993 if (newStatus == SupervisedUserFilteringBehavior.BLOCK) { |
| 1993 filteringBehaviorDiv.textContent = | 1994 filteringBehaviorDiv.textContent = |
| 1994 loadTimeData.getString('filterBlocked'); | 1995 loadTimeData.getString('filterBlocked'); |
| 1995 filteringBehaviorDiv.classList.add('filter-blocked'); | 1996 filteringBehaviorDiv.classList.add('filter-blocked'); |
| 1996 } else { | 1997 } else { |
| 1997 filteringBehaviorDiv.textContent = ''; | 1998 filteringBehaviorDiv.textContent = ''; |
| 1998 } | 1999 } |
| 1999 } | 2000 } |
| 2000 | 2001 |
| 2001 /** | 2002 /** |
| 2002 * Click handler for the 'Clear browsing data' dialog. | 2003 * Click handler for the 'Clear browsing data' dialog. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2268 innerArrow.classList.remove('collapse'); | 2269 innerArrow.classList.remove('collapse'); |
| 2269 innerArrow.classList.add('expand'); | 2270 innerArrow.classList.add('expand'); |
| 2270 } else { | 2271 } else { |
| 2271 innerResultList.style.height = 0; | 2272 innerResultList.style.height = 0; |
| 2272 innerArrow.classList.remove('expand'); | 2273 innerArrow.classList.remove('expand'); |
| 2273 innerArrow.classList.add('collapse'); | 2274 innerArrow.classList.add('collapse'); |
| 2274 } | 2275 } |
| 2275 } | 2276 } |
| 2276 | 2277 |
| 2277 /** | 2278 /** |
| 2278 * Builds the DOM elements to show the managed status of a domain/URL. | 2279 * Builds the DOM elements to show the filtering status of a domain/URL. |
| 2279 * @param {ManagedModeFilteringBehavior} filteringBehavior The filter behavior | 2280 * @param {SupervisedUserFilteringBehavior} filteringBehavior The filter |
| 2280 * for this item. | 2281 * behavior for this item. |
| 2281 * @return {Element} Returns the DOM elements which show the status. | 2282 * @return {Element} Returns the DOM elements which show the status. |
| 2282 */ | 2283 */ |
| 2283 function getManagedStatusDOM(filteringBehavior) { | 2284 function getFilteringStatusDOM(filteringBehavior) { |
| 2284 var filterStatusDiv = createElementWithClassName('div', 'filter-status'); | 2285 var filterStatusDiv = createElementWithClassName('div', 'filter-status'); |
| 2285 var filteringBehaviorDiv = | 2286 var filteringBehaviorDiv = |
| 2286 createElementWithClassName('div', 'filtering-behavior'); | 2287 createElementWithClassName('div', 'filtering-behavior'); |
| 2287 filterStatusDiv.appendChild(filteringBehaviorDiv); | 2288 filterStatusDiv.appendChild(filteringBehaviorDiv); |
| 2288 | 2289 |
| 2289 updateHostStatus(filterStatusDiv, filteringBehavior); | 2290 updateHostStatus(filterStatusDiv, filteringBehavior); |
| 2290 return filterStatusDiv; | 2291 return filterStatusDiv; |
| 2291 } | 2292 } |
| 2292 | 2293 |
| 2293 | 2294 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2328 historyView.reload(); | 2329 historyView.reload(); |
| 2329 } | 2330 } |
| 2330 | 2331 |
| 2331 // Add handlers to HTML elements. | 2332 // Add handlers to HTML elements. |
| 2332 document.addEventListener('DOMContentLoaded', load); | 2333 document.addEventListener('DOMContentLoaded', load); |
| 2333 | 2334 |
| 2334 // This event lets us enable and disable menu items before the menu is shown. | 2335 // This event lets us enable and disable menu items before the menu is shown. |
| 2335 document.addEventListener('canExecute', function(e) { | 2336 document.addEventListener('canExecute', function(e) { |
| 2336 e.canExecute = true; | 2337 e.canExecute = true; |
| 2337 }); | 2338 }); |
| OLD | NEW |