Bug 1530050 - [1.0] Add recommended and strict content blocking categories selections for safer app defaults. r=snorp,geckoview-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D24967

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eugen Sawin 2019-03-27 14:39:11 +00:00
Родитель d605b47da3
Коммит b185068750
4 изменённых файлов: 43 добавлений и 11 удалений

Просмотреть файл

@ -43,12 +43,15 @@ package org.mozilla.geckoview {
@android.support.annotation.AnyThread public class ContentBlocking {
ctor public ContentBlocking();
field public static final int AT_AD = 2;
field public static final int AT_ALL = 126;
field public static final int AT_ANALYTIC = 4;
field public static final int AT_CONTENT = 16;
field public static final int AT_CRYPTOMINING = 64;
field public static final int AT_DEFAULT = 46;
field public static final int AT_SOCIAL = 8;
field public static final int AT_STRICT = 126;
field public static final int AT_TEST = 32;
field public static final int CB_DEFAULT = 15406;
field public static final int CB_STRICT = 15486;
field public static final int COOKIE_ACCEPT_ALL = 0;
field public static final int COOKIE_ACCEPT_FIRST_PARTY = 1;
field public static final int COOKIE_ACCEPT_NONE = 2;

Просмотреть файл

@ -73,8 +73,7 @@ public class ContentBlocking {
/* package */ final Pref<String> mAt = new Pref<String>(
"urlclassifier.trackingTable",
ContentBlocking.catToAtPref(
AT_TEST | AT_ANALYTIC | AT_SOCIAL | AT_AD));
ContentBlocking.catToAtPref(AT_DEFAULT));
/* package */ final Pref<Boolean> mCm = new Pref<Boolean>(
"privacy.trackingprotection.cryptomining.enabled", false);
/* package */ final Pref<String> mCmList = new Pref<String>(
@ -206,9 +205,10 @@ public class ContentBlocking {
@Retention(RetentionPolicy.SOURCE)
@IntDef(flag = true,
value = { NONE, AT_AD, AT_ANALYTIC, AT_SOCIAL, AT_CONTENT,
AT_ALL, AT_TEST, AT_CRYPTOMINING,
AT_TEST, AT_CRYPTOMINING, AT_DEFAULT, AT_STRICT,
SB_MALWARE, SB_UNWANTED,
SB_HARMFUL, SB_PHISHING })
SB_HARMFUL, SB_PHISHING,
CB_DEFAULT, CB_STRICT })
/* package */ @interface Category {}
public static final int NONE = 0;
@ -231,6 +231,7 @@ public class ContentBlocking {
/**
* Block content trackers.
* May cause issues with some web sites.
*/
public static final int AT_CONTENT = 1 << 4;
@ -245,11 +246,17 @@ public class ContentBlocking {
public static final int AT_CRYPTOMINING = 1 << 6;
/**
* Block all known trackers.
* Blocks all {@link #AT_AD AT_*} types.
* Block ad, analytic, social and test trackers.
*/
public static final int AT_ALL =
AT_AD | AT_ANALYTIC | AT_SOCIAL | AT_CONTENT | AT_TEST | AT_CRYPTOMINING;
public static final int AT_DEFAULT =
AT_AD | AT_ANALYTIC | AT_SOCIAL | AT_TEST;
/**
* Block all known trackers.
* May cause issues with some web sites.
*/
public static final int AT_STRICT =
AT_DEFAULT | AT_CONTENT | AT_CRYPTOMINING;
// Safe browsing
/**
@ -279,6 +286,19 @@ public class ContentBlocking {
public static final int SB_ALL =
SB_MALWARE | SB_UNWANTED | SB_HARMFUL | SB_PHISHING;
/**
* Recommended content blocking categories.
* A combination of {@link #AT_DEFAULT} and {@link #SB_ALL}.
*/
public static final int CB_DEFAULT = SB_ALL | AT_DEFAULT;
/**
* Strict content blocking categories.
* A combination of {@link #AT_STRICT} and {@link #SB_ALL}.
* May cause issues with some web sites.
*/
public static final int CB_STRICT = SB_ALL | AT_STRICT;
// Sync values with nsICookieService.idl.
@Retention(RetentionPolicy.SOURCE)
@IntDef({ COOKIE_ACCEPT_ALL, COOKIE_ACCEPT_FIRST_PARTY,

Просмотреть файл

@ -22,6 +22,15 @@ exclude: true
[68.3]: ../ContentBlocking.html#AT_CRYPTOMINING
- Added [`ContentBlocking#AT_DEFAULT`][68.4], [`ContentBlocking#AT_STRICT`][68.5],
[`ContentBlocking#CB_DEFAULT`][68.6] and [`ContentBlocking#CB_STRICT`][68.7]
for clearer app default selections.
[68.4]: ../ContentBlocking.html$AT_DEFAULT
[68.5]: ../ContentBlocking.html$AT_STRICT
[68.6]: ../ContentBlocking.html$CB_DEFAULT
[68.7]: ../ContentBlocking.html$CB_STRICT
## v67
- Added [`setAutomaticFontSizeAdjustment`][67.2] to
[`GeckoRuntimeSettings`][67.3] for automatically adjusting font size settings
@ -228,4 +237,4 @@ exclude: true
[65.24]: ../CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
[65.25]: ../GeckoResult.html
[api-version]: e48935ac13c3a907d46d50bb2b00f5e84d30ef4b
[api-version]: 9ac0d5a6ef3fd45ecf9e12b42de4f6057e274c30

Просмотреть файл

@ -135,7 +135,7 @@ public class GeckoViewActivity extends AppCompatActivity {
.remoteDebuggingEnabled(mEnableRemoteDebugging)
.consoleOutput(true)
.contentBlocking(new ContentBlocking.Settings.Builder()
.categories(ContentBlocking.AT_ALL | ContentBlocking.SB_ALL)
.categories(ContentBlocking.AT_DEFAULT)
.build())
.crashHandler(ExampleCrashHandler.class);