OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 12 matching lines...) Expand all Loading... |
23 import java.util.HashSet; | 23 import java.util.HashSet; |
24 import java.util.List; | 24 import java.util.List; |
25 import java.util.Locale; | 25 import java.util.Locale; |
26 import java.util.Set; | 26 import java.util.Set; |
27 | 27 |
28 import org.adblockplus.libadblockplus.AppInfo; | 28 import org.adblockplus.libadblockplus.AppInfo; |
29 import org.adblockplus.libadblockplus.Filter; | 29 import org.adblockplus.libadblockplus.Filter; |
30 import org.adblockplus.libadblockplus.FilterChangeCallback; | 30 import org.adblockplus.libadblockplus.FilterChangeCallback; |
31 import org.adblockplus.libadblockplus.FilterEngine; | 31 import org.adblockplus.libadblockplus.FilterEngine; |
32 import org.adblockplus.libadblockplus.FilterEngine.ContentType; | 32 import org.adblockplus.libadblockplus.FilterEngine.ContentType; |
| 33 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback; |
33 import org.adblockplus.libadblockplus.JsEngine; | 34 import org.adblockplus.libadblockplus.JsEngine; |
34 import org.adblockplus.libadblockplus.LogSystem; | 35 import org.adblockplus.libadblockplus.LogSystem; |
35 import org.adblockplus.libadblockplus.ShowNotificationCallback; | 36 import org.adblockplus.libadblockplus.ShowNotificationCallback; |
36 import org.adblockplus.libadblockplus.Subscription; | 37 import org.adblockplus.libadblockplus.Subscription; |
37 import org.adblockplus.libadblockplus.UpdateAvailableCallback; | 38 import org.adblockplus.libadblockplus.UpdateAvailableCallback; |
38 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 39 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
39 | 40 |
40 import android.content.Context; | 41 import android.content.Context; |
41 import android.content.pm.PackageInfo; | 42 import android.content.pm.PackageInfo; |
42 import android.content.pm.PackageManager.NameNotFoundException; | 43 import android.content.pm.PackageManager.NameNotFoundException; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return AppInfo.builder() | 96 return AppInfo.builder() |
96 .setVersion(version) | 97 .setVersion(version) |
97 .setApplicationVersion(sdkVersion) | 98 .setApplicationVersion(sdkVersion) |
98 .setLocale(locale) | 99 .setLocale(locale) |
99 .setDevelopmentBuild(developmentBuild) | 100 .setDevelopmentBuild(developmentBuild) |
100 .build(); | 101 .build(); |
101 } | 102 } |
102 | 103 |
103 public static AdblockEngine create(final AppInfo appInfo, | 104 public static AdblockEngine create(final AppInfo appInfo, |
104 final String basePath, boolean enableElemhi
de, | 105 final String basePath, boolean enableElemhi
de, |
| 106 IsAllowedConnectionCallback isAllowedConnec
tionCallback, |
105 UpdateAvailableCallback updateAvailableCall
back, | 107 UpdateAvailableCallback updateAvailableCall
back, |
106 UpdateCheckDoneCallback updateCheckDoneCall
back, | 108 UpdateCheckDoneCallback updateCheckDoneCall
back, |
107 ShowNotificationCallback showNotificationCa
llback, | 109 ShowNotificationCallback showNotificationCa
llback, |
108 FilterChangeCallback filterChangeCallback) | 110 FilterChangeCallback filterChangeCallback) |
109 { | 111 { |
110 Log.w(TAG, "Create"); | 112 Log.w(TAG, "Create"); |
111 | 113 |
112 final AdblockEngine engine = new AdblockEngine(enableElemhide); | 114 final AdblockEngine engine = new AdblockEngine(enableElemhide); |
113 | 115 |
114 engine.jsEngine = new JsEngine(appInfo); | 116 engine.jsEngine = new JsEngine(appInfo); |
115 engine.jsEngine.setDefaultFileSystem(basePath); | 117 engine.jsEngine.setDefaultFileSystem(basePath); |
116 | 118 |
117 engine.logSystem = new AndroidLogSystem(); | 119 engine.logSystem = new AndroidLogSystem(); |
118 engine.jsEngine.setLogSystem(engine.logSystem); | 120 engine.jsEngine.setLogSystem(engine.logSystem); |
119 | 121 |
120 engine.webRequest = new AndroidWebRequest(enableElemhide); | 122 engine.webRequest = new AndroidWebRequest(enableElemhide); |
121 engine.jsEngine.setWebRequest(engine.webRequest); | 123 engine.jsEngine.setWebRequest(engine.webRequest); |
122 | 124 |
123 engine.filterEngine = new FilterEngine(engine.jsEngine); | 125 engine.filterEngine = new FilterEngine(engine.jsEngine, isAllowedConnectionC
allback); |
124 | 126 |
125 engine.updateAvailableCallback = updateAvailableCallback; | 127 engine.updateAvailableCallback = updateAvailableCallback; |
126 if (engine.updateAvailableCallback != null) | 128 if (engine.updateAvailableCallback != null) |
127 { | 129 { |
128 engine.filterEngine.setUpdateAvailableCallback(updateAvailableCallback); | 130 engine.filterEngine.setUpdateAvailableCallback(updateAvailableCallback); |
129 } | 131 } |
130 | 132 |
131 engine.updateCheckDoneCallback = updateCheckDoneCallback; | 133 engine.updateCheckDoneCallback = updateCheckDoneCallback; |
132 | 134 |
133 engine.showNotificationCallback = showNotificationCallback; | 135 engine.showNotificationCallback = showNotificationCallback; |
134 if (engine.showNotificationCallback != null) | 136 if (engine.showNotificationCallback != null) |
135 { | 137 { |
136 engine.filterEngine.setShowNotificationCallback(showNotificationCallback); | 138 engine.filterEngine.setShowNotificationCallback(showNotificationCallback); |
137 } | 139 } |
138 | 140 |
139 engine.filterChangeCallback = filterChangeCallback; | 141 engine.filterChangeCallback = filterChangeCallback; |
140 if (engine.filterChangeCallback != null) | 142 if (engine.filterChangeCallback != null) |
141 { | 143 { |
142 engine.filterEngine.setFilterChangeCallback(filterChangeCallback); | 144 engine.filterEngine.setFilterChangeCallback(filterChangeCallback); |
143 } | 145 } |
144 | 146 |
145 engine.webRequest.updateSubscriptionURLs(engine.filterEngine); | 147 engine.webRequest.updateSubscriptionURLs(engine.filterEngine); |
146 | 148 |
147 return engine; | 149 return engine; |
148 } | 150 } |
149 | 151 |
150 public static AdblockEngine create(final AppInfo appInfo, | 152 public static AdblockEngine create(final AppInfo appInfo, |
151 final String basePath, boolean elemhideEnab
led) | 153 final String basePath, |
| 154 boolean elemhideEnabled, |
| 155 IsAllowedConnectionCallback isAllowedConnec
tionCallback) |
152 { | 156 { |
153 return create(appInfo, basePath, elemhideEnabled, null, null, null, null); | 157 return create(appInfo, basePath, elemhideEnabled, isAllowedConnectionCallbac
k, null, null, null, null); |
154 } | 158 } |
155 | 159 |
156 public void dispose() | 160 public void dispose() |
157 { | 161 { |
158 Log.w(TAG, "Dispose"); | 162 Log.w(TAG, "Dispose"); |
159 | 163 |
160 if (this.logSystem != null) | 164 if (this.logSystem != null) |
161 { | 165 { |
162 this.logSystem.dispose(); | 166 this.logSystem.dispose(); |
163 this.logSystem = null; | 167 this.logSystem = null; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 public void setWhitelistedDomains(List<String> domains) | 468 public void setWhitelistedDomains(List<String> domains) |
465 { | 469 { |
466 this.whitelistedDomains = domains; | 470 this.whitelistedDomains = domains; |
467 } | 471 } |
468 | 472 |
469 public List<String> getWhitelistedDomains() | 473 public List<String> getWhitelistedDomains() |
470 { | 474 { |
471 return whitelistedDomains; | 475 return whitelistedDomains; |
472 } | 476 } |
473 } | 477 } |
OLD | NEW |