OLD | NEW |
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 import android.net.Uri; | 51 import android.net.Uri; |
52 import android.os.Build; | 52 import android.os.Build; |
53 import android.preference.PreferenceManager; | 53 import android.preference.PreferenceManager; |
54 import android.provider.Settings; | 54 import android.provider.Settings; |
55 import android.util.Log; | 55 import android.util.Log; |
56 | 56 |
57 public class AdblockPlus extends Application | 57 public class AdblockPlus extends Application |
58 { | 58 { |
59 private static final String TAG = Utils.getTag(AdblockPlus.class); | 59 private static final String TAG = Utils.getTag(AdblockPlus.class); |
60 | 60 |
61 private static final Pattern RE_JS = Pattern.compile(".*\\.js$", Pattern.CASE_
INSENSITIVE); | 61 private static final Pattern RE_JS = Pattern.compile("\\.js$", Pattern.CASE_IN
SENSITIVE); |
62 private static final Pattern RE_CSS = Pattern.compile(".*\\.css$", Pattern.CAS
E_INSENSITIVE); | 62 private static final Pattern RE_CSS = Pattern.compile("\\.css$", Pattern.CASE_
INSENSITIVE); |
63 private static final Pattern RE_IMAGE = Pattern.compile(".*\\.(?:gif|png|jpe?g
|bmp|ico)$", Pattern.CASE_INSENSITIVE); | 63 private static final Pattern RE_IMAGE = Pattern.compile("\\.(?:gif|png|jpe?g|b
mp|ico)$", Pattern.CASE_INSENSITIVE); |
64 private static final Pattern RE_FONT = Pattern.compile(".*\\.(?:ttf|woff)$", P
attern.CASE_INSENSITIVE); | 64 private static final Pattern RE_FONT = Pattern.compile("\\.(?:ttf|woff)$", Pat
tern.CASE_INSENSITIVE); |
65 private static final Pattern RE_HTML = Pattern.compile(".*\\.html?$", Pattern.
CASE_INSENSITIVE); | 65 private static final Pattern RE_HTML = Pattern.compile("\\.html?$", Pattern.CA
SE_INSENSITIVE); |
66 | 66 |
67 /** | 67 /** |
68 * Update notification id. | 68 * Update notification id. |
69 */ | 69 */ |
70 public static final int UPDATE_NOTIFICATION_ID = R.string.app_name + 1; | 70 public static final int UPDATE_NOTIFICATION_ID = R.string.app_name + 1; |
71 /** | 71 /** |
72 * Broadcasted when filtering is enabled or disabled. | 72 * Broadcasted when filtering is enabled or disabled. |
73 */ | 73 */ |
74 public static final String BROADCAST_FILTERING_CHANGE = "org.adblockplus.andro
id.filtering.status"; | 74 public static final String BROADCAST_FILTERING_CHANGE = "org.adblockplus.andro
id.filtering.status"; |
75 /** | 75 /** |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 if (accept.contains("text/css")) | 371 if (accept.contains("text/css")) |
372 contentType = "STYLESHEET"; | 372 contentType = "STYLESHEET"; |
373 else if (accept.contains("image/*")) | 373 else if (accept.contains("image/*")) |
374 contentType = "IMAGE"; | 374 contentType = "IMAGE"; |
375 else if (accept.contains("text/html")) | 375 else if (accept.contains("text/html")) |
376 contentType = "SUBDOCUMENT"; | 376 contentType = "SUBDOCUMENT"; |
377 } | 377 } |
378 | 378 |
379 if (contentType == null) | 379 if (contentType == null) |
380 { | 380 { |
381 if (RE_JS.matcher(url).matches()) | 381 if (RE_JS.matcher(url).find()) |
382 contentType = "SCRIPT"; | 382 contentType = "SCRIPT"; |
383 else if (RE_CSS.matcher(url).matches()) | 383 else if (RE_CSS.matcher(url).find()) |
384 contentType = "STYLESHEET"; | 384 contentType = "STYLESHEET"; |
385 else if (RE_IMAGE.matcher(url).matches()) | 385 else if (RE_IMAGE.matcher(url).find()) |
386 contentType = "IMAGE"; | 386 contentType = "IMAGE"; |
387 else if (RE_FONT.matcher(url).matches()) | 387 else if (RE_FONT.matcher(url).find()) |
388 contentType = "FONT"; | 388 contentType = "FONT"; |
389 else if (RE_HTML.matcher(url).matches()) | 389 else if (RE_HTML.matcher(url).find()) |
390 contentType = "SUBDOCUMENT"; | 390 contentType = "SUBDOCUMENT"; |
391 } | 391 } |
392 if (contentType == null) | 392 if (contentType == null) |
393 contentType = "OTHER"; | 393 contentType = "OTHER"; |
394 | 394 |
395 final List<String> referrerChain = buildReferrerChain(referrer); | 395 final List<String> referrerChain = buildReferrerChain(referrer); |
396 Log.d("Referrer chain", fullUrl + ": " + referrerChain.toString()); | 396 Log.d("Referrer chain", fullUrl + ": " + referrerChain.toString()); |
397 final String[] referrerChainArray = referrerChain.toArray(new String[referre
rChain.size()]); | 397 final String[] referrerChainArray = referrerChain.toArray(new String[referre
rChain.size()]); |
398 return abpEngine.matches(fullUrl, contentType, referrerChainArray); | 398 return abpEngine.matches(fullUrl, contentType, referrerChainArray); |
399 } | 399 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 Log.e(TAG, e.getMessage(), e); | 536 Log.e(TAG, e.getMessage(), e); |
537 } | 537 } |
538 | 538 |
539 // Set crash handler | 539 // Set crash handler |
540 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); | 540 Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); |
541 | 541 |
542 // Initiate update check | 542 // Initiate update check |
543 scheduleUpdater(0); | 543 scheduleUpdater(0); |
544 } | 544 } |
545 } | 545 } |
OLD | NEW |