| 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 | 733 |
| 732 // HistoryModel, Private: ----------------------------------------------------- | 734 // HistoryModel, Private: ----------------------------------------------------- |
| 733 | 735 |
| 734 /** | 736 /** |
| 735 * Clear the history model. | 737 * Clear the history model. |
| 736 * @private | 738 * @private |
| 737 */ | 739 */ |
| 738 HistoryModel.prototype.clearModel_ = function() { | 740 HistoryModel.prototype.clearModel_ = function() { |
| 739 this.inFlight_ = false; // Whether a query is inflight. | 741 this.inFlight_ = false; // Whether a query is inflight. |
| 740 this.searchText_ = ''; | 742 this.searchText_ = ''; |
| 741 // Whether this user is a managed user. | 743 // Whether this user is a supervised user. |
| 742 this.isManagedProfile = loadTimeData.getBoolean('isManagedProfile'); | 744 this.isSupervisedProfile = loadTimeData.getBoolean('isSupervisedProfile'); |
| 743 this.deletingHistoryAllowed = loadTimeData.getBoolean('allowDeletingHistory'); | 745 this.deletingHistoryAllowed = loadTimeData.getBoolean('allowDeletingHistory'); |
| 744 | 746 |
| 745 // Only create checkboxes for editing entries if they can be used either to | 747 // Only create checkboxes for editing entries if they can be used either to |
| 746 // delete an entry or to block/allow it. | 748 // delete an entry or to block/allow it. |
| 747 this.editingEntriesAllowed = this.deletingHistoryAllowed; | 749 this.editingEntriesAllowed = this.deletingHistoryAllowed; |
| 748 | 750 |
| 749 // Flag to show that the results are grouped by domain or not. | 751 // Flag to show that the results are grouped by domain or not. |
| 750 this.groupByDomain_ = false; | 752 this.groupByDomain_ = false; |
| 751 | 753 |
| 752 this.visits_ = []; // Date-sorted list of visits (most recent first). | 754 this.visits_ = []; // Date-sorted list of visits (most recent first). |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 var domainElement = document.createElement('span'); | 1268 var domainElement = document.createElement('span'); |
| 1267 | 1269 |
| 1268 numberOfVisits.textContent = loadTimeData.getStringF('numberVisits', | 1270 numberOfVisits.textContent = loadTimeData.getStringF('numberVisits', |
| 1269 domainVisits.length); | 1271 domainVisits.length); |
| 1270 siteDomain.appendChild(numberOfVisits); | 1272 siteDomain.appendChild(numberOfVisits); |
| 1271 | 1273 |
| 1272 domainVisits[0].addFaviconToElement_(siteDomain); | 1274 domainVisits[0].addFaviconToElement_(siteDomain); |
| 1273 | 1275 |
| 1274 siteDomainWrapper.addEventListener('click', toggleHandler); | 1276 siteDomainWrapper.addEventListener('click', toggleHandler); |
| 1275 | 1277 |
| 1276 if (this.model_.isManagedProfile) { | 1278 if (this.model_.isSupervisedProfile) { |
| 1277 siteDomainWrapper.appendChild( | 1279 siteDomainWrapper.appendChild( |
| 1278 getManagedStatusDOM(domainVisits[0].hostFilteringBehavior)); | 1280 getFilteringStatusDOM(domainVisits[0].hostFilteringBehavior)); |
| 1279 } | 1281 } |
| 1280 | 1282 |
| 1281 siteResults.appendChild(siteDomainWrapper); | 1283 siteResults.appendChild(siteDomainWrapper); |
| 1282 var resultsList = siteResults.appendChild( | 1284 var resultsList = siteResults.appendChild( |
| 1283 createElementWithClassName('ol', 'site-results')); | 1285 createElementWithClassName('ol', 'site-results')); |
| 1284 resultsList.classList.add('grouped'); | 1286 resultsList.classList.add('grouped'); |
| 1285 | 1287 |
| 1286 // Collapse until it gets toggled. | 1288 // Collapse until it gets toggled. |
| 1287 resultsList.style.height = 0; | 1289 resultsList.style.height = 0; |
| 1288 | 1290 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1537 this.setTimeColumnWidth_(this.resultDiv_); | 1539 this.setTimeColumnWidth_(this.resultDiv_); |
| 1538 }; | 1540 }; |
| 1539 | 1541 |
| 1540 /** | 1542 /** |
| 1541 * Update the visibility of the page navigation buttons. | 1543 * Update the visibility of the page navigation buttons. |
| 1542 * @private | 1544 * @private |
| 1543 */ | 1545 */ |
| 1544 HistoryView.prototype.updateNavBar_ = function() { | 1546 HistoryView.prototype.updateNavBar_ = function() { |
| 1545 this.updateRangeButtons_(); | 1547 this.updateRangeButtons_(); |
| 1546 | 1548 |
| 1547 // Managed users have the control bar on top, don't show it on the bottom | 1549 // Supervised users have the control bar on top, don't show it on the bottom |
| 1548 // as well. | 1550 // as well. |
| 1549 if (!loadTimeData.getBoolean('isManagedProfile')) { | 1551 if (!loadTimeData.getBoolean('isSupervisedProfile')) { |
| 1550 $('newest-button').hidden = this.pageIndex_ == 0; | 1552 $('newest-button').hidden = this.pageIndex_ == 0; |
| 1551 $('newer-button').hidden = this.pageIndex_ == 0; | 1553 $('newer-button').hidden = this.pageIndex_ == 0; |
| 1552 $('older-button').hidden = | 1554 $('older-button').hidden = |
| 1553 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || | 1555 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || |
| 1554 !this.model_.hasMoreResults(); | 1556 !this.model_.hasMoreResults(); |
| 1555 } | 1557 } |
| 1556 }; | 1558 }; |
| 1557 | 1559 |
| 1558 /** | 1560 /** |
| 1559 * Updates the visibility of the 'Clear browsing data' button. | 1561 * Updates the visibility of the 'Clear browsing data' button. |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1874 searchField.addEventListener('search', doSearch); | 1876 searchField.addEventListener('search', doSearch); |
| 1875 $('search-button').addEventListener('click', doSearch); | 1877 $('search-button').addEventListener('click', doSearch); |
| 1876 | 1878 |
| 1877 $('more-from-site').addEventListener('activate', function(e) { | 1879 $('more-from-site').addEventListener('activate', function(e) { |
| 1878 activeVisit.showMoreFromSite_(); | 1880 activeVisit.showMoreFromSite_(); |
| 1879 activeVisit = null; | 1881 activeVisit = null; |
| 1880 }); | 1882 }); |
| 1881 | 1883 |
| 1882 // Only show the controls if the command line switch is activated. | 1884 // Only show the controls if the command line switch is activated. |
| 1883 if (loadTimeData.getBoolean('groupByDomain') || | 1885 if (loadTimeData.getBoolean('groupByDomain') || |
| 1884 loadTimeData.getBoolean('isManagedProfile')) { | 1886 loadTimeData.getBoolean('isSupervisedProfile')) { |
| 1885 // Hide the top container which has the "Clear browsing data" and "Remove | 1887 // Hide the top container which has the "Clear browsing data" and "Remove |
| 1886 // selected entries" buttons since they're unavailable in managed mode | 1888 // selected entries" buttons since they're unavailable for supervised users. |
| 1887 $('top-container').hidden = true; | 1889 $('top-container').hidden = true; |
| 1888 $('history-page').classList.add('big-topbar-page'); | 1890 $('history-page').classList.add('big-topbar-page'); |
| 1889 $('filter-controls').hidden = false; | 1891 $('filter-controls').hidden = false; |
| 1890 } | 1892 } |
| 1891 | 1893 |
| 1892 uber.setTitle(loadTimeData.getString('title')); | 1894 uber.setTitle(loadTimeData.getString('title')); |
| 1893 | 1895 |
| 1894 // Adjust the position of the notification bar when the window size changes. | 1896 // Adjust the position of the notification bar when the window size changes. |
| 1895 window.addEventListener('resize', | 1897 window.addEventListener('resize', |
| 1896 historyView.positionNotificationBar.bind(historyView)); | 1898 historyView.positionNotificationBar.bind(historyView)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1933 var isKeyboardVisible = (window.innerHeight / screenHeight) < 0.7; | 1935 var isKeyboardVisible = (window.innerHeight / screenHeight) < 0.7; |
| 1934 | 1936 |
| 1935 document.body.classList.toggle('ios-keyboard-visible', isKeyboardVisible); | 1937 document.body.classList.toggle('ios-keyboard-visible', isKeyboardVisible); |
| 1936 } | 1938 } |
| 1937 window.addEventListener('orientationchange', checkKeyboardVisibility); | 1939 window.addEventListener('orientationchange', checkKeyboardVisibility); |
| 1938 window.addEventListener('resize', checkKeyboardVisibility); | 1940 window.addEventListener('resize', checkKeyboardVisibility); |
| 1939 </if> /* is_ios */ | 1941 </if> /* is_ios */ |
| 1940 } | 1942 } |
| 1941 | 1943 |
| 1942 /** | 1944 /** |
| 1943 * Updates the managed filter status labels of a host/URL entry to the current | 1945 * Updates the filter status labels of a host/URL entry to the current value. |
| 1944 * value. | |
| 1945 * @param {Element} statusElement The div which contains the status labels. | 1946 * @param {Element} statusElement The div which contains the status labels. |
| 1946 * @param {ManagedModeFilteringBehavior} newStatus The filter status of the | 1947 * @param {SupervisedUserFilteringBehavior} newStatus The filter status of the |
| 1947 * current domain/URL. | 1948 * current domain/URL. |
| 1948 */ | 1949 */ |
| 1949 function updateHostStatus(statusElement, newStatus) { | 1950 function updateHostStatus(statusElement, newStatus) { |
| 1950 var filteringBehaviorDiv = | 1951 var filteringBehaviorDiv = |
| 1951 statusElement.querySelector('.filtering-behavior'); | 1952 statusElement.querySelector('.filtering-behavior'); |
| 1952 // Reset to the base class first, then add modifier classes if needed. | 1953 // Reset to the base class first, then add modifier classes if needed. |
| 1953 filteringBehaviorDiv.className = 'filtering-behavior'; | 1954 filteringBehaviorDiv.className = 'filtering-behavior'; |
| 1954 if (newStatus == ManagedModeFilteringBehavior.BLOCK) { | 1955 if (newStatus == SupervisedUserFilteringBehavior.BLOCK) { |
| 1955 filteringBehaviorDiv.textContent = | 1956 filteringBehaviorDiv.textContent = |
| 1956 loadTimeData.getString('filterBlocked'); | 1957 loadTimeData.getString('filterBlocked'); |
| 1957 filteringBehaviorDiv.classList.add('filter-blocked'); | 1958 filteringBehaviorDiv.classList.add('filter-blocked'); |
| 1958 } else { | 1959 } else { |
| 1959 filteringBehaviorDiv.textContent = ''; | 1960 filteringBehaviorDiv.textContent = ''; |
| 1960 } | 1961 } |
| 1961 } | 1962 } |
| 1962 | 1963 |
| 1963 /** | 1964 /** |
| 1964 * Click handler for the 'Clear browsing data' dialog. | 1965 * Click handler for the 'Clear browsing data' dialog. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2230 innerArrow.classList.remove('collapse'); | 2231 innerArrow.classList.remove('collapse'); |
| 2231 innerArrow.classList.add('expand'); | 2232 innerArrow.classList.add('expand'); |
| 2232 } else { | 2233 } else { |
| 2233 innerResultList.style.height = 0; | 2234 innerResultList.style.height = 0; |
| 2234 innerArrow.classList.remove('expand'); | 2235 innerArrow.classList.remove('expand'); |
| 2235 innerArrow.classList.add('collapse'); | 2236 innerArrow.classList.add('collapse'); |
| 2236 } | 2237 } |
| 2237 } | 2238 } |
| 2238 | 2239 |
| 2239 /** | 2240 /** |
| 2240 * Builds the DOM elements to show the managed status of a domain/URL. | 2241 * Builds the DOM elements to show the filtering status of a domain/URL. |
| 2241 * @param {ManagedModeFilteringBehavior} filteringBehavior The filter behavior | 2242 * @param {SupervisedUserFilteringBehavior} filteringBehavior The filter |
| 2242 * for this item. | 2243 * behavior for this item. |
| 2243 * @return {Element} Returns the DOM elements which show the status. | 2244 * @return {Element} Returns the DOM elements which show the status. |
| 2244 */ | 2245 */ |
| 2245 function getManagedStatusDOM(filteringBehavior) { | 2246 function getFilteringStatusDOM(filteringBehavior) { |
| 2246 var filterStatusDiv = createElementWithClassName('div', 'filter-status'); | 2247 var filterStatusDiv = createElementWithClassName('div', 'filter-status'); |
| 2247 var filteringBehaviorDiv = | 2248 var filteringBehaviorDiv = |
| 2248 createElementWithClassName('div', 'filtering-behavior'); | 2249 createElementWithClassName('div', 'filtering-behavior'); |
| 2249 filterStatusDiv.appendChild(filteringBehaviorDiv); | 2250 filterStatusDiv.appendChild(filteringBehaviorDiv); |
| 2250 | 2251 |
| 2251 updateHostStatus(filterStatusDiv, filteringBehavior); | 2252 updateHostStatus(filterStatusDiv, filteringBehavior); |
| 2252 return filterStatusDiv; | 2253 return filterStatusDiv; |
| 2253 } | 2254 } |
| 2254 | 2255 |
| 2255 | 2256 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2290 historyView.reload(); | 2291 historyView.reload(); |
| 2291 } | 2292 } |
| 2292 | 2293 |
| 2293 // Add handlers to HTML elements. | 2294 // Add handlers to HTML elements. |
| 2294 document.addEventListener('DOMContentLoaded', load); | 2295 document.addEventListener('DOMContentLoaded', load); |
| 2295 | 2296 |
| 2296 // This event lets us enable and disable menu items before the menu is shown. | 2297 // This event lets us enable and disable menu items before the menu is shown. |
| 2297 document.addEventListener('canExecute', function(e) { | 2298 document.addEventListener('canExecute', function(e) { |
| 2298 e.canExecute = true; | 2299 e.canExecute = true; |
| 2299 }); | 2300 }); |
| OLD | NEW |