make safe browsing a dedicated setting
This commit is contained in:
@@ -3,14 +3,6 @@
|
|||||||
"Safe Browsing": {
|
"Safe Browsing": {
|
||||||
"description": "Google Safe Browsing warns users about dangerous websites and downloads.",
|
"description": "Google Safe Browsing warns users about dangerous websites and downloads.",
|
||||||
"preferences": {
|
"preferences": {
|
||||||
"browser.safebrowsing.malware.enabled": {
|
|
||||||
"value": true,
|
|
||||||
"title": "Enable malware protection"
|
|
||||||
},
|
|
||||||
"browser.safebrowsing.phishing.enabled": {
|
|
||||||
"value": true,
|
|
||||||
"title": "Enable phishing protection"
|
|
||||||
},
|
|
||||||
"browser.safebrowsing.downloads.remote.enabled": {
|
"browser.safebrowsing.downloads.remote.enabled": {
|
||||||
"value": false,
|
"value": false,
|
||||||
"title": "Disable remote verification for downloads",
|
"title": "Disable remote verification for downloads",
|
||||||
|
|||||||
+33
@@ -31,6 +31,9 @@ import 'package:weblibre/features/user/domain/repositories/general_settings.dart
|
|||||||
|
|
||||||
part 'engine_settings_replication.g.dart';
|
part 'engine_settings_replication.g.dart';
|
||||||
|
|
||||||
|
const _safeBrowsingMalwarePref = 'browser.safebrowsing.malware.enabled';
|
||||||
|
const _safeBrowsingPhishingPref = 'browser.safebrowsing.phishing.enabled';
|
||||||
|
|
||||||
/// Checks if any Custom ETP setting changed between two EngineSettings instances.
|
/// Checks if any Custom ETP setting changed between two EngineSettings instances.
|
||||||
bool _customEtpSettingsChanged(
|
bool _customEtpSettingsChanged(
|
||||||
GeckoEngineSettings? previous,
|
GeckoEngineSettings? previous,
|
||||||
@@ -229,6 +232,24 @@ class EngineSettingsReplicationService
|
|||||||
.read(preferenceFixatorProvider.notifier)
|
.read(preferenceFixatorProvider.notifier)
|
||||||
.register('pdfjs.disabled', !settings.enablePdfJs);
|
.register('pdfjs.disabled', !settings.enablePdfJs);
|
||||||
}
|
}
|
||||||
|
if (previous.value?.safeBrowsingMalwareEnabled !=
|
||||||
|
settings.safeBrowsingMalwareEnabled) {
|
||||||
|
await ref
|
||||||
|
.read(preferenceFixatorProvider.notifier)
|
||||||
|
.register(
|
||||||
|
_safeBrowsingMalwarePref,
|
||||||
|
settings.safeBrowsingMalwareEnabled,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (previous.value?.safeBrowsingPhishingEnabled !=
|
||||||
|
settings.safeBrowsingPhishingEnabled) {
|
||||||
|
await ref
|
||||||
|
.read(preferenceFixatorProvider.notifier)
|
||||||
|
.register(
|
||||||
|
_safeBrowsingPhishingPref,
|
||||||
|
settings.safeBrowsingPhishingEnabled,
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!const DeepCollectionEquality.unordered().equals(
|
if (!const DeepCollectionEquality.unordered().equals(
|
||||||
previous.value?.locales,
|
previous.value?.locales,
|
||||||
settings.locales,
|
settings.locales,
|
||||||
@@ -283,6 +304,18 @@ class EngineSettingsReplicationService
|
|||||||
await ref
|
await ref
|
||||||
.read(preferenceFixatorProvider.notifier)
|
.read(preferenceFixatorProvider.notifier)
|
||||||
.register('pdfjs.disabled', !settings.enablePdfJs);
|
.register('pdfjs.disabled', !settings.enablePdfJs);
|
||||||
|
await ref
|
||||||
|
.read(preferenceFixatorProvider.notifier)
|
||||||
|
.register(
|
||||||
|
_safeBrowsingMalwarePref,
|
||||||
|
settings.safeBrowsingMalwareEnabled,
|
||||||
|
);
|
||||||
|
await ref
|
||||||
|
.read(preferenceFixatorProvider.notifier)
|
||||||
|
.register(
|
||||||
|
_safeBrowsingPhishingPref,
|
||||||
|
settings.safeBrowsingPhishingEnabled,
|
||||||
|
);
|
||||||
await ref
|
await ref
|
||||||
.read(preferenceFixatorProvider.notifier)
|
.read(preferenceFixatorProvider.notifier)
|
||||||
.register('intl.accept_languages', settings.locales.join(','));
|
.register('intl.accept_languages', settings.locales.join(','));
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ final class EngineSettingsReplicationServiceProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$engineSettingsReplicationServiceHash() =>
|
String _$engineSettingsReplicationServiceHash() =>
|
||||||
r'81443c37d18ad82f0694cd0e1115ccdf8a0f4c06';
|
r'061f0b32a9c49e3bd4b76cd99993620558e0d3b2';
|
||||||
|
|
||||||
abstract class _$EngineSettingsReplicationService extends $Notifier<void> {
|
abstract class _$EngineSettingsReplicationService extends $Notifier<void> {
|
||||||
void build();
|
void build();
|
||||||
|
|||||||
+74
@@ -55,6 +55,7 @@ class PrivacySecuritySettingsScreen extends StatelessWidget {
|
|||||||
_NetworkProtectionSection(),
|
_NetworkProtectionSection(),
|
||||||
_PrivacySignalsSection(),
|
_PrivacySignalsSection(),
|
||||||
_DataManagementSection(),
|
_DataManagementSection(),
|
||||||
|
_SafeBrowsingSection(),
|
||||||
_AdvancedSecuritySection(),
|
_AdvancedSecuritySection(),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
@@ -145,6 +146,21 @@ class _PrivacySignalsSection extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _SafeBrowsingSection extends StatelessWidget {
|
||||||
|
const _SafeBrowsingSection();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return const Column(
|
||||||
|
children: [
|
||||||
|
SettingSection(name: 'Google Safe Browsing'),
|
||||||
|
_SafeBrowsingMalwareTile(),
|
||||||
|
_SafeBrowsingPhishingTile(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _DataManagementSection extends StatelessWidget {
|
class _DataManagementSection extends StatelessWidget {
|
||||||
const _DataManagementSection();
|
const _DataManagementSection();
|
||||||
|
|
||||||
@@ -739,6 +755,64 @@ class _FissionEnabledTile extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _SafeBrowsingMalwareTile extends HookConsumerWidget {
|
||||||
|
const _SafeBrowsingMalwareTile();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final safeBrowsingMalwareEnabled = ref.watch(
|
||||||
|
engineSettingsWithDefaultsProvider.select(
|
||||||
|
(s) => s.safeBrowsingMalwareEnabled,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return SwitchListTile.adaptive(
|
||||||
|
title: const Text('Safe Browsing Malware Protection'),
|
||||||
|
subtitle: const Text(
|
||||||
|
'Warn about dangerous websites and malicious downloads.',
|
||||||
|
),
|
||||||
|
secondary: const Icon(Icons.bug_report_outlined),
|
||||||
|
value: safeBrowsingMalwareEnabled,
|
||||||
|
onChanged: (value) async {
|
||||||
|
await ref
|
||||||
|
.read(saveEngineSettingsControllerProvider.notifier)
|
||||||
|
.save(
|
||||||
|
(currentSettings) =>
|
||||||
|
currentSettings.copyWith.safeBrowsingMalwareEnabled(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SafeBrowsingPhishingTile extends HookConsumerWidget {
|
||||||
|
const _SafeBrowsingPhishingTile();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final safeBrowsingPhishingEnabled = ref.watch(
|
||||||
|
engineSettingsWithDefaultsProvider.select(
|
||||||
|
(s) => s.safeBrowsingPhishingEnabled,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
return SwitchListTile.adaptive(
|
||||||
|
title: const Text('Safe Browsing Phishing Protection'),
|
||||||
|
subtitle: const Text('Warn about deceptive websites and login pages.'),
|
||||||
|
secondary: const Icon(Icons.gpp_maybe_outlined),
|
||||||
|
value: safeBrowsingPhishingEnabled,
|
||||||
|
onChanged: (value) async {
|
||||||
|
await ref
|
||||||
|
.read(saveEngineSettingsControllerProvider.notifier)
|
||||||
|
.save(
|
||||||
|
(currentSettings) =>
|
||||||
|
currentSettings.copyWith.safeBrowsingPhishingEnabled(value),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _ExtensionsWebAPIEnabledTile extends HookConsumerWidget {
|
class _ExtensionsWebAPIEnabledTile extends HookConsumerWidget {
|
||||||
const _ExtensionsWebAPIEnabledTile();
|
const _ExtensionsWebAPIEnabledTile();
|
||||||
|
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
|||||||
|
|
||||||
final bool enablePdfJs;
|
final bool enablePdfJs;
|
||||||
|
|
||||||
|
final bool safeBrowsingMalwareEnabled;
|
||||||
|
|
||||||
|
final bool safeBrowsingPhishingEnabled;
|
||||||
|
|
||||||
EngineSettings({
|
EngineSettings({
|
||||||
required super.javascriptEnabled,
|
required super.javascriptEnabled,
|
||||||
required super.trackingProtectionPolicy,
|
required super.trackingProtectionPolicy,
|
||||||
@@ -181,6 +185,8 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
|||||||
required this.dohExceptionsList,
|
required this.dohExceptionsList,
|
||||||
required super.fingerprintingProtectionOverrides,
|
required super.fingerprintingProtectionOverrides,
|
||||||
required this.enablePdfJs,
|
required this.enablePdfJs,
|
||||||
|
required this.safeBrowsingMalwareEnabled,
|
||||||
|
required this.safeBrowsingPhishingEnabled,
|
||||||
required super.locales,
|
required super.locales,
|
||||||
required super.blockCookies,
|
required super.blockCookies,
|
||||||
required super.customCookiePolicy,
|
required super.customCookiePolicy,
|
||||||
@@ -232,6 +238,8 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
|||||||
List<String>? dohExceptionsList,
|
List<String>? dohExceptionsList,
|
||||||
String? fingerprintingProtectionOverrides,
|
String? fingerprintingProtectionOverrides,
|
||||||
bool? enablePdfJs,
|
bool? enablePdfJs,
|
||||||
|
bool? safeBrowsingMalwareEnabled,
|
||||||
|
bool? safeBrowsingPhishingEnabled,
|
||||||
List<String>? locales,
|
List<String>? locales,
|
||||||
bool? blockCookies,
|
bool? blockCookies,
|
||||||
CustomCookiePolicy? customCookiePolicy,
|
CustomCookiePolicy? customCookiePolicy,
|
||||||
@@ -269,6 +277,8 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
|||||||
dohDefaultProviderUrl ?? BuiltInDohProviders.quad9.url,
|
dohDefaultProviderUrl ?? BuiltInDohProviders.quad9.url,
|
||||||
dohExceptionsList = dohExceptionsList ?? [],
|
dohExceptionsList = dohExceptionsList ?? [],
|
||||||
enablePdfJs = enablePdfJs ?? true,
|
enablePdfJs = enablePdfJs ?? true,
|
||||||
|
safeBrowsingMalwareEnabled = safeBrowsingMalwareEnabled ?? true,
|
||||||
|
safeBrowsingPhishingEnabled = safeBrowsingPhishingEnabled ?? true,
|
||||||
super(
|
super(
|
||||||
javascriptEnabled: javascriptEnabled ?? true,
|
javascriptEnabled: javascriptEnabled ?? true,
|
||||||
trackingProtectionPolicy:
|
trackingProtectionPolicy:
|
||||||
@@ -359,6 +369,8 @@ class EngineSettings extends GeckoEngineSettings with FastEquatable {
|
|||||||
dohExceptionsList,
|
dohExceptionsList,
|
||||||
fingerprintingProtectionOverrides,
|
fingerprintingProtectionOverrides,
|
||||||
enablePdfJs,
|
enablePdfJs,
|
||||||
|
safeBrowsingMalwareEnabled,
|
||||||
|
safeBrowsingPhishingEnabled,
|
||||||
locales,
|
locales,
|
||||||
blockCookies,
|
blockCookies,
|
||||||
customCookiePolicy,
|
customCookiePolicy,
|
||||||
|
|||||||
@@ -67,6 +67,10 @@ abstract class _$EngineSettingsCWProxy {
|
|||||||
|
|
||||||
EngineSettings enablePdfJs(bool enablePdfJs);
|
EngineSettings enablePdfJs(bool enablePdfJs);
|
||||||
|
|
||||||
|
EngineSettings safeBrowsingMalwareEnabled(bool safeBrowsingMalwareEnabled);
|
||||||
|
|
||||||
|
EngineSettings safeBrowsingPhishingEnabled(bool safeBrowsingPhishingEnabled);
|
||||||
|
|
||||||
EngineSettings locales(List<String>? locales);
|
EngineSettings locales(List<String>? locales);
|
||||||
|
|
||||||
EngineSettings blockCookies(bool? blockCookies);
|
EngineSettings blockCookies(bool? blockCookies);
|
||||||
@@ -154,6 +158,8 @@ abstract class _$EngineSettingsCWProxy {
|
|||||||
List<String> dohExceptionsList,
|
List<String> dohExceptionsList,
|
||||||
String? fingerprintingProtectionOverrides,
|
String? fingerprintingProtectionOverrides,
|
||||||
bool enablePdfJs,
|
bool enablePdfJs,
|
||||||
|
bool safeBrowsingMalwareEnabled,
|
||||||
|
bool safeBrowsingPhishingEnabled,
|
||||||
List<String>? locales,
|
List<String>? locales,
|
||||||
bool? blockCookies,
|
bool? blockCookies,
|
||||||
CustomCookiePolicy? customCookiePolicy,
|
CustomCookiePolicy? customCookiePolicy,
|
||||||
@@ -292,6 +298,15 @@ class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
|
|||||||
EngineSettings enablePdfJs(bool enablePdfJs) =>
|
EngineSettings enablePdfJs(bool enablePdfJs) =>
|
||||||
call(enablePdfJs: enablePdfJs);
|
call(enablePdfJs: enablePdfJs);
|
||||||
|
|
||||||
|
@override
|
||||||
|
EngineSettings safeBrowsingMalwareEnabled(bool safeBrowsingMalwareEnabled) =>
|
||||||
|
call(safeBrowsingMalwareEnabled: safeBrowsingMalwareEnabled);
|
||||||
|
|
||||||
|
@override
|
||||||
|
EngineSettings safeBrowsingPhishingEnabled(
|
||||||
|
bool safeBrowsingPhishingEnabled,
|
||||||
|
) => call(safeBrowsingPhishingEnabled: safeBrowsingPhishingEnabled);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
EngineSettings locales(List<String>? locales) => call(locales: locales);
|
EngineSettings locales(List<String>? locales) => call(locales: locales);
|
||||||
|
|
||||||
@@ -433,6 +448,8 @@ class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
|
|||||||
Object? dohExceptionsList = const $CopyWithPlaceholder(),
|
Object? dohExceptionsList = const $CopyWithPlaceholder(),
|
||||||
Object? fingerprintingProtectionOverrides = const $CopyWithPlaceholder(),
|
Object? fingerprintingProtectionOverrides = const $CopyWithPlaceholder(),
|
||||||
Object? enablePdfJs = const $CopyWithPlaceholder(),
|
Object? enablePdfJs = const $CopyWithPlaceholder(),
|
||||||
|
Object? safeBrowsingMalwareEnabled = const $CopyWithPlaceholder(),
|
||||||
|
Object? safeBrowsingPhishingEnabled = const $CopyWithPlaceholder(),
|
||||||
Object? locales = const $CopyWithPlaceholder(),
|
Object? locales = const $CopyWithPlaceholder(),
|
||||||
Object? blockCookies = const $CopyWithPlaceholder(),
|
Object? blockCookies = const $CopyWithPlaceholder(),
|
||||||
Object? customCookiePolicy = const $CopyWithPlaceholder(),
|
Object? customCookiePolicy = const $CopyWithPlaceholder(),
|
||||||
@@ -571,6 +588,18 @@ class _$EngineSettingsCWProxyImpl implements _$EngineSettingsCWProxy {
|
|||||||
? _value.enablePdfJs
|
? _value.enablePdfJs
|
||||||
// ignore: cast_nullable_to_non_nullable
|
// ignore: cast_nullable_to_non_nullable
|
||||||
: enablePdfJs as bool,
|
: enablePdfJs as bool,
|
||||||
|
safeBrowsingMalwareEnabled:
|
||||||
|
safeBrowsingMalwareEnabled == const $CopyWithPlaceholder() ||
|
||||||
|
safeBrowsingMalwareEnabled == null
|
||||||
|
? _value.safeBrowsingMalwareEnabled
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: safeBrowsingMalwareEnabled as bool,
|
||||||
|
safeBrowsingPhishingEnabled:
|
||||||
|
safeBrowsingPhishingEnabled == const $CopyWithPlaceholder() ||
|
||||||
|
safeBrowsingPhishingEnabled == null
|
||||||
|
? _value.safeBrowsingPhishingEnabled
|
||||||
|
// ignore: cast_nullable_to_non_nullable
|
||||||
|
: safeBrowsingPhishingEnabled as bool,
|
||||||
locales: locales == const $CopyWithPlaceholder()
|
locales: locales == const $CopyWithPlaceholder()
|
||||||
? _value.locales
|
? _value.locales
|
||||||
// ignore: cast_nullable_to_non_nullable
|
// ignore: cast_nullable_to_non_nullable
|
||||||
@@ -760,6 +789,8 @@ EngineSettings _$EngineSettingsFromJson(
|
|||||||
fingerprintingProtectionOverrides:
|
fingerprintingProtectionOverrides:
|
||||||
json['fingerprintingProtectionOverrides'] as String?,
|
json['fingerprintingProtectionOverrides'] as String?,
|
||||||
enablePdfJs: json['enablePdfJs'] as bool?,
|
enablePdfJs: json['enablePdfJs'] as bool?,
|
||||||
|
safeBrowsingMalwareEnabled: json['safeBrowsingMalwareEnabled'] as bool?,
|
||||||
|
safeBrowsingPhishingEnabled: json['safeBrowsingPhishingEnabled'] as bool?,
|
||||||
locales: (json['locales'] as List<dynamic>?)
|
locales: (json['locales'] as List<dynamic>?)
|
||||||
?.map((e) => e as String)
|
?.map((e) => e as String)
|
||||||
.toList(),
|
.toList(),
|
||||||
@@ -867,6 +898,8 @@ Map<String, dynamic> _$EngineSettingsToJson(
|
|||||||
'dohDefaultProviderUrl': instance.dohDefaultProviderUrl,
|
'dohDefaultProviderUrl': instance.dohDefaultProviderUrl,
|
||||||
'dohExceptionsList': instance.dohExceptionsList,
|
'dohExceptionsList': instance.dohExceptionsList,
|
||||||
'enablePdfJs': instance.enablePdfJs,
|
'enablePdfJs': instance.enablePdfJs,
|
||||||
|
'safeBrowsingMalwareEnabled': instance.safeBrowsingMalwareEnabled,
|
||||||
|
'safeBrowsingPhishingEnabled': instance.safeBrowsingPhishingEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
const _$TrackingProtectionPolicyEnumMap = {
|
const _$TrackingProtectionPolicyEnumMap = {
|
||||||
|
|||||||
@@ -124,6 +124,10 @@ class EngineSettingsRepository extends _$EngineSettingsRepository {
|
|||||||
DriftSqlType.bool,
|
DriftSqlType.bool,
|
||||||
db.typeMapping,
|
db.typeMapping,
|
||||||
),
|
),
|
||||||
|
'safeBrowsingMalwareEnabled': settings['safeBrowsingMalwareEnabled']
|
||||||
|
?.readAs(DriftSqlType.bool, db.typeMapping),
|
||||||
|
'safeBrowsingPhishingEnabled': settings['safeBrowsingPhishingEnabled']
|
||||||
|
?.readAs(DriftSqlType.bool, db.typeMapping),
|
||||||
'locales': settings['locales']
|
'locales': settings['locales']
|
||||||
?.readAs(DriftSqlType.string, db.typeMapping)
|
?.readAs(DriftSqlType.string, db.typeMapping)
|
||||||
.mapNotNull(jsonDecode),
|
.mapNotNull(jsonDecode),
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ final class EngineSettingsRepositoryProvider
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _$engineSettingsRepositoryHash() =>
|
String _$engineSettingsRepositoryHash() =>
|
||||||
r'4abe41cfeba8e39484683033f11c54be644fa2b2';
|
r'f3fe745e37ec89c2d403906250aea66321c3e505';
|
||||||
|
|
||||||
abstract class _$EngineSettingsRepository
|
abstract class _$EngineSettingsRepository
|
||||||
extends $StreamNotifier<EngineSettings> {
|
extends $StreamNotifier<EngineSettings> {
|
||||||
|
|||||||
Reference in New Issue
Block a user