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

Side by Side Diff: src/org/adblockplus/android/AdblockPlus.java

Issue 4705284891082752: Proxy configurators (Closed)
Patch Set: Created Aug. 11, 2014, 12:36 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
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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 package org.adblockplus.android; 18 package org.adblockplus.android;
19 19
20 import java.io.BufferedReader; 20 import java.io.BufferedReader;
21 import java.io.File; 21 import java.io.File;
22 import java.io.FileNotFoundException; 22 import java.io.FileNotFoundException;
23 import java.io.IOException; 23 import java.io.IOException;
24 import java.io.InputStream; 24 import java.io.InputStream;
25 import java.io.InputStreamReader; 25 import java.io.InputStreamReader;
26 import java.util.ArrayList;
27 import java.util.Calendar; 26 import java.util.Calendar;
28 import java.util.LinkedHashMap;
29 import java.util.List; 27 import java.util.List;
30 import java.util.Map;
31 import java.util.TimeZone; 28 import java.util.TimeZone;
32 import java.util.regex.Pattern; 29 import java.util.regex.Pattern;
33 30
34 import org.adblockplus.android.updater.AlarmReceiver; 31 import org.adblockplus.android.updater.AlarmReceiver;
35 import org.apache.commons.lang.StringUtils; 32 import org.apache.commons.lang.StringUtils;
36 33
37 import android.app.ActivityManager; 34 import android.app.ActivityManager;
38 import android.app.ActivityManager.RunningServiceInfo; 35 import android.app.ActivityManager.RunningServiceInfo;
39 import android.app.AlarmManager; 36 import android.app.AlarmManager;
40 import android.app.Application; 37 import android.app.Application;
(...skipping 29 matching lines...) Expand all
70 public static final int UPDATE_NOTIFICATION_ID = R.string.app_name + 1; 67 public static final int UPDATE_NOTIFICATION_ID = R.string.app_name + 1;
71 /** 68 /**
72 * Broadcasted when filtering is enabled or disabled. 69 * Broadcasted when filtering is enabled or disabled.
73 */ 70 */
74 public static final String BROADCAST_FILTERING_CHANGE = "org.adblockplus.andro id.filtering.status"; 71 public static final String BROADCAST_FILTERING_CHANGE = "org.adblockplus.andro id.filtering.status";
75 /** 72 /**
76 * Broadcasted when subscription status changes. 73 * Broadcasted when subscription status changes.
77 */ 74 */
78 public static final String BROADCAST_SUBSCRIPTION_STATUS = "org.adblockplus.an droid.subscription.status"; 75 public static final String BROADCAST_SUBSCRIPTION_STATUS = "org.adblockplus.an droid.subscription.status";
79 /** 76 /**
80 * Broadcasted when filter match check is performed.
81 */
82 public static final String BROADCAST_FILTER_MATCHES = "org.adblockplus.android .filter.matches";
83 /**
84 * Cached list of recommended subscriptions. 77 * Cached list of recommended subscriptions.
85 */ 78 */
86 private Subscription[] subscriptions; 79 private Subscription[] subscriptions;
87 /** 80 /**
88 * Indicates whether filtering is enabled or not. 81 * Indicates whether filtering is enabled or not.
89 */ 82 */
90 private boolean filteringEnabled = false; 83 private boolean filteringEnabled = false;
91 84
92 private ABPEngine abpEngine; 85 private ABPEngine abpEngine;
93 86
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 public boolean isFirstRun() 214 public boolean isFirstRun()
222 { 215 {
223 return abpEngine.isFirstRun(); 216 return abpEngine.isFirstRun();
224 } 217 }
225 218
226 /** 219 /**
227 * Returns list of known subscriptions. 220 * Returns list of known subscriptions.
228 */ 221 */
229 public Subscription[] getRecommendedSubscriptions() 222 public Subscription[] getRecommendedSubscriptions()
230 { 223 {
231 // TODO: Why don't we re-check?
Felix Dahlke 2014/08/19 09:06:00 Any idea why we're caching recommended subscriptio
René Jeschke 2014/08/19 10:41:33 IIRC, they are fetched from a contained XML file i
232 if (subscriptions == null) 224 if (subscriptions == null)
233 subscriptions = abpEngine.getRecommendedSubscriptions(); 225 subscriptions = abpEngine.getRecommendedSubscriptions();
234 return subscriptions; 226 return subscriptions;
235 } 227 }
236 228
237 /** 229 /**
238 * Returns list of enabled subscriptions. 230 * Returns list of enabled subscriptions.
239 */ 231 */
240 public Subscription[] getListedSubscriptions() 232 public Subscription[] getListedSubscriptions()
241 { 233 {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 * Request query string 325 * Request query string
334 * @param referrer 326 * @param referrer
335 * Request referrer header 327 * Request referrer header
336 * @param accept 328 * @param accept
337 * Request accept header 329 * Request accept header
338 * @return true if matched filter was found 330 * @return true if matched filter was found
339 * @throws Exception 331 * @throws Exception
340 */ 332 */
341 public boolean matches(final String url, final String query, final String refe rrer, final String accept) 333 public boolean matches(final String url, final String query, final String refe rrer, final String accept)
342 { 334 {
343 final String fullUrl = !"".equals(query) ? url + "?" + query : url; 335 final String fullUrl = StringUtils.isNotEmpty(query) ? url + "?" + query : u rl;
344 if (referrer != null) 336 if (referrer != null)
345 referrerMapping.add(fullUrl, referrer); 337 referrerMapping.add(fullUrl, referrer);
346 338
347 if (!filteringEnabled) 339 if (!filteringEnabled)
348 return false; 340 return false;
349 341
350 String contentType = null; 342 String contentType = null;
351 343
352 if (accept != null) 344 if (accept != null)
353 { 345 {
(...skipping 15 matching lines...) Expand all
369 contentType = "IMAGE"; 361 contentType = "IMAGE";
370 else if (RE_FONT.matcher(url).find()) 362 else if (RE_FONT.matcher(url).find())
371 contentType = "FONT"; 363 contentType = "FONT";
372 else if (RE_HTML.matcher(url).find()) 364 else if (RE_HTML.matcher(url).find())
373 contentType = "SUBDOCUMENT"; 365 contentType = "SUBDOCUMENT";
374 } 366 }
375 if (contentType == null) 367 if (contentType == null)
376 contentType = "OTHER"; 368 contentType = "OTHER";
377 369
378 final List<String> referrerChain = referrerMapping.buildReferrerChain(referr er); 370 final List<String> referrerChain = referrerMapping.buildReferrerChain(referr er);
379 Log.d("Referrer chain", fullUrl + ": " + referrerChain.toString()); 371 // Currently disabled, we need some more control over what we log
372 // Log.d("Referrer chain", fullUrl + ": " + referrerChain.toString());
Felix Dahlke 2014/08/19 09:06:00 Just remove it, that's fine.
René Jeschke 2014/08/19 10:41:33 Done.
380 final String[] referrerChainArray = referrerChain.toArray(new String[referre rChain.size()]); 373 final String[] referrerChainArray = referrerChain.toArray(new String[referre rChain.size()]);
381 return abpEngine.matches(fullUrl, contentType, referrerChainArray); 374 return abpEngine.matches(fullUrl, contentType, referrerChainArray);
382 } 375 }
383 376
384 /** 377 /**
385 * Checks if filtering is enabled. 378 * Checks if filtering is enabled.
386 */ 379 */
387 public boolean isFilteringEnabled() 380 public boolean isFilteringEnabled()
388 { 381 {
389 return filteringEnabled; 382 return filteringEnabled;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 Log.e(TAG, e.getMessage(), e); 498 Log.e(TAG, e.getMessage(), e);
506 } 499 }
507 500
508 // Set crash handler 501 // Set crash handler
509 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); 502 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this));
510 503
511 // Initiate update check 504 // Initiate update check
512 scheduleUpdater(0); 505 scheduleUpdater(0);
513 } 506 }
514 } 507 }
OLDNEW

Powered by Google App Engine
This is Rietveld