Left: | ||
Right: |
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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 | 52 |
53 private Context context; | 53 private Context context; |
54 private String basePath; | 54 private String basePath; |
55 private boolean developmentBuild; | 55 private boolean developmentBuild; |
56 private String settingsPreferenceName; | 56 private String settingsPreferenceName; |
57 private String preloadedPreferenceName; | 57 private String preloadedPreferenceName; |
58 private Map<String, Integer> urlToResourceIdMap; | 58 private Map<String, Integer> urlToResourceIdMap; |
59 private AdblockEngine engine; | 59 private AdblockEngine engine; |
60 private AdblockSettingsStorage storage; | 60 private AdblockSettingsStorage storage; |
61 private CountDownLatch engineCreated; | 61 private CountDownLatch engineCreated; |
62 private Long v8IsolatePtr; | 62 private Long v8IsolateProviderPtr; |
63 | 63 |
64 /* | 64 /* |
65 Simple ARC management for AdblockEngine | 65 Simple ARC management for AdblockEngine |
66 Use `retain` and `release` | 66 Use `retain` and `release` |
67 */ | 67 */ |
68 | 68 |
69 private AtomicInteger referenceCounter = new AtomicInteger(0); | 69 private AtomicInteger referenceCounter = new AtomicInteger(0); |
70 | 70 |
71 // singleton | 71 // singleton |
72 protected AdblockHelper() | 72 protected AdblockHelper() |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 * @param preferenceName Shared Preferences name to store intercepted requests stats | 125 * @param preferenceName Shared Preferences name to store intercepted requests stats |
126 * @param urlToResourceIdMap | 126 * @param urlToResourceIdMap |
127 */ | 127 */ |
128 public AdblockHelper preloadSubscriptions(String preferenceName, Map<String, I nteger> urlToResourceIdMap) | 128 public AdblockHelper preloadSubscriptions(String preferenceName, Map<String, I nteger> urlToResourceIdMap) |
129 { | 129 { |
130 this.preloadedPreferenceName = preferenceName; | 130 this.preloadedPreferenceName = preferenceName; |
131 this.urlToResourceIdMap = urlToResourceIdMap; | 131 this.urlToResourceIdMap = urlToResourceIdMap; |
132 return this; | 132 return this; |
133 } | 133 } |
134 | 134 |
135 public void useV8Isolate(long ptr) | 135 public AdblockHelper useV8IsolateProvider(long ptr) |
136 { | 136 { |
137 this.v8IsolatePtr = ptr; | 137 this.v8IsolateProviderPtr = ptr; |
138 return this; | |
sergei
2017/11/07 09:58:45
Changing of the return value is an unrelated chang
anton
2017/11/07 10:17:05
Agree it's unrelated in general.
Just want to keep
| |
138 } | 139 } |
139 | 140 |
140 private void createAdblock() | 141 private void createAdblock() |
141 { | 142 { |
142 ConnectivityManager connectivityManager = | 143 ConnectivityManager connectivityManager = |
143 (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVIC E); | 144 (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVIC E); |
144 IsAllowedConnectionCallback isAllowedConnectionCallback = new IsAllowedConne ctionCallbackImpl(connectivityManager); | 145 IsAllowedConnectionCallback isAllowedConnectionCallback = new IsAllowedConne ctionCallbackImpl(connectivityManager); |
145 | 146 |
146 Log.d(TAG, "Creating adblock engine ..."); | 147 Log.d(TAG, "Creating adblock engine ..."); |
147 | 148 |
148 // read and apply current settings | 149 // read and apply current settings |
149 SharedPreferences settingsPrefs = context.getSharedPreferences( | 150 SharedPreferences settingsPrefs = context.getSharedPreferences( |
150 settingsPreferenceName, | 151 settingsPreferenceName, |
151 Context.MODE_PRIVATE); | 152 Context.MODE_PRIVATE); |
152 storage = new SharedPrefsStorage(settingsPrefs); | 153 storage = new SharedPrefsStorage(settingsPrefs); |
153 | 154 |
154 AdblockEngine.Builder builder = AdblockEngine | 155 AdblockEngine.Builder builder = AdblockEngine |
155 .builder( | 156 .builder( |
156 AdblockEngine.generateAppInfo(context, developmentBuild), | 157 AdblockEngine.generateAppInfo(context, developmentBuild), |
157 basePath) | 158 basePath) |
158 .setIsAllowedConnectionCallback(isAllowedConnectionCallback) | 159 .setIsAllowedConnectionCallback(isAllowedConnectionCallback) |
159 .enableElementHiding(true); | 160 .enableElementHiding(true); |
160 | 161 |
161 if (v8IsolatePtr != null) | 162 if (v8IsolateProviderPtr != null) |
162 { | 163 { |
163 builder.useV8Isolate(v8IsolatePtr); | 164 builder.useV8IsolateProvider(v8IsolateProviderPtr); |
164 } | 165 } |
165 | 166 |
166 // if preloaded subscriptions provided | 167 // if preloaded subscriptions provided |
167 if (preloadedPreferenceName != null) | 168 if (preloadedPreferenceName != null) |
168 { | 169 { |
169 SharedPreferences preloadedSubscriptionsPrefs = context.getSharedPreferenc es( | 170 SharedPreferences preloadedSubscriptionsPrefs = context.getSharedPreferenc es( |
170 preloadedPreferenceName, | 171 preloadedPreferenceName, |
171 Context.MODE_PRIVATE); | 172 Context.MODE_PRIVATE); |
172 builder.preloadSubscriptions( | 173 builder.preloadSubscriptions( |
173 context, | 174 context, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 engineCreated = null; | 309 engineCreated = null; |
309 } | 310 } |
310 else | 311 else |
311 { | 312 { |
312 disposeAdblock(); | 313 disposeAdblock(); |
313 } | 314 } |
314 } | 315 } |
315 return lastInstance; | 316 return lastInstance; |
316 } | 317 } |
317 } | 318 } |
OLD | NEW |