-
Notifications
You must be signed in to change notification settings - Fork 15k
/
content_allow_embedder_to_prevent_locking_scheme_registry.patch
56 lines (48 loc) · 2.67 KB
/
content_allow_embedder_to_prevent_locking_scheme_registry.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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <nornagon@nornagon.net>
Date: Wed, 21 Nov 2018 14:31:34 -0800
Subject: content: allow embedder to prevent locking scheme registry
The //content layer requires all schemes to be registered during startup,
because Add*Scheme aren't threadsafe. However, Electron exposes the option to
register additional schemes via JavaScript in the main process before the app
is ready, but after the //content layer has already locked the registry.
Without this patch, calling `registerStandardSchemes` during initialization
when in debug mode will cause a DCHECK to fire.
diff --git a/content/app/content_main_runner_impl.cc b/content/app/content_main_runner_impl.cc
index 034fdcad958cb25780c304d184b2fbb721a13200..c2090368f6678950690463e0b90620cb9fdf5f41 100644
--- a/content/app/content_main_runner_impl.cc
+++ b/content/app/content_main_runner_impl.cc
@@ -808,7 +808,7 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) {
#endif
RegisterPathProvider();
- RegisterContentSchemes(true);
+ RegisterContentSchemes(delegate_->ShouldLockSchemeRegistry());
#if defined(OS_ANDROID) && (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
int icudata_fd = g_fds->MaybeGet(kAndroidICUDataDescriptor);
diff --git a/content/public/app/content_main_delegate.cc b/content/public/app/content_main_delegate.cc
index c4bdfd36ad0c34b3a91b59502414bc98c091ccee..d7ac740d0088c002bee98238faea1ef9593eee92 100644
--- a/content/public/app/content_main_delegate.cc
+++ b/content/public/app/content_main_delegate.cc
@@ -63,6 +63,10 @@ bool ContentMainDelegate::ShouldEnableProfilerRecording() {
return false;
}
+bool ContentMainDelegate::ShouldLockSchemeRegistry() {
+ return true;
+}
+
service_manager::ProcessType ContentMainDelegate::OverrideProcessType() {
return service_manager::ProcessType::kDefault;
}
diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h
index 979e25d1c1b9ff4b16adbab28cb44d8473f8232a..7aca113058ed111a98e396df57ebc36c06e3b896 100644
--- a/content/public/app/content_main_delegate.h
+++ b/content/public/app/content_main_delegate.h
@@ -101,6 +101,9 @@ class CONTENT_EXPORT ContentMainDelegate {
// Returns whether or not profiler recording should be enabled.
virtual bool ShouldEnableProfilerRecording();
+ // Allows the embedder to prevent locking the scheme registry.
+ virtual bool ShouldLockSchemeRegistry();
+
// Fatal errors during initialization are reported by this function, so that
// the embedder can implement graceful exit by displaying some message and
// returning initialization error code. Default behavior is CHECK(false).