/
fix_adapt_exclusive_access_for_electron_needs.patch
69 lines (61 loc) · 2.91 KB
/
fix_adapt_exclusive_access_for_electron_needs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Mon, 25 Oct 2021 21:45:57 +0200
Subject: fix: adapt exclusive_access for electron needs
This patch is necessary in order to properly enable
navigator.keyboard.{(un)?lock}() functionality. We don't have a concept
of PermissionManager nor of a Profile, so this would not affect usage of
the API.
We also need to ensure that NotifyExclusiveTabAccessLost is called
on all platforms in FullscreenController::ExitFullscreenModeInternal()
and not just macOS, since Electron's native window impls report state
change fairly instantly as well, and so pressing escape won't work on
Linux or Windows to un-fullscreen in some circumstances without this
change.
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
index 9b2c91d39324b61afa49ccea6be2eda8308473ff..6817a9cd22ebb8adba2118a1bd8a32cfc065e8ea 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
@@ -382,13 +382,9 @@ void FullscreenController::EnterFullscreenModeInternal(
// Do not enter fullscreen mode if disallowed by pref. This prevents the user
// from manually entering fullscreen mode and also disables kiosk mode on
// desktop platforms.
- if (!exclusive_access_manager()
- ->context()
- ->GetProfile()
- ->GetPrefs()
- ->GetBoolean(prefs::kFullscreenAllowed)) {
+ auto* profile = exclusive_access_manager()->context()->GetProfile();
+ if (!profile || !profile->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed))
return;
- }
#endif
toggled_into_fullscreen_ = true;
@@ -401,6 +397,7 @@ void FullscreenController::EnterFullscreenModeInternal(
url = extension_caused_fullscreen_;
}
+#if 0
if (display_id != display::kInvalidDisplayId) {
// Check, but do not prompt, for permission to request a specific screen.
// Sites generally need permission to get the display id in the first place.
@@ -413,6 +410,7 @@ void FullscreenController::EnterFullscreenModeInternal(
display_id = display::kInvalidDisplayId;
}
}
+#endif
if (option == BROWSER)
base::RecordAction(base::UserMetricsAction("ToggleFullscreen"));
@@ -439,12 +437,12 @@ void FullscreenController::ExitFullscreenModeInternal() {
RecordExitingUMA();
toggled_into_fullscreen_ = false;
-#if BUILDFLAG(IS_MAC)
- // Mac windows report a state change instantly, and so we must also clear
+
+ // Electron native windows report a state change instantly, and so we must also clear
// state_prior_to_tab_fullscreen_ to match them else other logic using
// state_prior_to_tab_fullscreen_ will be incorrect.
NotifyTabExclusiveAccessLost();
-#endif
+
exclusive_access_manager()->context()->ExitFullscreen();
extension_caused_fullscreen_ = GURL();