Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/ui/sendReport.js

Issue 5410618009976832: issue #690 - don't consider special subscriptions when complaining about high subscription count (Closed)
Left Patch Set: Created July 26, 2014, 7:39 p.m.
Right Patch Set: Created July 30, 2014, 6:06 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 this.data.parentNode.removeChild(this.data); 726 this.data.parentNode.removeChild(this.data);
727 } 727 }
728 }; 728 };
729 729
730 let subscriptionUpdateDataSource = 730 let subscriptionUpdateDataSource =
731 { 731 {
732 contentWnd: null, 732 contentWnd: null,
733 type: null, 733 type: null,
734 outdated: null, 734 outdated: null,
735 needUpdate: null, 735 needUpdate: null,
736
737 subscriptionFilter: function(s)
738 {
739 if (s instanceof DownloadableSubscription)
740 return subscriptionsDataSource.subscriptionFilter(s);
741 else
742 return false;
743 },
736 744
737 collectData: function(wnd, windowURI, callback) 745 collectData: function(wnd, windowURI, callback)
738 { 746 {
739 this.contentWnd = wnd; 747 this.contentWnd = wnd;
740 let now = Date.now() / MILLISECONDS_IN_SECOND; 748 let now = Date.now() / MILLISECONDS_IN_SECOND;
741 let outdatedThreshold = now - 14 * SECONDS_IN_DAY; 749 let outdatedThreshold = now - 14 * SECONDS_IN_DAY;
742 let needUpdateThreshold = now - 1 * SECONDS_IN_HOUR; 750 let needUpdateThreshold = now - 1 * SECONDS_IN_HOUR;
743 751
744 this.outdated = []; 752 this.outdated = [];
745 this.needUpdate = []; 753 this.needUpdate = [];
746 754
747 let subscriptions = FilterStorage.subscriptions.filter(issuesDataSource.subs criptionFilter); 755 let subscriptions = FilterStorage.subscriptions.filter(this.subscriptionFilt er);
748 for (let i = 0; i < subscriptions.length; i++) 756 for (let i = 0; i < subscriptions.length; i++)
749 { 757 {
750 let lastSuccess = subscriptions[i].lastSuccess; 758 let lastSuccess = subscriptions[i].lastSuccess;
751 if (lastSuccess < outdatedThreshold) 759 if (lastSuccess < outdatedThreshold)
752 this.outdated.push(subscriptions[i]); 760 this.outdated.push(subscriptions[i]);
753 if (lastSuccess < needUpdateThreshold) 761 if (lastSuccess < needUpdateThreshold)
754 this.needUpdate.push(subscriptions[i]); 762 this.needUpdate.push(subscriptions[i]);
755 } 763 }
756 764
757 callback(); 765 callback();
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 } 880 }
873 881
874 let issuesDataSource = 882 let issuesDataSource =
875 { 883 {
876 contentWnd: null, 884 contentWnd: null,
877 isEnabled: Prefs.enabled, 885 isEnabled: Prefs.enabled,
878 whitelistFilter: null, 886 whitelistFilter: null,
879 disabledFilters: [], 887 disabledFilters: [],
880 disabledSubscriptions: [], 888 disabledSubscriptions: [],
881 ownFilters: [], 889 ownFilters: [],
882 numGeneralSubscriptions: 0, 890 numSubscriptions: 0,
Wladimir Palant 2014/07/28 09:17:18 I see no point renaming this property, your new na
saroyanm 2014/07/28 09:49:20 Done.
883 numAppliedFilters: Infinity, 891 numAppliedFilters: Infinity,
884 892
885 subscriptionFilter: function(s) 893 subscriptionFilter: function(s)
886 { 894 {
887 if (s instanceof DownloadableSubscription) 895 if (s instanceof DownloadableSubscription &&
896 s.url != Prefs.subscriptions_exceptionsurl &&
897 s.url != Prefs.subscriptions_antiadblockurl)
898 {
888 return subscriptionsDataSource.subscriptionFilter(s); 899 return subscriptionsDataSource.subscriptionFilter(s);
900 }
889 else 901 else
890 return false; 902 return false;
891 }, 903 },
892 904
893 collectData: function(wnd, windowURI, callback) 905 collectData: function(wnd, windowURI, callback)
894 { 906 {
895 this.contentWnd = wnd; 907 this.contentWnd = wnd;
896 this.whitelistFilter = Policy.isWindowWhitelisted(wnd); 908 this.whitelistFilter = Policy.isWindowWhitelisted(wnd);
897 909
898 if (!this.whitelistFilter && this.isEnabled) 910 if (!this.whitelistFilter && this.isEnabled)
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 954
943 let filter = disabledMatcher.matchesAny(request.location, request.type Descr, request.docDomain, request.thirdParty); 955 let filter = disabledMatcher.matchesAny(request.location, request.type Descr, request.docDomain, request.thirdParty);
944 if (filter && !(subscription.url in seenSubscriptions)) 956 if (filter && !(subscription.url in seenSubscriptions))
945 { 957 {
946 this.disabledSubscriptions.push(subscription); 958 this.disabledSubscriptions.push(subscription);
947 seenSubscriptions[subscription.text] = true; 959 seenSubscriptions[subscription.text] = true;
948 break; 960 break;
949 } 961 }
950 } 962 }
951 } 963 }
952 964
953 for each (let {url} in FilterStorage.subscriptions.filter(this.subscriptio nFilter)) 965 this.numSubscriptions = FilterStorage.subscriptions.filter(this.subscripti onFilter).length;
saroyanm 2014/07/26 19:52:07 Not sure if we need separate generalSubscriptionFi
Wladimir Palant 2014/07/28 09:17:18 Please simply extend subscriptionFilter - this fun
saroyanm 2014/07/28 09:49:20 Seams like the issuesDataSource.subscriptionFilter
954 if (url != Prefs.subscriptions_exceptionsurl && url != Prefs.subscriptio ns_antiadblockurl)
955 this.numGeneralSubscriptions++;
956
957 this.numAppliedFilters = 0; 966 this.numAppliedFilters = 0;
958 for each (let filter in filtersDataSource.origFilters) 967 for each (let filter in filtersDataSource.origFilters)
959 { 968 {
960 if (filter instanceof WhitelistFilter) 969 if (filter instanceof WhitelistFilter)
961 continue; 970 continue;
962 971
963 this.numAppliedFilters++; 972 this.numAppliedFilters++;
964 if (filter.subscriptions.some(function(subscription) subscription instan ceof SpecialSubscription)) 973 if (filter.subscriptions.some(function(subscription) subscription instan ceof SpecialSubscription))
965 this.ownFilters.push(filter); 974 this.ownFilters.push(filter);
966 } 975 }
967 } 976 }
968 977
969 callback(); 978 callback();
970 }, 979 },
971 980
972 updateIssues: function(type) 981 updateIssues: function(type)
973 { 982 {
974 if (type == "other") 983 if (type == "other")
975 { 984 {
976 E("typeSelectorPage").next = "typeWarning"; 985 E("typeSelectorPage").next = "typeWarning";
977 return; 986 return;
978 } 987 }
979 988
980 E("issuesWhitelistBox").hidden = !this.whitelistFilter; 989 E("issuesWhitelistBox").hidden = !this.whitelistFilter;
981 E("issuesDisabledBox").hidden = this.isEnabled; 990 E("issuesDisabledBox").hidden = this.isEnabled;
982 E("issuesNoFiltersBox").hidden = (type != "false positive" || this.numApplie dFilters > 0); 991 E("issuesNoFiltersBox").hidden = (type != "false positive" || this.numApplie dFilters > 0);
983 E("issuesNoSubscriptionsBox").hidden = (type != "false negative" || this.num AppliedFilters > 0 || this.numGeneralSubscriptions > 0); 992 E("issuesNoSubscriptionsBox").hidden = (type != "false negative" || this.num AppliedFilters > 0 || this.numSubscriptions > 0);
984 E("issuesSubscriptionCountBox").hidden = (this.numGeneralSubscriptions < 5); 993 E("issuesSubscriptionCountBox").hidden = (this.numSubscriptions < 5);
985 994
986 let ownFiltersBox = E("issuesOwnFilters"); 995 let ownFiltersBox = E("issuesOwnFilters");
987 if (this.ownFilters.length && !ownFiltersBox.firstChild) 996 if (this.ownFilters.length && !ownFiltersBox.firstChild)
988 { 997 {
989 let template = E("issuesOwnFiltersTemplate"); 998 let template = E("issuesOwnFiltersTemplate");
990 for each (let filter in this.ownFilters) 999 for each (let filter in this.ownFilters)
991 { 1000 {
992 let element = template.cloneNode(true); 1001 let element = template.cloneNode(true);
993 element.removeAttribute("id"); 1002 element.removeAttribute("id");
994 element.removeAttribute("hidden"); 1003 element.removeAttribute("hidden");
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 1574
1566 function censorURL(url) 1575 function censorURL(url)
1567 { 1576 {
1568 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*"); 1577 return url.replace(/([?;&\/#][^?;&\/#]+?=)[^?;&\/#]+/g, "$1*");
1569 } 1578 }
1570 1579
1571 function encodeHTML(str) 1580 function encodeHTML(str)
1572 { 1581 {
1573 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;"); 1582 return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"). replace(/"/g, "&quot;");
1574 } 1583 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld