diff --git a/mobile/android/geckoview/api.txt b/mobile/android/geckoview/api.txt index 71e4282a00dd..e2a748916274 100644 --- a/mobile/android/geckoview/api.txt +++ b/mobile/android/geckoview/api.txt @@ -621,6 +621,7 @@ package org.mozilla.geckoview { public static interface GeckoSession.TrackingProtectionDelegate { method @android.support.annotation.UiThread public void onTrackerBlocked(@android.support.annotation.NonNull org.mozilla.geckoview.GeckoSession, @android.support.annotation.Nullable java.lang.String, int); field public static final int CATEGORY_AD = 1; + field public static final int CATEGORY_AD_EXT = 64; field public static final int CATEGORY_ALL = 31; field public static final int CATEGORY_ANALYTIC = 2; field public static final int CATEGORY_CONTENT = 8; diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java index 950cfa0fc15b..0dc134ebd86b 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java @@ -3816,7 +3816,7 @@ public class GeckoSession implements Parcelable { @IntDef(flag = true, value = { CATEGORY_NONE, CATEGORY_AD, CATEGORY_ANALYTIC, CATEGORY_SOCIAL, CATEGORY_CONTENT, CATEGORY_ALL, - CATEGORY_TEST }) + CATEGORY_TEST, CATEGORY_AD_EXT }) /* package */ @interface Category {} static final int CATEGORY_NONE = 0; @@ -3844,6 +3844,10 @@ public class GeckoSession implements Parcelable { * Block all known trackers. */ static final int CATEGORY_ALL = (1 << 5) - 1; + /** + * Experimental: Block advertisements. + */ + static final int CATEGORY_AD_EXT = 1 << 6; /** * A tracking element has been blocked from loading. diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java index 9ab5bb4f1caa..527b44b5de89 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java @@ -14,6 +14,13 @@ import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate; private static final String ANALYTIC = "analytics-track-digest256"; private static final String SOCIAL = "social-track-digest256"; private static final String CONTENT = "content-track-digest256"; + private static final String[] AD_EXT = new String[] { + "fanboy-annoyance-digest256", + "fanboy-social-digest256", + "easylist-digest25", + "easyprivacy-digest25", + "adguard-digest25" + }; /* package */ static String buildPrefValue(int categories) { StringBuilder builder = new StringBuilder(); @@ -36,6 +43,11 @@ import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate; if ((categories & TrackingProtectionDelegate.CATEGORY_CONTENT) != 0) { builder.append(CONTENT).append(','); } + if ((categories & TrackingProtectionDelegate.CATEGORY_AD_EXT) != 0) { + for (final String l: AD_EXT) { + builder.append(l).append(','); + } + } // Trim final ','. return builder.substring(0, builder.length() - 1); } @@ -57,6 +69,12 @@ import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate; if (list.indexOf(CONTENT) != -1) { category |= TrackingProtectionDelegate.CATEGORY_CONTENT; } + for (final String l: AD_EXT) { + if (list.indexOf(l) != -1) { + category |= TrackingProtectionDelegate.CATEGORY_AD_EXT; + break; + } + } return category; } } diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md index bbd5e20f8fce..007614408144 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md @@ -26,6 +26,8 @@ description: GeckoView API Changelog. - Added `@UiThread` to `GeckoSession.releaseSession` and `GeckoSession.setSession` ## v65 +- Added experimental ad-blocking category to `GeckoSession.TrackingProtectionDelegate`. + - Moved [`CompositorController`][65.1], [`DynamicToolbarAnimator`][65.2], [`OverscrollEdgeEffect`][65.3], [`PanZoomController`][65.4] from `org.mozilla.gecko.gfx` to [`org.mozilla.geckoview`][65.5] @@ -113,4 +115,4 @@ description: GeckoView API Changelog. [65.24]: ../CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String- [65.25]: ../GeckoResult.html -[api-version]: e7a6a3ed65c75f7cb278b693adfa09cae5238ca2 +[api-version]: 45d1d8774e913a3077d7c489274184fd301f14fc diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 0daed929a730..d986fc07b5c7 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -5571,7 +5571,7 @@ pref("urlclassifier.features.cryptomining.blacklistTables", ""); pref("urlclassifier.features.cryptomining.whitelistTables", ""); // These tables will never trigger a gethash call. -pref("urlclassifier.disallow_completions", "test-malware-simple,test-harmful-simple,test-phish-simple,test-unwanted-simple,test-track-simple,test-trackwhite-simple,test-block-simple,goog-downloadwhite-digest256,base-track-digest256,mozstd-trackwhite-digest256,content-track-digest256,mozplugin-block-digest256,mozplugin2-block-digest256,block-flash-digest256,except-flash-digest256,allow-flashallow-digest256,except-flashallow-digest256,block-flashsubdoc-digest256,except-flashsubdoc-digest256,goog-passwordwhite-proto,ads-track-digest256,social-track-digest256,analytics-track-digest256,base-fingerprinting-track-digest256,content-fingerprinting-track-digest256,base-cryptomining-track-digest256,content-cryptomining-track-digest256"); +pref("urlclassifier.disallow_completions", "test-malware-simple,test-harmful-simple,test-phish-simple,test-unwanted-simple,test-track-simple,test-trackwhite-simple,test-block-simple,goog-downloadwhite-digest256,base-track-digest256,mozstd-trackwhite-digest256,content-track-digest256,mozplugin-block-digest256,mozplugin2-block-digest256,block-flash-digest256,except-flash-digest256,allow-flashallow-digest256,except-flashallow-digest256,block-flashsubdoc-digest256,except-flashsubdoc-digest256,goog-passwordwhite-proto,ads-track-digest256,social-track-digest256,analytics-track-digest256,base-fingerprinting-track-digest256,content-fingerprinting-track-digest256,base-cryptomining-track-digest256,content-cryptomining-track-digest256,fanboy-annoyance-digest256,fanboy-social-digest256,easylist-digest256,easyprivacy-digest256,adguard-digest256"); // Number of random entries to send with a gethash request pref("urlclassifier.gethashnoise", 4); @@ -5640,7 +5640,7 @@ pref("browser.safebrowsing.reportPhishURL", "https://%LOCALE%.phish-report.mozil // Mozilla Safe Browsing provider (for tracking protection and plugin blocking) pref("browser.safebrowsing.provider.mozilla.pver", "2.2"); -pref("browser.safebrowsing.provider.mozilla.lists", "base-track-digest256,mozstd-trackwhite-digest256,content-track-digest256,mozplugin-block-digest256,mozplugin2-block-digest256,block-flash-digest256,except-flash-digest256,allow-flashallow-digest256,except-flashallow-digest256,block-flashsubdoc-digest256,except-flashsubdoc-digest256,ads-track-digest256,social-track-digest256,analytics-track-digest256,base-fingerprinting-track-digest256,content-fingerprinting-track-digest256,base-cryptomining-track-digest256,content-cryptomining-track-digest256"); +pref("browser.safebrowsing.provider.mozilla.lists", "base-track-digest256,mozstd-trackwhite-digest256,content-track-digest256,mozplugin-block-digest256,mozplugin2-block-digest256,block-flash-digest256,except-flash-digest256,allow-flashallow-digest256,except-flashallow-digest256,block-flashsubdoc-digest256,except-flashsubdoc-digest256,ads-track-digest256,social-track-digest256,analytics-track-digest256,base-fingerprinting-track-digest256,content-fingerprinting-track-digest256,base-cryptomining-track-digest256,content-cryptomining-track-digest256,fanboy-annoyance-digest256,fanboy-social-digest256,easylist-digest256,easyprivacy-digest256,adguard-digest256"); pref("browser.safebrowsing.provider.mozilla.updateURL", "https://shavar.services.mozilla.com/downloads?client=SAFEBROWSING_ID&appver=%MAJOR_VERSION%&pver=2.2"); pref("browser.safebrowsing.provider.mozilla.gethashURL", "https://shavar.services.mozilla.com/gethash?client=SAFEBROWSING_ID&appver=%MAJOR_VERSION%&pver=2.2"); // Set to a date in the past to force immediate download in new profiles.