/
fix_adapt_exclusive_access_for_electron_needs.patch
149 lines (133 loc) · 6.12 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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 467fed776d390e1a10075d62dab75fd8a6789627..d6f3c20fabee755373add6ee1e5722c106204e42 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
@@ -16,12 +16,16 @@
#include "build/build_config.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/profiles/profile.h"
+#if 0
#include "chrome/browser/ui/blocked_content/popunder_preventer.h"
+#endif
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_within_tab_helper.h"
+#if 0
#include "chrome/browser/ui/status_bubble.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#endif
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/navigation_entry.h"
@@ -164,6 +168,7 @@ void FullscreenController::EnterFullscreenModeForTab(
return;
}
+#if 0
if (base::FeatureList::IsEnabled(
blink::features::kWindowPlacementFullscreenCompanionWindow)) {
if (!popunder_preventer_)
@@ -171,6 +176,7 @@ void FullscreenController::EnterFullscreenModeForTab(
else
popunder_preventer_->WillActivateWebContents(web_contents);
}
+#endif
// Keep the current state. |SetTabWithExclusiveAccess| may change the return
// value of |IsWindowFullscreenForTabOrPending|.
@@ -220,7 +226,9 @@ void FullscreenController::EnterFullscreenModeForTab(
}
void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
+#if 0
popunder_preventer_.reset();
+#endif
if (MaybeToggleFullscreenWithinTab(web_contents, false)) {
// During tab capture of fullscreen-within-tab views, the browser window
@@ -275,11 +283,13 @@ void FullscreenController::ExitFullscreenModeForTab(WebContents* web_contents) {
void FullscreenController::FullscreenTabOpeningPopup(
content::WebContents* opener,
content::WebContents* popup) {
+#if 0
DCHECK(base::FeatureList::IsEnabled(
blink::features::kWindowPlacementFullscreenCompanionWindow));
DCHECK_EQ(exclusive_access_tab(), opener);
DCHECK(popunder_preventer_);
popunder_preventer_->AddPotentialPopunder(popup);
+#endif
}
void FullscreenController::OnTabDeactivated(
@@ -429,17 +439,15 @@ 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;
+#if 0
bool entering_tab_fullscreen = option == TAB && !tab_fullscreen_;
+#endif
GURL url;
if (option == TAB) {
url = GetRequestingOrigin();
@@ -449,6 +457,7 @@ void FullscreenController::EnterFullscreenModeInternal(
url = extension_caused_fullscreen_;
}
+#if 0
if (option == TAB && 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.
@@ -466,6 +475,7 @@ void FullscreenController::EnterFullscreenModeInternal(
GetDisplayId(WebContents::FromRenderFrameHost(requesting_frame));
}
}
+#endif
if (option == BROWSER)
base::RecordAction(base::UserMetricsAction("ToggleFullscreen"));
@@ -492,12 +502,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();
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.h b/chrome/browser/ui/exclusive_access/fullscreen_controller.h
index 58a1ff5fb9fecd8c85905045ba43f43f0c63c2bb..15f868ac651c05eae6505adb80f2b4573a1166ef 100644
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.h
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.h
@@ -224,10 +224,12 @@ class FullscreenController : public ExclusiveAccessControllerBase {
// Used in testing to set the state to tab fullscreen.
bool is_tab_fullscreen_for_testing_ = false;
+#if 0
// Tracks related popups that lost activation or were shown without activation
// during content fullscreen sessions. This also activates the popups when
// fullscreen exits, to prevent sites from creating persisent popunders.
std::unique_ptr<PopunderPreventer> popunder_preventer_;
+#endif
base::ObserverList<FullscreenObserver> observer_list_;