Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(257)

Side by Side Diff: chrome/browser/resources/history/history.js

Issue 15969014: History: Update managed user history page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor fixes Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/history/history.html ('k') | chrome/browser/ui/webui/history_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 /////////////////////////////////////////////////////////////////////////////// 7 ///////////////////////////////////////////////////////////////////////////////
8 // Globals: 8 // Globals:
9 /** @const */ var RESULTS_PER_PAGE = 150; 9 /** @const */ var RESULTS_PER_PAGE = 150;
10 10
11 // Amount of time between pageviews that we consider a 'break' in browsing, 11 // Amount of time between pageviews that we consider a 'break' in browsing,
12 // measured in milliseconds. 12 // measured in milliseconds.
13 /** @const */ var BROWSING_GAP_TIME = 15 * 60 * 1000; 13 /** @const */ var BROWSING_GAP_TIME = 15 * 60 * 1000;
14 14
15 // TODO(glen): Get rid of these global references, replace with a controller 15 // TODO(glen): Get rid of these global references, replace with a controller
16 // or just make the classes own more of the page. 16 // or just make the classes own more of the page.
17 var historyModel; 17 var historyModel;
18 var historyView; 18 var historyView;
19 var pageState; 19 var pageState;
20 var selectionAnchor = -1; 20 var selectionAnchor = -1;
21 var activeVisit = null; 21 var activeVisit = null;
22 22
23 /** @const */ var Command = cr.ui.Command; 23 /** @const */ var Command = cr.ui.Command;
24 /** @const */ var Menu = cr.ui.Menu; 24 /** @const */ var Menu = cr.ui.Menu;
25 /** @const */ var MenuButton = cr.ui.MenuButton; 25 /** @const */ var MenuButton = cr.ui.MenuButton;
26 26
27 /** 27 /**
28 * Enum that shows whether a manual exception is set in managed mode for a 28 * Enum that shows the filtering behavior for a host or URL to a managed user.
29 * host or URL. 29 * Must behave like the FilteringBehavior enum from managed_mode_url_filter.h.
30 * Must behave like the ManualBehavior enum from managed_user_service.h.
31 * @enum {number} 30 * @enum {number}
32 */ 31 */
33 ManagedModeManualBehavior = { 32 ManagedModeFilteringBehavior = {
34 NONE: 0, 33 ALLOW: 0,
35 ALLOW: 1, 34 WARN: 1,
36 BLOCK: 2 35 BLOCK: 2
37 }; 36 };
38 37
39 MenuButton.createDropDownArrows(); 38 MenuButton.createDropDownArrows();
40 39
41 /** 40 /**
42 * Returns true if the mobile (non-desktop) version is being shown. 41 * Returns true if the mobile (non-desktop) version is being shown.
43 * @return {boolean} true if the mobile version is being shown. 42 * @return {boolean} true if the mobile version is being shown.
44 */ 43 */
45 function isMobileVersion() { 44 function isMobileVersion() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // two items easily. 78 // two items easily.
80 79
81 this.date = new Date(result.time); 80 this.date = new Date(result.time);
82 81
83 // See comment in BrowsingHistoryHandler::QueryComplete - we won't always 82 // See comment in BrowsingHistoryHandler::QueryComplete - we won't always
84 // get all of these. 83 // get all of these.
85 this.dateRelativeDay = result.dateRelativeDay || ''; 84 this.dateRelativeDay = result.dateRelativeDay || '';
86 this.dateTimeOfDay = result.dateTimeOfDay || ''; 85 this.dateTimeOfDay = result.dateTimeOfDay || '';
87 this.dateShort = result.dateShort || ''; 86 this.dateShort = result.dateShort || '';
88 87
89 // These values represent indicators shown to users in managed mode. 88 // Shows the filtering behavior for that host (used by a managed user).
90 // |*manualBehavior| shows whether the user has manually added an exception 89 this.hostFilteringBehavior = result.hostFilteringBehavior ||
91 // for that URL or host while |*inContentPack| shows whether that URL or host 90 ManagedModeFilteringBehavior.ALLOW;
92 // is in a content pack or not.
93 this.urlManualBehavior = result.urlManualBehavior ||
94 ManagedModeManualBehavior.NONE;
95 this.hostManualBehavior = result.hostManualBehavior ||
96 ManagedModeManualBehavior.NONE;
97 this.urlInContentPack = result.urlInContentPack || false;
98 this.hostInContentPack = result.hostInContentPack || false;
99 this.blockedVisit = result.blockedVisit || false; 91 this.blockedVisit = result.blockedVisit || false;
100 92
101 // Whether this is the continuation of a previous day. 93 // Whether this is the continuation of a previous day.
102 this.continued = continued; 94 this.continued = continued;
103 95
104 this.allTimestamps = result.allTimestamps; 96 this.allTimestamps = result.allTimestamps;
105 } 97 }
106 98
107 // Visit, public: ------------------------------------------------------------- 99 // Visit, public: -------------------------------------------------------------
108 100
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 entryBox.appendChild(time); 149 entryBox.appendChild(time);
158 var titleAndDomainWrapper = entryBox.appendChild( 150 var titleAndDomainWrapper = entryBox.appendChild(
159 createElementWithClassName('div', 'title-and-domain')); 151 createElementWithClassName('div', 'title-and-domain'));
160 if (this.blockedVisit) { 152 if (this.blockedVisit) {
161 titleAndDomainWrapper.classList.add('blocked-indicator'); 153 titleAndDomainWrapper.classList.add('blocked-indicator');
162 titleAndDomainWrapper.appendChild(this.getVisitAttemptDOM_()); 154 titleAndDomainWrapper.appendChild(this.getVisitAttemptDOM_());
163 } else { 155 } else {
164 titleAndDomainWrapper.appendChild(this.getTitleDOM_()); 156 titleAndDomainWrapper.appendChild(this.getTitleDOM_());
165 if (addTitleFavicon) 157 if (addTitleFavicon)
166 this.addFaviconToElement_(titleAndDomainWrapper); 158 this.addFaviconToElement_(titleAndDomainWrapper);
159 else
160 titleAndDomainWrapper.classList.remove('title-and-domain');
markusheintz_ 2013/06/05 14:49:09 A) Instead of removing it. Maybe you don't add it
Sergiu 2013/06/05 20:18:42 I agree, see what you think now of the new names a
161 titleAndDomainWrapper.appendChild(domain);
167 } 162 }
168 titleAndDomainWrapper.appendChild(domain);
169 163
170 if (isMobileVersion()) { 164 if (isMobileVersion()) {
171 var removeButton = createElementWithClassName('button', 'remove-entry'); 165 var removeButton = createElementWithClassName('button', 'remove-entry');
172 removeButton.classList.add('custom-appearance'); 166 removeButton.classList.add('custom-appearance');
173 removeButton.addEventListener('click', function(e) { 167 removeButton.addEventListener('click', function(e) {
174 self.removeFromHistory(); 168 self.removeFromHistory();
175 e.stopPropagation(); 169 e.stopPropagation();
176 e.preventDefault(); 170 e.preventDefault();
177 }); 171 });
178 entryBox.appendChild(removeButton); 172 entryBox.appendChild(removeButton);
(...skipping 22 matching lines...) Expand all
201 this.classList.add('contains-focus'); 195 this.classList.add('contains-focus');
202 }, true); 196 }, true);
203 entryBox.addEventListener('blur', function() { 197 entryBox.addEventListener('blur', function() {
204 this.classList.remove('contains-focus'); 198 this.classList.remove('contains-focus');
205 }, true); 199 }, true);
206 200
207 var entryBoxContainer = 201 var entryBoxContainer =
208 createElementWithClassName('div', 'entry-box-container'); 202 createElementWithClassName('div', 'entry-box-container');
209 node.appendChild(entryBoxContainer); 203 node.appendChild(entryBoxContainer);
210 entryBoxContainer.appendChild(entryBox); 204 entryBoxContainer.appendChild(entryBox);
211 if (!isSearchResult && this.model_.isManagedProfile &&
212 this.model_.getGroupByDomain()) {
213 entryBoxContainer.appendChild(
214 getManagedStatusDOM(this.urlManualBehavior, this.urlInContentPack));
215 }
216 205
217 if (isSearchResult) { 206 if (isSearchResult) {
218 time.appendChild(document.createTextNode(this.dateShort)); 207 time.appendChild(document.createTextNode(this.dateShort));
219 var snippet = createElementWithClassName('div', 'snippet'); 208 var snippet = createElementWithClassName('div', 'snippet');
220 this.addHighlightedText_(snippet, 209 this.addHighlightedText_(snippet,
221 this.snippet_, 210 this.snippet_,
222 this.model_.getSearchText()); 211 this.model_.getSearchText());
223 node.appendChild(snippet); 212 node.appendChild(snippet);
224 } else if (useMonthDate) { 213 } else if (useMonthDate) {
225 // Show the day instead of the time. 214 // Show the day instead of the time.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 }; 309 };
321 310
322 /** 311 /**
323 * Returns the DOM element containing the text for a blocked visit attempt. 312 * Returns the DOM element containing the text for a blocked visit attempt.
324 * @return {Element} DOM representation of the visit attempt. 313 * @return {Element} DOM representation of the visit attempt.
325 * @private 314 * @private
326 */ 315 */
327 Visit.prototype.getVisitAttemptDOM_ = function() { 316 Visit.prototype.getVisitAttemptDOM_ = function() {
328 var node = createElementWithClassName('div', 'title'); 317 var node = createElementWithClassName('div', 'title');
329 node.innerHTML = loadTimeData.getStringF('blockedVisitText', 318 node.innerHTML = loadTimeData.getStringF('blockedVisitText',
330 this.url_, this.id_); 319 this.url_,
320 this.id_,
321 this.getDomainFromURL_(this.url_));
331 return node; 322 return node;
332 }; 323 };
333 324
334 /** 325 /**
335 * Set the favicon for an element. 326 * Set the favicon for an element.
336 * @param {Element} el The DOM element to which to add the icon. 327 * @param {Element} el The DOM element to which to add the icon.
337 * @private 328 * @private
338 */ 329 */
339 Visit.prototype.addFaviconToElement_ = function(el) { 330 Visit.prototype.addFaviconToElement_ = function(el) {
340 var url = isMobileVersion() ? 331 var url = isMobileVersion() ?
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 */ 569 */
579 HistoryModel.prototype.clearModel_ = function() { 570 HistoryModel.prototype.clearModel_ = function() {
580 this.inFlight_ = false; // Whether a query is inflight. 571 this.inFlight_ = false; // Whether a query is inflight.
581 this.searchText_ = ''; 572 this.searchText_ = '';
582 // Whether this user is a managed user. 573 // Whether this user is a managed user.
583 this.isManagedProfile = loadTimeData.getBoolean('isManagedProfile'); 574 this.isManagedProfile = loadTimeData.getBoolean('isManagedProfile');
584 this.deletingHistoryAllowed = loadTimeData.getBoolean('allowDeletingHistory'); 575 this.deletingHistoryAllowed = loadTimeData.getBoolean('allowDeletingHistory');
585 576
586 // Only create checkboxes for editing entries if they can be used either to 577 // Only create checkboxes for editing entries if they can be used either to
587 // delete an entry or to block/allow it. 578 // delete an entry or to block/allow it.
588 this.editingEntriesAllowed = this.deletingHistoryAllowed || 579 this.editingEntriesAllowed = this.deletingHistoryAllowed;
589 this.isManagedProfile;
590 580
591 // Flag to show that the results are grouped by domain or not. 581 // Flag to show that the results are grouped by domain or not.
592 this.groupByDomain_ = false; 582 this.groupByDomain_ = false;
593 // Group domains by default for managed users.
594 if (this.isManagedProfile)
595 this.groupByDomain_ = true;
596 583
597 this.visits_ = []; // Date-sorted list of visits (most recent first). 584 this.visits_ = []; // Date-sorted list of visits (most recent first).
598 this.nextVisitId_ = 0; 585 this.nextVisitId_ = 0;
599 selectionAnchor = -1; 586 selectionAnchor = -1;
600 587
601 // The page that the view wants to see - we only fetch slightly past this 588 // The page that the view wants to see - we only fetch slightly past this
602 // point. If the view requests a page that we don't have data for, we try 589 // point. If the view requests a page that we don't have data for, we try
603 // to fetch it and call back when we're done. 590 // to fetch it and call back when we're done.
604 this.requestedPage_ = 0; 591 this.requestedPage_ = 0;
605 592
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 $('newest-button').addEventListener('click', function() { 718 $('newest-button').addEventListener('click', function() {
732 self.setPage(0); 719 self.setPage(0);
733 }); 720 });
734 $('newer-button').addEventListener('click', function() { 721 $('newer-button').addEventListener('click', function() {
735 self.setPage(self.pageIndex_ - 1); 722 self.setPage(self.pageIndex_ - 1);
736 }); 723 });
737 $('older-button').addEventListener('click', function() { 724 $('older-button').addEventListener('click', function() {
738 self.setPage(self.pageIndex_ + 1); 725 self.setPage(self.pageIndex_ + 1);
739 }); 726 });
740 727
728 var handleRangeChange = function(e) {
729 // Update the results and save the last state.
730 self.setRangeInDays(parseInt(e.target.value, 10));
731 };
732
741 // Add handlers for the range options. 733 // Add handlers for the range options.
742 $('timeframe-filter').addEventListener('change', function(e) { 734 $('timeframe-filter-all').addEventListener('change', handleRangeChange);
743 self.setRangeInDays(parseInt(e.target.value, 10)); 735 $('timeframe-filter-week').addEventListener('change', handleRangeChange);
744 }); 736 $('timeframe-filter-month').addEventListener('change', handleRangeChange);
745
746 $('group-by-domain').addEventListener('click', function(e) {
747 self.setGroupByDomain($('group-by-domain').checked);
748 });
749 737
750 $('range-previous').addEventListener('click', function(e) { 738 $('range-previous').addEventListener('click', function(e) {
751 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) 739 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME)
752 self.setPage(self.pageIndex_ + 1); 740 self.setPage(self.pageIndex_ + 1);
753 else 741 else
754 self.setOffset(self.getOffset() + 1); 742 self.setOffset(self.getOffset() + 1);
755 }); 743 });
756 $('range-next').addEventListener('click', function(e) { 744 $('range-next').addEventListener('click', function(e) {
757 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) 745 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME)
758 self.setPage(self.pageIndex_ - 1); 746 self.setPage(self.pageIndex_ - 1);
759 else 747 else
760 self.setOffset(self.getOffset() - 1); 748 self.setOffset(self.getOffset() - 1);
761 }); 749 });
762 $('range-today').addEventListener('click', function(e) { 750 $('range-today').addEventListener('click', function(e) {
763 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME) 751 if (self.getRangeInDays() == HistoryModel.Range.ALL_TIME)
764 self.setPage(0); 752 self.setPage(0);
765 else 753 else
766 self.setOffset(0); 754 self.setOffset(0);
767 }); 755 });
768 } 756 }
769 757
770 // HistoryView, public: ------------------------------------------------------- 758 // HistoryView, public: -------------------------------------------------------
771 /** 759 /**
772 * Do a search on a specific term. 760 * Do a search on a specific term.
773 * @param {string} term The string to search for. 761 * @param {string} term The string to search for.
774 */ 762 */
775 HistoryView.prototype.setSearch = function(term) { 763 HistoryView.prototype.setSearch = function(term) {
776 window.scrollTo(0, 0); 764 window.scrollTo(0, 0);
777 this.setPageState(term, 0, this.model_.getGroupByDomain(), 765 this.setPageState(term, 0, this.getRangeInDays(), this.getOffset());
778 this.getRangeInDays(), this.getOffset());
779 }; 766 };
780 767
781 /** 768 /**
782 * Enable or disable results as being grouped by domain.
783 * @param {boolean} groupedByDomain Whether to group by domain or not.
784 */
785 HistoryView.prototype.setGroupByDomain = function(groupedByDomain) {
786 // Group by domain is not currently supported for search results, so reset
787 // the search term if there was one.
788 this.setPageState('', this.pageIndex_, groupedByDomain, this.getRangeInDays(),
789 this.getOffset());
790 };
791
792 /**
793 * Reload the current view. 769 * Reload the current view.
794 */ 770 */
795 HistoryView.prototype.reload = function() { 771 HistoryView.prototype.reload = function() {
796 this.model_.reload(); 772 this.model_.reload();
797 this.updateSelectionEditButtons(); 773 this.updateSelectionEditButtons();
798 this.updateRangeButtons_(); 774 this.updateRangeButtons_();
799 }; 775 };
800 776
801 /** 777 /**
802 * Sets all the parameters for the history page and then reloads the view to 778 * Sets all the parameters for the history page and then reloads the view to
803 * update the results. 779 * update the results.
804 * @param {string} searchText The search string to set. 780 * @param {string} searchText The search string to set.
805 * @param {number} page The page to be viewed. 781 * @param {number} page The page to be viewed.
806 * @param {boolean} groupByDomain Whether the results are grouped or not.
807 * @param {HistoryModel.Range} range The range to view or search over. 782 * @param {HistoryModel.Range} range The range to view or search over.
808 * @param {number} offset Set the begining of the query to the specific offset. 783 * @param {number} offset Set the begining of the query to the specific offset.
809 */ 784 */
810 HistoryView.prototype.setPageState = function(searchText, page, groupByDomain, 785 HistoryView.prototype.setPageState = function(searchText, page, range, offset) {
811 range, offset) {
812 this.clear_(); 786 this.clear_();
813 this.model_.searchText_ = searchText; 787 this.model_.searchText_ = searchText;
814 this.pageIndex_ = page; 788 this.pageIndex_ = page;
815 this.model_.requestedPage_ = page; 789 this.model_.requestedPage_ = page;
816 this.model_.groupByDomain_ = groupByDomain;
817 this.model_.rangeInDays_ = range; 790 this.model_.rangeInDays_ = range;
791 this.model_.groupByDomain_ = false;
792 if (range != HistoryModel.Range.ALL_TIME)
793 this.model_.groupByDomain_ = true;
818 this.model_.offset_ = offset; 794 this.model_.offset_ = offset;
819 this.reload(); 795 this.reload();
820 pageState.setUIState(this.model_.getSearchText(), 796 pageState.setUIState(this.model_.getSearchText(),
821 this.pageIndex_, 797 this.pageIndex_,
822 this.model_.getGroupByDomain(),
823 this.getRangeInDays(), 798 this.getRangeInDays(),
824 this.getOffset()); 799 this.getOffset());
825 }; 800 };
826 801
827 /** 802 /**
828 * Switch to a specified page. 803 * Switch to a specified page.
829 * @param {number} page The page we wish to view. 804 * @param {number} page The page we wish to view.
830 */ 805 */
831 HistoryView.prototype.setPage = function(page) { 806 HistoryView.prototype.setPage = function(page) {
832 // TODO(sergiu): Move this function to setPageState as well and see why one 807 // TODO(sergiu): Move this function to setPageState as well and see why one
833 // of the tests fails when using setPageState. 808 // of the tests fails when using setPageState.
834 this.clear_(); 809 this.clear_();
835 this.pageIndex_ = parseInt(page, 10); 810 this.pageIndex_ = parseInt(page, 10);
836 window.scrollTo(0, 0); 811 window.scrollTo(0, 0);
837 this.model_.requestPage(page); 812 this.model_.requestPage(page);
838 pageState.setUIState(this.model_.getSearchText(), 813 pageState.setUIState(this.model_.getSearchText(),
839 this.pageIndex_, 814 this.pageIndex_,
840 this.model_.getGroupByDomain(),
841 this.getRangeInDays(), 815 this.getRangeInDays(),
842 this.getOffset()); 816 this.getOffset());
843 }; 817 };
844 818
845 /** 819 /**
846 * @return {number} The page number being viewed. 820 * @return {number} The page number being viewed.
847 */ 821 */
848 HistoryView.prototype.getPage = function() { 822 HistoryView.prototype.getPage = function() {
849 return this.pageIndex_; 823 return this.pageIndex_;
850 }; 824 };
851 825
852 /** 826 /**
853 * Set the current range for grouped results. 827 * Set the current range for grouped results.
854 * @param {string} range The number of days to which the range should be set. 828 * @param {string} range The number of days to which the range should be set.
855 */ 829 */
856 HistoryView.prototype.setRangeInDays = function(range) { 830 HistoryView.prototype.setRangeInDays = function(range) {
857 // Set the range, offset and reset the page. 831 // Set the range, offset and reset the page.
858 this.setPageState(this.model_.getSearchText(), 0, 832 var groupedByDomain = (range == HistoryModel.Range.ALL_TIME) ? false : true;
859 this.model_.getGroupByDomain(), range, 0); 833 this.setPageState(this.model_.getSearchText(), 0, range, 0);
860 }; 834 };
861 835
862 /** 836 /**
863 * Get the current range in days. 837 * Get the current range in days.
864 * @return {number} Current range in days from the model. 838 * @return {number} Current range in days from the model.
865 */ 839 */
866 HistoryView.prototype.getRangeInDays = function() { 840 HistoryView.prototype.getRangeInDays = function() {
867 return this.model_.rangeInDays; 841 return this.model_.rangeInDays;
868 }; 842 };
869 843
870 /** 844 /**
871 * Set the current offset for grouped results. 845 * Set the current offset for grouped results.
872 * @param {number} offset Offset to set. 846 * @param {number} offset Offset to set.
873 */ 847 */
874 HistoryView.prototype.setOffset = function(offset) { 848 HistoryView.prototype.setOffset = function(offset) {
875 // If there is another query already in flight wait for that to complete. 849 // If there is another query already in flight wait for that to complete.
876 if (this.model_.inFlight_) 850 if (this.model_.inFlight_)
877 return; 851 return;
878 this.setPageState(this.model_.getSearchText(), 852 this.setPageState(this.model_.getSearchText(),
879 this.pageIndex_, 853 this.pageIndex_,
880 this.model_.getGroupByDomain(),
881 this.getRangeInDays(), 854 this.getRangeInDays(),
882 offset); 855 offset);
883 }; 856 };
884 857
885 /** 858 /**
886 * Get the current offset. 859 * Get the current offset.
887 * @return {number} Current offset from the model. 860 * @return {number} Current offset from the model.
888 */ 861 */
889 HistoryView.prototype.getOffset = function() { 862 HistoryView.prototype.getOffset = function() {
890 return this.model_.offset; 863 return this.model_.offset;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1004
1032 numberOfVisits.textContent = loadTimeData.getStringF('numberVisits', 1005 numberOfVisits.textContent = loadTimeData.getStringF('numberVisits',
1033 domainVisits.length); 1006 domainVisits.length);
1034 siteDomain.appendChild(numberOfVisits); 1007 siteDomain.appendChild(numberOfVisits);
1035 1008
1036 domainVisits[0].addFaviconToElement_(siteDomain); 1009 domainVisits[0].addFaviconToElement_(siteDomain);
1037 1010
1038 siteDomainWrapper.addEventListener('click', toggleHandler); 1011 siteDomainWrapper.addEventListener('click', toggleHandler);
1039 1012
1040 if (this.model_.isManagedProfile) { 1013 if (this.model_.isManagedProfile) {
1041 // Visit attempts don't make sense for domains so set the last parameter to 1014 siteDomainWrapper.appendChild(
1042 // false. 1015 getManagedStatusDOM(domainVisits[0].hostFilteringBehavior));
1043 siteDomainWrapper.appendChild(getManagedStatusDOM(
1044 domainVisits[0].hostManualBehavior, domainVisits[0].hostInContentPack));
1045 } 1016 }
1046 1017
1047 siteResults.appendChild(siteDomainWrapper); 1018 siteResults.appendChild(siteDomainWrapper);
1048 var resultsList = siteResults.appendChild( 1019 var resultsList = siteResults.appendChild(
1049 createElementWithClassName('ol', 'site-results')); 1020 createElementWithClassName('ol', 'site-results'));
1050 1021
1051 // Collapse until it gets toggled. 1022 // Collapse until it gets toggled.
1052 resultsList.style.height = 0; 1023 resultsList.style.height = 0;
1053 1024
1054 // Add the results for each of the domain. 1025 // Add the results for each of the domain.
1055 var isMonthGroupedResult = this.getRangeInDays() == HistoryModel.Range.MONTH; 1026 var isMonthGroupedResult = this.getRangeInDays() == HistoryModel.Range.MONTH;
1056 for (var j = 0, visit; visit = domainVisits[j]; j++) { 1027 for (var j = 0, visit; visit = domainVisits[j]; j++) {
1057 resultsList.appendChild(visit.getResultDOM({ 1028 resultsList.appendChild(visit.getResultDOM({
1058 useMonthDate: isMonthGroupedResult 1029 useMonthDate: isMonthGroupedResult
1059 })); 1030 }));
1060 this.setVisitRendered_(visit); 1031 this.setVisitRendered_(visit);
1061 } 1032 }
1062 }; 1033 };
1063 1034
1064 /** 1035 /**
1065 * Enables or disables the time range buttons. 1036 * Enables or disables the time range buttons.
1066 * @private 1037 * @private
1067 */ 1038 */
1068 HistoryView.prototype.updateRangeButtons_ = function() { 1039 HistoryView.prototype.updateRangeButtons_ = function() {
1069 // Update the range button to the current value.
1070 $('timeframe-filter').value = this.getRangeInDays();
1071
1072 // The enabled state for the previous, today and next buttons. 1040 // The enabled state for the previous, today and next buttons.
1073 var previousState = false; 1041 var previousState = false;
1074 var todayState = false; 1042 var todayState = false;
1075 var nextState = false; 1043 var nextState = false;
1076 var usePage = (this.getRangeInDays() == HistoryModel.Range.ALL_TIME); 1044 var usePage = (this.getRangeInDays() == HistoryModel.Range.ALL_TIME);
1077 1045
1078 // Use pagination for most recent visits, offset otherwise. 1046 // Use pagination for most recent visits, offset otherwise.
1079 // TODO(sergiu): Maybe send just one variable in the future. 1047 // TODO(sergiu): Maybe send just one variable in the future.
1080 if (usePage) { 1048 if (usePage) {
1081 if (this.getPage() != 0) { 1049 if (this.getPage() != 0) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 * @param {Array} visits Visits returned by the query. 1097 * @param {Array} visits Visits returned by the query.
1130 * @param {Element} parentElement Element to which to add the results to. 1098 * @param {Element} parentElement Element to which to add the results to.
1131 * @private 1099 * @private
1132 */ 1100 */
1133 HistoryView.prototype.addMonthResults_ = function(visits, parentElement) { 1101 HistoryView.prototype.addMonthResults_ = function(visits, parentElement) {
1134 if (visits.length == 0) 1102 if (visits.length == 0)
1135 return; 1103 return;
1136 1104
1137 var monthResults = parentElement.appendChild( 1105 var monthResults = parentElement.appendChild(
1138 createElementWithClassName('ol', 'month-results')); 1106 createElementWithClassName('ol', 'month-results'));
1107 // Don't add checkboxes if entries can not be edited.
1108 if (!this.model_.editingEntriesAllowed)
1109 monthResults.classList.add('no-checkboxes');
1110
1139 this.groupVisitsByDomain_(visits, monthResults); 1111 this.groupVisitsByDomain_(visits, monthResults);
1140 }; 1112 };
1141 1113
1142 /** 1114 /**
1143 * Adds the results for a certain day. This includes a title with the day of 1115 * Adds the results for a certain day. This includes a title with the day of
1144 * the results and the results themselves, grouped or not. 1116 * the results and the results themselves, grouped or not.
1145 * @param {Array} visits Visits returned by the query. 1117 * @param {Array} visits Visits returned by the query.
1146 * @param {Element} parentElement Element to which to add the results to. 1118 * @param {Element} parentElement Element to which to add the results to.
1147 * @private 1119 * @private
1148 */ 1120 */
1149 HistoryView.prototype.addDayResults_ = function(visits, parentElement) { 1121 HistoryView.prototype.addDayResults_ = function(visits, parentElement) {
1150 if (visits.length == 0) 1122 if (visits.length == 0)
1151 return; 1123 return;
1152 1124
1153 var firstVisit = visits[0]; 1125 var firstVisit = visits[0];
1154 var day = parentElement.appendChild(createElementWithClassName('h3', 'day')); 1126 var day = parentElement.appendChild(createElementWithClassName('h3', 'day'));
1155 day.appendChild(document.createTextNode(firstVisit.dateRelativeDay)); 1127 day.appendChild(document.createTextNode(firstVisit.dateRelativeDay));
1156 if (firstVisit.continued) { 1128 if (firstVisit.continued) {
1157 day.appendChild(document.createTextNode(' ' + 1129 day.appendChild(document.createTextNode(' ' +
1158 loadTimeData.getString('cont'))); 1130 loadTimeData.getString('cont')));
1159 } 1131 }
1160 var dayResults = parentElement.appendChild( 1132 var dayResults = parentElement.appendChild(
1161 createElementWithClassName('ol', 'day-results')); 1133 createElementWithClassName('ol', 'day-results'));
1162 1134
1135 // Don't add checkboxes if entries can not be edited.
1136 if (!this.model_.editingEntriesAllowed)
1137 dayResults.classList.add('no-checkboxes');
1138
1163 if (this.model_.getGroupByDomain()) { 1139 if (this.model_.getGroupByDomain()) {
1164 this.groupVisitsByDomain_(visits, dayResults); 1140 this.groupVisitsByDomain_(visits, dayResults);
1165 } else { 1141 } else {
1166 var lastTime; 1142 var lastTime;
1167 1143
1168 for (var i = 0, visit; visit = visits[i]; i++) { 1144 for (var i = 0, visit; visit = visits[i]; i++) {
1169 // If enough time has passed between visits, indicate a gap in browsing. 1145 // If enough time has passed between visits, indicate a gap in browsing.
1170 var thisTime = visit.date.getTime(); 1146 var thisTime = visit.date.getTime();
1171 if (lastTime && lastTime - thisTime > BROWSING_GAP_TIME) 1147 if (lastTime && lastTime - thisTime > BROWSING_GAP_TIME)
1172 dayResults.appendChild(createElementWithClassName('li', 'gap')); 1148 dayResults.appendChild(createElementWithClassName('li', 'gap'));
1173 1149
1174 // Insert the visit into the DOM. 1150 // Insert the visit into the DOM.
1175 dayResults.appendChild(visit.getResultDOM({ addTitleFavicon: true })); 1151 dayResults.appendChild(visit.getResultDOM({ addTitleFavicon: true }));
1176 this.setVisitRendered_(visit); 1152 this.setVisitRendered_(visit);
1177 1153
1178 lastTime = thisTime; 1154 lastTime = thisTime;
1179 } 1155 }
1180 } 1156 }
1181 }; 1157 };
1182 1158
1183 /** 1159 /**
1160 * Adds the text that shows the current inteval, used for week and month
1161 * results.
1162 * @param {Element} resultsFragment The element to which the interval will be
1163 * added to.
1164 * @private
1165 */
1166 HistoryView.prototype.addTimeframeInterval_ = function(resultsFragment) {
1167 if (this.getRangeInDays() == HistoryModel.Range.ALL_TIME)
1168 return;
1169
1170 // If this is a time range result add some text that shows what is the
1171 // time range for the results the user is viewing.
1172 var timeFrame = resultsFragment.appendChild(
1173 createElementWithClassName('h2', 'timeframe'));
1174 // TODO(sergiu): Figure the best way to show this for the first day of
1175 // the month.
1176 timeFrame.appendChild(document.createTextNode(loadTimeData.getStringF(
1177 'historyInterval',
1178 this.model_.queryStartTime,
1179 this.model_.queryEndTime)));
1180 };
1181
1182 /**
1184 * Update the page with results. 1183 * Update the page with results.
1185 * @param {boolean} doneLoading Whether the current request is complete. 1184 * @param {boolean} doneLoading Whether the current request is complete.
1186 * @private 1185 * @private
1187 */ 1186 */
1188 HistoryView.prototype.displayResults_ = function(doneLoading) { 1187 HistoryView.prototype.displayResults_ = function(doneLoading) {
1189 // Either show a page of results received for the all time results or all the 1188 // Either show a page of results received for the all time results or all the
1190 // received results for the weekly and monthly view. 1189 // received results for the weekly and monthly view.
1191 var results = this.model_.visits_; 1190 var results = this.model_.visits_;
1192 if (this.getRangeInDays() == HistoryModel.Range.ALL_TIME) { 1191 if (this.getRangeInDays() == HistoryModel.Range.ALL_TIME) {
1193 var rangeStart = this.pageIndex_ * RESULTS_PER_PAGE; 1192 var rangeStart = this.pageIndex_ * RESULTS_PER_PAGE;
1194 var rangeEnd = rangeStart + RESULTS_PER_PAGE; 1193 var rangeEnd = rangeStart + RESULTS_PER_PAGE;
1195 results = this.model_.getNumberedRange(rangeStart, rangeEnd); 1194 results = this.model_.getNumberedRange(rangeStart, rangeEnd);
1196 } 1195 }
1197 var searchText = this.model_.getSearchText(); 1196 var searchText = this.model_.getSearchText();
1198 var groupByDomain = this.model_.getGroupByDomain(); 1197 var groupByDomain = this.model_.getGroupByDomain();
1199 1198
1200 if (searchText) { 1199 if (searchText) {
1201 // Add a header for the search results, if there isn't already one. 1200 // Add a header for the search results, if there isn't already one.
1202 if (!this.resultDiv_.querySelector('h3')) { 1201 if (!this.resultDiv_.querySelector('h3')) {
1203 var header = document.createElement('h3'); 1202 var header = document.createElement('h3');
1204 header.textContent = loadTimeData.getStringF('searchResultsFor', 1203 header.textContent = loadTimeData.getStringF('searchResultsFor',
1205 searchText); 1204 searchText);
1206 this.resultDiv_.appendChild(header); 1205 this.resultDiv_.appendChild(header);
1207 } 1206 }
1208 1207
1208 this.addTimeframeInterval_(this.resultDiv_);
1209
1209 var searchResults = createElementWithClassName('ol', 'search-results'); 1210 var searchResults = createElementWithClassName('ol', 'search-results');
1211
1212 // Don't add checkboxes if entries can not be edited.
1213 if (!this.model_.editingEntriesAllowed)
1214 searchResults.classList.add('no-checkboxes');
1215
1210 if (results.length == 0 && doneLoading) { 1216 if (results.length == 0 && doneLoading) {
1211 var noSearchResults = searchResults.appendChild( 1217 var noSearchResults = searchResults.appendChild(
1212 createElementWithClassName('div', 'no-results-message')); 1218 createElementWithClassName('div', 'no-results-message'));
1213 noSearchResults.textContent = loadTimeData.getString('noSearchResults'); 1219 noSearchResults.textContent = loadTimeData.getString('noSearchResults');
1214 } else { 1220 } else {
1215 for (var i = 0, visit; visit = results[i]; i++) { 1221 for (var i = 0, visit; visit = results[i]; i++) {
1216 if (!visit.isRendered) { 1222 if (!visit.isRendered) {
1217 searchResults.appendChild(visit.getResultDOM({ 1223 searchResults.appendChild(visit.getResultDOM({
1218 isSearchResult: true, 1224 isSearchResult: true,
1219 addTitleFavicon: true 1225 addTitleFavicon: true
1220 })); 1226 }));
1221 this.setVisitRendered_(visit); 1227 this.setVisitRendered_(visit);
1222 } 1228 }
1223 } 1229 }
1224 } 1230 }
1225 this.resultDiv_.appendChild(searchResults); 1231 this.resultDiv_.appendChild(searchResults);
1226 } else { 1232 } else {
1227 var resultsFragment = document.createDocumentFragment(); 1233 var resultsFragment = document.createDocumentFragment();
1228 1234
1229 if (this.getRangeInDays() == HistoryModel.Range.WEEK || 1235 this.addTimeframeInterval_(resultsFragment);
1230 this.getRangeInDays() == HistoryModel.Range.MONTH) {
1231 // If this is a time range result add some text that shows what is the
1232 // time range for the results the user is viewing.
1233 var timeFrame = resultsFragment.appendChild(
1234 createElementWithClassName('h2', 'timeframe'));
1235 // TODO(sergiu): Figure the best way to show this for the first day of
1236 // the month.
1237 timeFrame.appendChild(document.createTextNode(loadTimeData.getStringF(
1238 'historyInterval',
1239 this.model_.queryStartTime,
1240 this.model_.queryEndTime)));
1241 }
1242 1236
1243 if (results.length == 0 && doneLoading) { 1237 if (results.length == 0 && doneLoading) {
1244 var noResults = resultsFragment.appendChild( 1238 var noResults = resultsFragment.appendChild(
1245 createElementWithClassName('div', 'no-results-message')); 1239 createElementWithClassName('div', 'no-results-message'));
1246 noResults.textContent = loadTimeData.getString('noResults'); 1240 noResults.textContent = loadTimeData.getString('noResults');
1247 this.resultDiv_.appendChild(resultsFragment); 1241 this.resultDiv_.appendChild(resultsFragment);
1248 this.updateNavBar_(); 1242 this.updateNavBar_();
1249 return; 1243 return;
1250 } 1244 }
1251 1245
(...skipping 23 matching lines...) Expand all
1275 } 1269 }
1276 this.updateNavBar_(); 1270 this.updateNavBar_();
1277 }; 1271 };
1278 1272
1279 /** 1273 /**
1280 * Update the visibility of the page navigation buttons. 1274 * Update the visibility of the page navigation buttons.
1281 * @private 1275 * @private
1282 */ 1276 */
1283 HistoryView.prototype.updateNavBar_ = function() { 1277 HistoryView.prototype.updateNavBar_ = function() {
1284 this.updateRangeButtons_(); 1278 this.updateRangeButtons_();
1285 $('newest-button').hidden = this.pageIndex_ == 0; 1279 if (!loadTimeData.getBoolean('isManagedProfile')) {
1286 $('newer-button').hidden = this.pageIndex_ == 0; 1280 // Managed users have the control bar on top, don't show it on the bottom
1287 $('older-button').hidden = 1281 // as well.
1288 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME || 1282 $('newest-button').hidden = this.pageIndex_ == 0;
1289 !this.model_.hasMoreResults(); 1283 $('newer-button').hidden = this.pageIndex_ == 0;
1284 $('older-button').hidden =
1285 this.model_.rangeInDays_ != HistoryModel.Range.ALL_TIME ||
1286 !this.model_.hasMoreResults();
1287 }
1290 }; 1288 };
1291 1289
1292 /** 1290 /**
1293 * Updates the visibility of the 'Clear browsing data' button. 1291 * Updates the visibility of the 'Clear browsing data' button.
1294 * Only used on mobile platforms. 1292 * Only used on mobile platforms.
1295 * @private 1293 * @private
1296 */ 1294 */
1297 HistoryView.prototype.updateClearBrowsingDataButton_ = function() { 1295 HistoryView.prototype.updateClearBrowsingDataButton_ = function() {
1298 // Ideally, we should hide the 'Clear browsing data' button whenever the 1296 // Ideally, we should hide the 'Clear browsing data' button whenever the
1299 // soft keyboard is visible. This is not possible, so instead, hide the 1297 // soft keyboard is visible. This is not possible, so instead, hide the
(...skipping 20 matching lines...) Expand all
1320 this.view = view; 1318 this.view = view;
1321 1319
1322 if (typeof this.checker_ != 'undefined' && this.checker_) { 1320 if (typeof this.checker_ != 'undefined' && this.checker_) {
1323 clearInterval(this.checker_); 1321 clearInterval(this.checker_);
1324 } 1322 }
1325 1323
1326 // TODO(glen): Replace this with a bound method so we don't need 1324 // TODO(glen): Replace this with a bound method so we don't need
1327 // public model and view. 1325 // public model and view.
1328 this.checker_ = window.setInterval(function(stateObj) { 1326 this.checker_ = window.setInterval(function(stateObj) {
1329 var hashData = stateObj.getHashData(); 1327 var hashData = stateObj.getHashData();
1330 var isGroupedByDomain = hashData.grouped == 'true';
1331 var page = parseInt(hashData.page, 10); 1328 var page = parseInt(hashData.page, 10);
1332 var range = parseInt(hashData.range, 10); 1329 var range = parseInt(hashData.range, 10);
1333 var offset = parseInt(hashData.offset, 10); 1330 var offset = parseInt(hashData.offset, 10);
1334 if (hashData.q != stateObj.model.getSearchText() || 1331 if (hashData.q != stateObj.model.getSearchText() ||
1335 page != stateObj.view.getPage() || 1332 page != stateObj.view.getPage() ||
1336 isGroupedByDomain != stateObj.view.model_.getGroupByDomain() ||
1337 range != stateObj.model.rangeInDays || 1333 range != stateObj.model.rangeInDays ||
1338 offset != stateObj.model.offset) { 1334 offset != stateObj.model.offset) {
1339 stateObj.view.setPageState(hashData.q, page, isGroupedByDomain, 1335 stateObj.view.setPageState(hashData.q, page, range, offset);
1340 range, offset);
1341 } 1336 }
1342 }, 50, this); 1337 }, 50, this);
1343 } 1338 }
1344 1339
1345 /** 1340 /**
1346 * Holds the singleton instance. 1341 * Holds the singleton instance.
1347 */ 1342 */
1348 PageState.instance = null; 1343 PageState.instance = null;
1349 1344
1350 /** 1345 /**
(...skipping 21 matching lines...) Expand all
1372 1367
1373 return result; 1368 return result;
1374 }; 1369 };
1375 1370
1376 /** 1371 /**
1377 * Set the hash to a specified state, this will create an entry in the 1372 * Set the hash to a specified state, this will create an entry in the
1378 * session history so the back button cycles through hash states, which 1373 * session history so the back button cycles through hash states, which
1379 * are then picked up by our listener. 1374 * are then picked up by our listener.
1380 * @param {string} term The current search string. 1375 * @param {string} term The current search string.
1381 * @param {number} page The page currently being viewed. 1376 * @param {number} page The page currently being viewed.
1382 * @param {boolean} grouped Whether the results are grouped or not.
1383 * @param {HistoryModel.Range} range The range to view or search over. 1377 * @param {HistoryModel.Range} range The range to view or search over.
1384 * @param {number} offset Set the begining of the query to the specific offset. 1378 * @param {number} offset Set the begining of the query to the specific offset.
1385 */ 1379 */
1386 PageState.prototype.setUIState = function(term, page, grouped, range, offset) { 1380 PageState.prototype.setUIState = function(term, page, range, offset) {
1387 // Make sure the form looks pretty. 1381 // Make sure the form looks pretty.
1388 $('search-field').value = term; 1382 $('search-field').value = term;
1389 $('group-by-domain').checked = grouped;
1390 var hash = this.getHashData(); 1383 var hash = this.getHashData();
1391 if (hash.q != term || hash.page != page || hash.grouped != grouped || 1384 if (hash.q != term || hash.page != page || hash.range != range ||
1392 hash.range != range || hash.offset != offset) { 1385 hash.offset != offset) {
1393 window.location.hash = PageState.getHashString( 1386 window.location.hash = PageState.getHashString(term, page, range, offset);
1394 term, page, grouped, range, offset);
1395 } 1387 }
1396 }; 1388 };
1397 1389
1398 /** 1390 /**
1399 * Static method to get the hash string for a specified state 1391 * Static method to get the hash string for a specified state
1400 * @param {string} term The current search string. 1392 * @param {string} term The current search string.
1401 * @param {number} page The page currently being viewed. 1393 * @param {number} page The page currently being viewed.
1402 * @param {boolean} grouped Whether the results are grouped or not.
1403 * @param {HistoryModel.Range} range The range to view or search over. 1394 * @param {HistoryModel.Range} range The range to view or search over.
1404 * @param {number} offset Set the begining of the query to the specific offset. 1395 * @param {number} offset Set the begining of the query to the specific offset.
1405 * @return {string} The string to be used in a hash. 1396 * @return {string} The string to be used in a hash.
1406 */ 1397 */
1407 PageState.getHashString = function(term, page, grouped, range, offset) { 1398 PageState.getHashString = function(term, page, range, offset) {
1408 // Omit elements that are empty. 1399 // Omit elements that are empty.
1409 var newHash = []; 1400 var newHash = [];
1410 1401
1411 if (term) 1402 if (term)
1412 newHash.push('q=' + encodeURIComponent(term)); 1403 newHash.push('q=' + encodeURIComponent(term));
1413 1404
1414 if (page) 1405 if (page)
1415 newHash.push('page=' + page); 1406 newHash.push('page=' + page);
1416 1407
1417 if (grouped)
1418 newHash.push('grouped=' + grouped);
1419
1420 if (range) 1408 if (range)
1421 newHash.push('range=' + range); 1409 newHash.push('range=' + range);
1422 1410
1423 if (offset) 1411 if (offset)
1424 newHash.push('offset=' + offset); 1412 newHash.push('offset=' + offset);
1425 1413
1426 return newHash.join('&'); 1414 return newHash.join('&');
1427 }; 1415 };
1428 1416
1429 /////////////////////////////////////////////////////////////////////////////// 1417 ///////////////////////////////////////////////////////////////////////////////
1430 // Document Functions: 1418 // Document Functions:
1431 /** 1419 /**
1432 * Window onload handler, sets up the page. 1420 * Window onload handler, sets up the page.
1433 */ 1421 */
1434 function load() { 1422 function load() {
1435 uber.onContentFrameLoaded(); 1423 uber.onContentFrameLoaded();
1436 1424
1437 var searchField = $('search-field'); 1425 var searchField = $('search-field');
1438 1426
1439 historyModel = new HistoryModel(); 1427 historyModel = new HistoryModel();
1440 historyView = new HistoryView(historyModel); 1428 historyView = new HistoryView(historyModel);
1441 pageState = new PageState(historyModel, historyView); 1429 pageState = new PageState(historyModel, historyView);
1442 1430
1443 // Create default view. 1431 // Create default view.
1444 var hashData = pageState.getHashData(); 1432 var hashData = pageState.getHashData();
1445 var grouped = (hashData.grouped == 'true') || historyModel.getGroupByDomain(); 1433 var grouped = (hashData.grouped == 'true') || historyModel.getGroupByDomain();
1446 var page = parseInt(hashData.page, 10) || historyView.getPage(); 1434 var page = parseInt(hashData.page, 10) || historyView.getPage();
1447 var range = parseInt(hashData.range, 10) || historyView.getRangeInDays(); 1435 var range = parseInt(hashData.range, 10) || historyView.getRangeInDays();
1448 var offset = parseInt(hashData.offset, 10) || historyView.getOffset(); 1436 var offset = parseInt(hashData.offset, 10) || historyView.getOffset();
1449 historyView.setPageState(hashData.q, page, grouped, range, offset); 1437 historyView.setPageState(hashData.q, page, range, offset);
1450 1438
1451 if ($('overlay')) 1439 if ($('overlay'))
1452 cr.ui.overlay.setupOverlay($('overlay')); 1440 cr.ui.overlay.setupOverlay($('overlay'));
1453 1441
1454 var doSearch = function(e) { 1442 var doSearch = function(e) {
1455 // Disable the group by domain control when a search is active.
1456 $('group-by-domain').disabled = (searchField.value != '');
1457 historyView.setSearch(searchField.value); 1443 historyView.setSearch(searchField.value);
1458 1444
1459 if (isMobileVersion()) 1445 if (isMobileVersion())
1460 searchField.blur(); // Dismiss the keyboard. 1446 searchField.blur(); // Dismiss the keyboard.
1461 }; 1447 };
1462 1448
1463 var mayRemoveVisits = loadTimeData.getBoolean('allowDeletingHistory'); 1449 var mayRemoveVisits = loadTimeData.getBoolean('allowDeletingHistory');
1464 $('remove-visit').disabled = !mayRemoveVisits; 1450 $('remove-visit').disabled = !mayRemoveVisits;
1465 1451
1466 if (mayRemoveVisits) { 1452 if (mayRemoveVisits) {
1467 $('remove-visit').addEventListener('activate', function(e) { 1453 $('remove-visit').addEventListener('activate', function(e) {
1468 activeVisit.removeFromHistory(); 1454 activeVisit.removeFromHistory();
1469 activeVisit = null; 1455 activeVisit = null;
1470 }); 1456 });
1471 } 1457 }
1472 1458
1473 searchField.addEventListener('search', doSearch); 1459 searchField.addEventListener('search', doSearch);
1474 $('search-button').addEventListener('click', doSearch); 1460 $('search-button').addEventListener('click', doSearch);
1475 1461
1476 $('more-from-site').addEventListener('activate', function(e) { 1462 $('more-from-site').addEventListener('activate', function(e) {
1477 activeVisit.showMoreFromSite_(); 1463 activeVisit.showMoreFromSite_();
1478 activeVisit = null; 1464 activeVisit = null;
1479 }); 1465 });
1480 1466
1481 // Only show the controls if the command line switch is activated. 1467 // Only show the controls if the command line switch is activated.
1482 if (loadTimeData.getBoolean('groupByDomain') || 1468 if (loadTimeData.getBoolean('groupByDomain') ||
1483 loadTimeData.getBoolean('isManagedProfile')) { 1469 loadTimeData.getBoolean('isManagedProfile')) {
1484 $('filter-controls').hidden = false; 1470 // Hide the top container which has the "Clear browsing data" and "Remove
1471 // selected entries" buttons since they're unavailable in managed mode
1472 $('top-container').hidden = true;
1473 $('page').classList.add('big-topbar-page');
1474 } else {
1475 $('filter-controls').hidden = true;
markusheintz_ 2013/06/05 14:14:15 Just for the record since we already discussed thi
1485 } 1476 }
1486 1477
1487 var title = loadTimeData.getString('title'); 1478 var title = loadTimeData.getString('title');
1488 uber.invokeMethodOnParent('setTitle', {title: title}); 1479 uber.invokeMethodOnParent('setTitle', {title: title});
1489 1480
1490 // Adjust the position of the notification bar when the window size changes. 1481 // Adjust the position of the notification bar when the window size changes.
1491 window.addEventListener('resize', 1482 window.addEventListener('resize',
1492 historyView.positionNotificationBar.bind(historyView)); 1483 historyView.positionNotificationBar.bind(historyView));
1493 1484
1494 if (isMobileVersion()) { 1485 if (isMobileVersion()) {
(...skipping 18 matching lines...) Expand all
1513 } else { 1504 } else {
1514 window.addEventListener('message', function(e) { 1505 window.addEventListener('message', function(e) {
1515 if (e.data.method == 'frameSelected') 1506 if (e.data.method == 'frameSelected')
1516 searchField.focus(); 1507 searchField.focus();
1517 }); 1508 });
1518 searchField.focus(); 1509 searchField.focus();
1519 } 1510 }
1520 } 1511 }
1521 1512
1522 /** 1513 /**
1523 * Updates the whitelist status labels of a host/URL entry to the current 1514 * Updates the managed filter status labels of a host/URL entry to the current
1524 * value. 1515 * value.
1525 * @param {Element} statusElement The div which contains the status labels. 1516 * @param {Element} statusElement The div which contains the status labels.
1526 * @param {Object} newStatus A dictionary with two entries: 1517 * @param {ManagedModeFilteringBehavior} newStatus The filter status of the
1527 * - |inContentPack|: whether the current domain/URL is allowed by a 1518 * current domain/URL.
1528 * content pack.
1529 * - |manualBehavior|: The manual status of the current domain/URL.
1530 */ 1519 */
1531 function updateHostStatus(statusElement, newStatus) { 1520 function updateHostStatus(statusElement, newStatus) {
1532 var inContentPackDiv = statusElement.querySelector('.in-content-pack'); 1521 var filteringBehaviorDiv =
1533 inContentPackDiv.className = 'in-content-pack'; 1522 statusElement.querySelector('.filtering-behavior');
1534 1523 // Reset to the base class first, then add modifier classes if needed.
1535 if (newStatus['inContentPack']) { 1524 filteringBehaviorDiv.className = 'filtering-behavior';
1536 if (newStatus['manualBehavior'] != ManagedModeManualBehavior.NONE) 1525 if (newStatus == ManagedModeFilteringBehavior.BLOCK) {
1537 inContentPackDiv.classList.add('in-content-pack-passive'); 1526 filteringBehaviorDiv.textContent =
1538 else 1527 loadTimeData.getString('filterBlocked');
1539 inContentPackDiv.classList.add('in-content-pack-active'); 1528 filteringBehaviorDiv.classList.add('filter-blocked');
1540 } 1529 } else {
1541 1530 filteringBehaviorDiv.textContent = '';
1542 if ('manualBehavior' in newStatus) {
1543 var manualBehaviorDiv = statusElement.querySelector('.manual-behavior');
1544 // Reset to the base class first, then add modifier classes if needed.
1545 manualBehaviorDiv.className = 'manual-behavior';
1546 switch (newStatus['manualBehavior']) {
1547 case ManagedModeManualBehavior.NONE:
1548 manualBehaviorDiv.textContent = '';
1549 break;
1550 case ManagedModeManualBehavior.ALLOW:
1551 manualBehaviorDiv.textContent = loadTimeData.getString('filterAllowed');
1552 manualBehaviorDiv.classList.add('filter-allowed');
1553 break;
1554 case ManagedModeManualBehavior.BLOCK:
1555 manualBehaviorDiv.textContent = loadTimeData.getString('filterBlocked');
1556 manualBehaviorDiv.classList.add('filter-blocked');
1557 break;
1558 }
1559 } 1531 }
1560 } 1532 }
1561 1533
1562 /** 1534 /**
1563 * Click handler for the 'Clear browsing data' dialog. 1535 * Click handler for the 'Clear browsing data' dialog.
1564 * @param {Event} e The click event. 1536 * @param {Event} e The click event.
1565 */ 1537 */
1566 function openClearBrowsingData(e) { 1538 function openClearBrowsingData(e) {
1567 chrome.send('clearBrowsingData'); 1539 chrome.send('clearBrowsingData');
1568 } 1540 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1788 innerArrow.classList.add('expand'); 1760 innerArrow.classList.add('expand');
1789 } else { 1761 } else {
1790 innerResultList.style.height = 0; 1762 innerResultList.style.height = 0;
1791 innerArrow.classList.remove('expand'); 1763 innerArrow.classList.remove('expand');
1792 innerArrow.classList.add('collapse'); 1764 innerArrow.classList.add('collapse');
1793 } 1765 }
1794 } 1766 }
1795 1767
1796 /** 1768 /**
1797 * Builds the DOM elements to show the managed status of a domain/URL. 1769 * Builds the DOM elements to show the managed status of a domain/URL.
1798 * @param {ManagedModeManualBehavior} manualBehavior The manual behavior for 1770 * @param {ManagedModeFilteringBehavior} filteringBehavior The filter behavior
1799 * this item. 1771 * for this item.
1800 * @param {boolean} inContentPack Whether this element is in a content pack or
markusheintz_ 2013/06/05 14:49:09 Just to double check so that I don't misunderstand
1801 * not.
1802 * @return {Element} Returns the DOM elements which show the status. 1772 * @return {Element} Returns the DOM elements which show the status.
1803 */ 1773 */
1804 function getManagedStatusDOM(manualBehavior, inContentPack) { 1774 function getManagedStatusDOM(filteringBehavior) {
1805 var filterStatusDiv = createElementWithClassName('div', 'filter-status'); 1775 var filterStatusDiv = createElementWithClassName('div', 'filter-status');
1806 var inContentPackDiv = createElementWithClassName('div', 'in-content-pack'); 1776 var filteringBehaviorDiv =
1807 inContentPackDiv.textContent = loadTimeData.getString('inContentPack'); 1777 createElementWithClassName('div', 'filtering-behavior');
1808 var manualBehaviorDiv = createElementWithClassName('div', 'manual-behavior'); 1778 filterStatusDiv.appendChild(filteringBehaviorDiv);
1809 filterStatusDiv.appendChild(inContentPackDiv);
1810 filterStatusDiv.appendChild(manualBehaviorDiv);
1811 1779
1812 updateHostStatus(filterStatusDiv, { 1780 updateHostStatus(filterStatusDiv, filteringBehavior);
1813 'inContentPack' : inContentPack,
1814 'manualBehavior' : manualBehavior
1815 });
1816 return filterStatusDiv; 1781 return filterStatusDiv;
1817 } 1782 }
1818 1783
1819 1784
1820 /////////////////////////////////////////////////////////////////////////////// 1785 ///////////////////////////////////////////////////////////////////////////////
1821 // Chrome callbacks: 1786 // Chrome callbacks:
1822 1787
1823 /** 1788 /**
1824 * Our history system calls this function with results from searches. 1789 * Our history system calls this function with results from searches.
1825 * @param {Object} info An object containing information about the query. 1790 * @param {Object} info An object containing information about the query.
(...skipping 28 matching lines...) Expand all
1854 historyView.reload(); 1819 historyView.reload();
1855 } 1820 }
1856 1821
1857 // Add handlers to HTML elements. 1822 // Add handlers to HTML elements.
1858 document.addEventListener('DOMContentLoaded', load); 1823 document.addEventListener('DOMContentLoaded', load);
1859 1824
1860 // This event lets us enable and disable menu items before the menu is shown. 1825 // This event lets us enable and disable menu items before the menu is shown.
1861 document.addEventListener('canExecute', function(e) { 1826 document.addEventListener('canExecute', function(e) {
1862 e.canExecute = true; 1827 e.canExecute = true;
1863 }); 1828 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/history/history.html ('k') | chrome/browser/ui/webui/history_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698