global desktop mode feature
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/providers/tab_session.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
|
||||
part 'desktop_mode.g.dart';
|
||||
|
||||
@@ -43,6 +44,11 @@ class DesktopMode extends _$DesktopMode {
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
// Seed the initial value from the browser-wide default so a newly opened
|
||||
// tab's menu checkbox matches the desktop mode it was actually created with
|
||||
// natively (GeckoTabsApi seeds new tabs from BrowserState.desktopMode).
|
||||
// Read (not watch) so toggling the global default never clobbers an
|
||||
// existing tab's per-tab override.
|
||||
return ref.read(generalSettingsWithDefaultsProvider).globalDesktopMode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ final class DesktopModeProvider extends $NotifierProvider<DesktopMode, bool> {
|
||||
}
|
||||
}
|
||||
|
||||
String _$desktopModeHash() => r'18550009e95a23ff82d30206ce81daa859c57c26';
|
||||
String _$desktopModeHash() => r'727c8a884de5c21499f4b3ae6835af1115f649f2';
|
||||
|
||||
final class DesktopModeFamily extends $Family
|
||||
with $ClassFamilyOverride<DesktopMode, bool, bool, bool, String> {
|
||||
|
||||
+32
@@ -25,6 +25,7 @@ import 'package:flutter_mozilla_components/flutter_mozilla_components.dart';
|
||||
import 'package:riverpod/riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:weblibre/core/logger.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/providers/desktop_mode.dart';
|
||||
import 'package:weblibre/features/geckoview/features/browser/domain/services/browser_addon.dart';
|
||||
import 'package:weblibre/features/geckoview/features/preferences/data/repositories/preference_observer.dart';
|
||||
import 'package:weblibre/features/geckoview/features/preferences/data/repositories/preference_settings.dart';
|
||||
@@ -158,6 +159,37 @@ class EngineSettingsReplicationService
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
fireImmediately: true,
|
||||
generalSettingsWithDefaultsProvider.select(
|
||||
(settings) => settings.globalDesktopMode,
|
||||
),
|
||||
(previous, next) async {
|
||||
// Only an actual toggle (not the initial startup fire) should rewrite
|
||||
// existing tabs; the initial fire just sets the default for new tabs.
|
||||
final isUserToggle = previous != null;
|
||||
|
||||
await _service.setGlobalDesktopMode(
|
||||
next,
|
||||
applyToExistingTabs: isUserToggle,
|
||||
);
|
||||
|
||||
if (isUserToggle) {
|
||||
// The native side applied the new value to all existing tabs.
|
||||
// Invalidate the per-tab desktop-mode notifiers so their menu
|
||||
// checkboxes re-seed and reflect it.
|
||||
ref.invalidate(desktopModeProvider);
|
||||
}
|
||||
},
|
||||
onError: (error, stackTrace) {
|
||||
logger.e(
|
||||
'Error listening to globalDesktopMode',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
ref.listen(
|
||||
fireImmediately: true,
|
||||
engineSettingsRepositoryProvider,
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ final class EngineSettingsReplicationServiceProvider
|
||||
}
|
||||
|
||||
String _$engineSettingsReplicationServiceHash() =>
|
||||
r'8f37476c9beecd6cc70a07b8cd3a51864b077176';
|
||||
r'36f43a382419203ec53cac71fe51b1d30df2a0c6';
|
||||
|
||||
abstract class _$EngineSettingsReplicationService extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
+9
@@ -64,6 +64,15 @@ class PreferenceSetting with FastEquatable {
|
||||
final String? description;
|
||||
|
||||
final bool requireUserOptIn;
|
||||
|
||||
/// Marks this preference as an enforced hardening policy: it renders as a
|
||||
/// locked, non-interactive row and cannot be toggled off in the UI.
|
||||
///
|
||||
/// This is a *policy* flag, not a claim that [value] equals Gecko's default.
|
||||
/// Many locked preferences intentionally deviate from the engine default
|
||||
/// (e.g. blanking the telemetry/crash-report/OHTTP endpoints), so auditing
|
||||
/// locked values against Gecko defaults is expected to show differences —
|
||||
/// those are deliberate overrides, not bugs.
|
||||
final bool locked;
|
||||
final bool enforceOnStartup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user