| 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 11 matching lines...) Expand all  Loading... | 
|   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.Calendar; |   26 import java.util.Calendar; | 
|   27 import java.util.List; |   27 import java.util.List; | 
|   28 import java.util.TimeZone; |   28 import java.util.TimeZone; | 
|   29 import java.util.regex.Pattern; |   29 import java.util.regex.Pattern; | 
|   30  |   30  | 
|   31 import org.adblockplus.android.updater.AlarmReceiver; |   31 import org.adblockplus.android.updater.AlarmReceiver; | 
 |   32 import org.adblockplus.libadblockplus.FilterEngine.ContentType; | 
|   32 import org.apache.commons.lang.StringUtils; |   33 import org.apache.commons.lang.StringUtils; | 
|   33  |   34  | 
|   34 import android.app.ActivityManager; |   35 import android.app.ActivityManager; | 
|   35 import android.app.ActivityManager.RunningServiceInfo; |   36 import android.app.ActivityManager.RunningServiceInfo; | 
|   36 import android.app.AlarmManager; |   37 import android.app.AlarmManager; | 
|   37 import android.app.Application; |   38 import android.app.Application; | 
|   38 import android.app.PendingIntent; |   39 import android.app.PendingIntent; | 
|   39 import android.content.Context; |   40 import android.content.Context; | 
|   40 import android.content.Intent; |   41 import android.content.Intent; | 
|   41 import android.content.SharedPreferences; |   42 import android.content.SharedPreferences; | 
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  332    */ |  333    */ | 
|  333   public boolean matches(final String url, final String query, final String refe
     rrer, final String accept) |  334   public boolean matches(final String url, final String query, final String refe
     rrer, final String accept) | 
|  334   { |  335   { | 
|  335     final String fullUrl = StringUtils.isNotEmpty(query) ? url + "?" + query : u
     rl; |  336     final String fullUrl = StringUtils.isNotEmpty(query) ? url + "?" + query : u
     rl; | 
|  336     if (referrer != null) |  337     if (referrer != null) | 
|  337       referrerMapping.add(fullUrl, referrer); |  338       referrerMapping.add(fullUrl, referrer); | 
|  338  |  339  | 
|  339     if (!filteringEnabled) |  340     if (!filteringEnabled) | 
|  340       return false; |  341       return false; | 
|  341  |  342  | 
|  342     String contentType = null; |  343     ContentType contentType = null; | 
|  343  |  344  | 
|  344     if (accept != null) |  345     if (accept != null) | 
|  345     { |  346     { | 
|  346       if (accept.contains("text/css")) |  347       if (accept.contains("text/css")) | 
|  347         contentType = "STYLESHEET"; |  348         contentType = ContentType.STYLESHEET; | 
|  348       else if (accept.contains("image/*")) |  349       else if (accept.contains("image/*")) | 
|  349         contentType = "IMAGE"; |  350         contentType = ContentType.IMAGE; | 
|  350       else if (accept.contains("text/html")) |  351       else if (accept.contains("text/html")) | 
|  351         contentType = "SUBDOCUMENT"; |  352         contentType = ContentType.SUBDOCUMENT; | 
|  352     } |  353     } | 
|  353  |  354  | 
|  354     if (contentType == null) |  355     if (contentType == null) | 
|  355     { |  356     { | 
|  356       if (RE_JS.matcher(url).find()) |  357       if (RE_JS.matcher(url).find()) | 
|  357         contentType = "SCRIPT"; |  358         contentType = ContentType.SCRIPT; | 
|  358       else if (RE_CSS.matcher(url).find()) |  359       else if (RE_CSS.matcher(url).find()) | 
|  359         contentType = "STYLESHEET"; |  360         contentType = ContentType.STYLESHEET; | 
|  360       else if (RE_IMAGE.matcher(url).find()) |  361       else if (RE_IMAGE.matcher(url).find()) | 
|  361         contentType = "IMAGE"; |  362         contentType = ContentType.IMAGE; | 
|  362       else if (RE_FONT.matcher(url).find()) |  363       else if (RE_FONT.matcher(url).find()) | 
|  363         contentType = "FONT"; |  364         contentType = ContentType.FONT; | 
|  364       else if (RE_HTML.matcher(url).find()) |  365       else if (RE_HTML.matcher(url).find()) | 
|  365         contentType = "SUBDOCUMENT"; |  366         contentType = ContentType.SUBDOCUMENT; | 
|  366     } |  367     } | 
|  367     if (contentType == null) |  368     if (contentType == null) | 
|  368       contentType = "OTHER"; |  369       contentType = ContentType.OTHER; | 
|  369  |  370  | 
|  370     final List<String> referrerChain = referrerMapping.buildReferrerChain(referr
     er); |  371     final List<String> referrerChain = referrerMapping.buildReferrerChain(referr
     er); | 
|  371     final String[] referrerChainArray = referrerChain.toArray(new String[referre
     rChain.size()]); |  372     final String[] referrerChainArray = referrerChain.toArray(new String[referre
     rChain.size()]); | 
|  372     return abpEngine.matches(fullUrl, contentType, referrerChainArray); |  373     return abpEngine.matches(fullUrl, contentType, referrerChainArray); | 
|  373   } |  374   } | 
|  374  |  375  | 
|  375   /** |  376   /** | 
|  376    * Checks if filtering is enabled. |  377    * Checks if filtering is enabled. | 
|  377    */ |  378    */ | 
|  378   public boolean isFilteringEnabled() |  379   public boolean isFilteringEnabled() | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  496       Log.e(TAG, e.getMessage(), e); |  497       Log.e(TAG, e.getMessage(), e); | 
|  497     } |  498     } | 
|  498  |  499  | 
|  499     // Set crash handler |  500     // Set crash handler | 
|  500     Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); |  501     Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this)); | 
|  501  |  502  | 
|  502     // Initiate update check |  503     // Initiate update check | 
|  503     scheduleUpdater(0); |  504     scheduleUpdater(0); | 
|  504   } |  505   } | 
|  505 } |  506 } | 
| OLD | NEW |