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

Side by Side Diff: background.js

Issue 6432313504169984: Issue 1663 - Various Firefox-related changes of the first-run page (Closed)
Patch Set: Updated fake background page Created Jan. 6, 2015, 10:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « README.md ('k') | firstRun.html » ('j') | i18n.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 } 30 }
31 } 31 }
32 } 32 }
33 33
34 var subscriptions =[ 34 var subscriptions =[
35 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", 35 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt",
36 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", 36 "https://easylist-downloads.adblockplus.org/exceptionrules.txt",
37 "https://easylist-downloads.adblockplus.org/fanboy-social.txt" 37 "https://easylist-downloads.adblockplus.org/fanboy-social.txt"
38 ]; 38 ];
39 39
40 global.Utils = { 40 var modules = {};
41 getDocLink: function(link) 41 global.require = function(module)
42 { 42 {
43 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(link) ; 43 return modules[module];
44 }
45 }; 44 };
46 45
47 global.Subscription = function(url) 46 modules.utils = {
48 { 47 Utils: {
49 this.url = url; 48 getDocLink: function(link)
50 this.title = "Subscription " + url;
51 this.disabled = false;
52 this.lastDownload = 1234;
53 };
54
55 global.Subscription.fromURL = function(url)
56 {
57 return new global.Subscription(url);
58 };
59
60 global.DownloadableSubscription = global.Subscription;
61 global.SpecialSubscription = function() {};
62
63 global.FilterStorage = {
64 get subscriptions()
65 {
66 return subscriptions.map(global.Subscription.fromURL);
67 },
68
69 get knownSubscriptions()
70 {
71 var result = {};
72 for (var i = 0; i < subscriptions.length; i++)
73 result[subscriptions[i]] = global.Subscription.fromURL(subscriptions[i]) ;
74 return result;
75 },
76
77 addSubscription: function(subscription)
78 {
79 var index = subscriptions.indexOf(subscription.url);
80 if (index < 0)
81 { 49 {
82 subscriptions.push(subscription.url); 50 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k);
83 global.FilterNotifier.triggerListeners("subscription.added", subscriptio n);
84 }
85 },
86
87 removeSubscription: function(subscription)
88 {
89 var index = subscriptions.indexOf(subscription.url);
90 if (index >= 0)
91 {
92 subscriptions.splice(index, 1);
93 global.FilterNotifier.triggerListeners("subscription.removed", subscript ion);
94 } 51 }
95 } 52 }
96 }; 53 };
97 54
98 global.BlockingFilter = function() {}; 55 modules.subscriptionClasses = {
56 Subscription: function(url)
57 {
58 this.url = url;
59 this.title = "Subscription " + url;
60 this.disabled = false;
61 this.lastDownload = 1234;
62 },
99 63
100 global.defaultMatcher = { 64 SpecialSubscription: function() {}
101 matchesAny: function(url, requestType, docDomain, thirdParty) 65 };
102 { 66 modules.subscriptionClasses.Subscription.fromURL = function(url)
103 var params = {blockedURLs: ""}; 67 {
104 updateFromURL(params); 68 return new modules.subscriptionClasses.Subscription(url);
105 var blocked = params.blockedURLs.split(","); 69 };
106 if (blocked.indexOf(url) >= 0) 70 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla sses.Subscription;
107 return new global.BlockingFilter(); 71
108 else 72 modules.filterStorage = {
109 return null; 73 FilterStorage: {
74 get subscriptions()
75 {
76 return subscriptions.map(modules.subscriptionClasses.Subscription.fromUR L);
77 },
78
79 get knownSubscriptions()
80 {
81 var result = {};
82 for (var i = 0; i < subscriptions.length; i++)
83 result[subscriptions[i]] = modules.subscriptionClasses.Subscription.fr omURL(subscriptions[i]);
84 return result;
85 },
86
87 addSubscription: function(subscription)
88 {
89 var index = subscriptions.indexOf(subscription.url);
90 if (index < 0)
91 {
92 subscriptions.push(subscription.url);
93 modules.filterNotifier.FilterNotifier.triggerListeners("subscription.a dded", subscription);
94 }
95 },
96
97 removeSubscription: function(subscription)
98 {
99 var index = subscriptions.indexOf(subscription.url);
100 if (index >= 0)
101 {
102 subscriptions.splice(index, 1);
103 modules.filterNotifier.FilterNotifier.triggerListeners("subscription.r emoved", subscription);
104 }
105 }
106 }
107 };
108
109 modules.filterClasses = {
110 BlockingFilter: function() {}
111 };
112
113 modules.synchronizer = {
114 Synchronizer: {}
115 };
116
117 modules.matcher = {
118 defaultMatcher: {
119 matchesAny: function(url, requestType, docDomain, thirdParty)
120 {
121 var params = {blockedURLs: ""};
122 updateFromURL(params);
123 var blocked = params.blockedURLs.split(",");
124 if (blocked.indexOf(url) >= 0)
125 return new modules.filterClasses.BlockingFilter();
126 else
127 return null;
128 }
110 } 129 }
111 }; 130 };
112 131
113 var notifierListeners = []; 132 var notifierListeners = [];
114 global.FilterNotifier = { 133 modules.filterNotifier = {
115 addListener: function(listener) 134 FilterNotifier: {
116 { 135 addListener: function(listener)
117 if (notifierListeners.indexOf(listener) < 0) 136 {
118 notifierListeners.push(listener); 137 if (notifierListeners.indexOf(listener) < 0)
119 }, 138 notifierListeners.push(listener);
139 },
120 140
121 removeListener: function(listener) 141 removeListener: function(listener)
122 { 142 {
123 var index = notifierListeners.indexOf(listener); 143 var index = notifierListeners.indexOf(listener);
124 if (index >= 0) 144 if (index >= 0)
125 notifierListeners.splice(index, 1); 145 notifierListeners.splice(index, 1);
126 }, 146 },
127 147
128 triggerListeners: function() 148 triggerListeners: function()
129 { 149 {
130 var args = Array.prototype.slice.apply(arguments); 150 var args = Array.prototype.slice.apply(arguments);
131 var listeners = notifierListeners.slice(); 151 var listeners = notifierListeners.slice();
132 for (var i = 0; i < listeners.length; i++) 152 for (var i = 0; i < listeners.length; i++)
133 listeners[i].apply(null, args); 153 listeners[i].apply(null, args);
154 }
134 } 155 }
135 }; 156 };
136 157
137 global.require = function(module) 158 modules.info = {
138 { 159 platform: "gecko",
139 if (module == "info") 160 platformVersion: "34.0",
140 { 161 application: "firefox",
141 var result = { 162 applicationVersion: "34.0"
142 platform: "gecko", 163 };
143 platformVersion: "34.0", 164 updateFromURL(modules.info);
144 application: "firefox",
145 applicationVersion: "34.0"
146 };
147 updateFromURL(result);
148 return result;
149 }
150 else
151 return undefined;
152 }
153 165
154 global.openOptions = function() 166 global.openOptions = function()
155 { 167 {
156 window.open("http://example.com/options.html", "_blank"); 168 window.open("http://example.com/options.html", "_blank");
157 }; 169 };
158 170
159 global.Services = { 171 global.Services = {
160 vc: { 172 vc: {
161 compare: function(v1, v2) 173 compare: function(v1, v2)
162 { 174 {
163 return parseFloat(v1) - parseFloat(v2); 175 return parseFloat(v1) - parseFloat(v2);
164 } 176 }
165 } 177 }
166 }; 178 };
167 179
168 var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; 180 var issues = {seenDataCorruption: false, filterlistsReinitialized: false};
169 updateFromURL(issues); 181 updateFromURL(issues);
170 global.seenDataCorruption = issues.seenDataCorruption; 182 global.seenDataCorruption = issues.seenDataCorruption;
171 global.filterlistsReinitialized = issues.filterlistsReinitialized; 183 global.filterlistsReinitialized = issues.filterlistsReinitialized;
172 })(this); 184 })(this);
OLDNEW
« no previous file with comments | « README.md ('k') | firstRun.html » ('j') | i18n.js » ('J')

Powered by Google App Engine
This is Rietveld