Bug 1517641 - [1.0] Add experimental ad-blocking category to the Tracking Protection API.
authorEugen Sawin <esawin@mozilla.com>
Fri, 18 Jan 2019 00:06:48 +0100
changeset 454403 c92a0281831e1c23e7b2fdb8fae5b0dc88cee7f5
parent 454402 1fc8677c25f0fc9a7e55fd82984c30653b204914
child 454404 b2ed817b75234cbc7f40355ca4e01542a618e16f
push id35396
push userebalazs@mozilla.com
push dateFri, 18 Jan 2019 09:40:42 +0000
treeherdermozilla-central@3aa256c255f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1517641
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1517641 - [1.0] Add experimental ad-blocking category to the Tracking Protection API. Differential Revision: https://phabricator.services.mozilla.com/D16700
mobile/android/geckoview/api.txt
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java
mobile/android/geckoview/src/main/java/org/mozilla/geckoview/doc-files/CHANGELOG.md
modules/libpref/init/all.js
--- a/mobile/android/geckoview/api.txt
+++ b/mobile/android/geckoview/api.txt
@@ -616,16 +616,17 @@ package org.mozilla.geckoview {
   }
 
   public static interface GeckoSession.TextInputDelegate.RestartReason implements java.lang.annotation.Annotation {
   }
 
   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;
     field public static final int CATEGORY_NONE = 0;
     field public static final int CATEGORY_SOCIAL = 4;
     field public static final int CATEGORY_TEST = 16;
   }
 
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -3811,17 +3811,17 @@ public class GeckoSession implements Par
      * GeckoSession applications implement this interface to handle tracking
      * protection events.
      **/
     public interface TrackingProtectionDelegate {
         @Retention(RetentionPolicy.SOURCE)
         @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;
         /**
          * Block advertisement trackers.
          */
         static final int CATEGORY_AD = 1 << 0;
         /**
@@ -3839,16 +3839,20 @@ public class GeckoSession implements Par
         /**
          * Block Gecko test trackers (used for tests).
          */
         static final int CATEGORY_TEST = 1 << 4;
         /**
          * 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.
          * Set blocked tracker categories via GeckoRuntimeSettings and enable
          * tracking protection via GeckoSessionSettings.
          *
         * @param session The GeckoSession that initiated the callback.
         * @param uri The URI of the blocked element.
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/TrackingProtection.java
@@ -9,16 +9,23 @@ package org.mozilla.geckoview;
 import org.mozilla.geckoview.GeckoSession.TrackingProtectionDelegate;
 
 /* package */ class TrackingProtection {
     private static final String TEST = "test-track-simple";
     private static final String AD = "ads-track-digest256";
     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();
 
         if ((categories == TrackingProtectionDelegate.CATEGORY_NONE)) {
             return "";
         }
         if ((categories & TrackingProtectionDelegate.CATEGORY_TEST) != 0) {
@@ -31,16 +38,21 @@ import org.mozilla.geckoview.GeckoSessio
             builder.append(ANALYTIC).append(',');
         }
         if ((categories & TrackingProtectionDelegate.CATEGORY_SOCIAL) != 0) {
             builder.append(SOCIAL).append(',');
         }
         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);
     }
 
     /* package */ static int listToCategory(final String list) {
         int category = 0;
         if (list.indexOf(TEST) != -1) {
             category |= TrackingProtectionDelegate.CATEGORY_TEST;
@@ -52,11 +64,17 @@ import org.mozilla.geckoview.GeckoSessio
             category |= TrackingProtectionDelegate.CATEGORY_ANALYTIC;
         }
         if (list.indexOf(SOCIAL) != -1) {
             category |= TrackingProtectionDelegate.CATEGORY_SOCIAL;
         }
         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;
     }
 }
--- 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
@@ -21,16 +21,18 @@ description: GeckoView API Changelog.
 [66.3]: ../GeckoSessionSettings.html
 
 - Added GeckoRuntimeSetting for enabling desktop viewport. Desktop viewport is
   no longer set by `USER_AGENT_MODE_DESKTOP` and must be set separately.
 
 - 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]
 
 [65.1]: ../CompositorController.html
 [65.2]: ../DynamicToolbarAnimator.html
 [65.3]: ../OverscrollEdgeEffect.html
 [65.4]: ../PanZoomController.html
@@ -108,9 +110,9 @@ description: GeckoView API Changelog.
 [65.23]: ../GeckoSession.FinderResult.html
 
 - Update [`CrashReporter#sendCrashReport`][65.24] to return the crash ID as a
   [`GeckoResult<String>`][65.25].
 
 [65.24]: ../CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
 [65.25]: ../GeckoResult.html
 
-[api-version]: e7a6a3ed65c75f7cb278b693adfa09cae5238ca2
+[api-version]: 45d1d8774e913a3077d7c489274184fd301f14fc
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5566,17 +5566,17 @@ pref("urlclassifier.trackingTable", "tes
 pref("urlclassifier.trackingWhitelistTable", "test-trackwhite-simple,mozstd-trackwhite-digest256");
 
 pref("urlclassifier.features.fingerprinting.blacklistTables", "");
 pref("urlclassifier.features.fingerprinting.whitelistTables", "");
 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);
 
 // Gethash timeout for Safe Browsing
 pref("urlclassifier.gethash.timeout_ms", 5000);
 // Update server response timeout for Safe Browsing
 pref("urlclassifier.update.response_timeout_ms", 30000);
@@ -5635,17 +5635,17 @@ pref("browser.safebrowsing.provider.goog
 pref("browser.safebrowsing.provider.google4.advisoryName", "Google Safe Browsing");
 pref("browser.safebrowsing.provider.google4.dataSharingURL", "https://safebrowsing.googleapis.com/v4/threatHits?$ct=application/x-protobuf&key=%GOOGLE_API_KEY%&$httpMethod=POST");
 pref("browser.safebrowsing.provider.google4.dataSharing.enabled", false);
 
 pref("browser.safebrowsing.reportPhishURL", "https://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%&url=");
 
 // 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.
 pref("browser.safebrowsing.provider.mozilla.nextupdatetime", "1");
 // Block lists for tracking protection. The name values will be used as the keys
 // to lookup the localized name in preferences.properties.
 pref("browser.safebrowsing.provider.mozilla.lists.base", "moz-std");
 pref("browser.safebrowsing.provider.mozilla.lists.content", "moz-full");