summaryrefslogtreecommitdiff
path: root/chromium/content/common
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2018-04-19 12:14:44 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2021-10-04 10:17:59 +0200
commit96397825bd85d2bef6219e0d7ab595835db058c7 (patch)
treeea22f24358bb9db372464106697b4d6f64234405 /chromium/content/common
parent39af75235ac5e4bc488b7dc8e60c8413586cb9ff (diff)
downloadqtwebengine-chromium-96397825bd85d2bef6219e0d7ab595835db058c7.tar.gz
Extend url library for WebEngine custom schemes
Adds (another) parallel scheme registry in url/url_util_qt, which is then used in Chromium and Blink to specialize URL handling for WebEngine custom schemes. The registry is transmitted from the main process to subprocesses in a new command line flag (--webengine-schemes), since the scheme lists in url/url_util are locked before IPC is initialized. Task-number: QTBUG-62536 Change-Id: Id26811a18d4c740cc4d281d2da5720304a235a41 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/content/common')
-rw-r--r--chromium/content/common/url_schemes.cc39
1 files changed, 38 insertions, 1 deletions
diff --git a/chromium/content/common/url_schemes.cc b/chromium/content/common/url_schemes.cc
index dc37f121130..1b8b7edbb37 100644
--- a/chromium/content/common/url_schemes.cc
+++ b/chromium/content/common/url_schemes.cc
@@ -15,6 +15,7 @@
#include "content/public/common/content_client.h"
#include "content/public/common/url_constants.h"
#include "url/url_util.h"
+#include "url/url_util_qt.h"
namespace content {
namespace {
@@ -96,11 +97,38 @@ void RegisterContentSchemes() {
for (auto& scheme : schemes.empty_document_schemes)
url::AddEmptyDocumentScheme(scheme.c_str());
-#if defined(OS_ANDROID)
+#if defined(OS_ANDROID) || defined(TOOLKIT_QT)
if (schemes.allow_non_standard_schemes_in_origins)
url::EnableNonStandardSchemesForAndroidWebView();
#endif
+ // NOTE(juvaldma)(Chromium 67.0.3396.47)
+ //
+ // Since ContentClient::Schemes::standard_types doesn't have types
+ // (url::SchemeType), we need to bypass AddAdditionalSchemes and add our
+ // 'standard custom schemes' directly. Although the other scheme lists could
+ // be filled also in AddAdditionalSchemes by QtWebEngineCore, to follow the
+ // principle of the separation of concerns, we add them here instead. This
+ // way, from the perspective of QtWebEngineCore, everything to do with custom
+ // scheme parsing is fully encapsulated behind url::CustomScheme. The
+ // complexity of QtWebEngineCore is reduced while the complexity of
+ // url::CustomScheme is not significantly increased (since the functionality
+ // is needed anyway).
+ for (auto& cs : url::CustomScheme::GetSchemes()) {
+ if (cs.type != url::SCHEME_WITHOUT_AUTHORITY)
+ url::AddStandardScheme(cs.name.c_str(), cs.type);
+ if (cs.flags & url::CustomScheme::Secure)
+ url::AddSecureScheme(cs.name.c_str());
+ if (cs.flags & url::CustomScheme::Local)
+ url::AddLocalScheme(cs.name.c_str());
+ if (cs.flags & url::CustomScheme::NoAccessAllowed)
+ url::AddNoAccessScheme(cs.name.c_str());
+ if (cs.flags & url::CustomScheme::ContentSecurityPolicyIgnored)
+ url::AddCSPBypassingScheme(cs.name.c_str());
+ if (cs.flags & url::CustomScheme::CorsEnabled)
+ url::AddCorsEnabledScheme(cs.name.c_str());
+ }
+
// Prevent future modification of the scheme lists. This is to prevent
// accidental creation of data races in the program. Add*Scheme aren't
// threadsafe so must be called when GURL isn't used on any other thread. This
@@ -116,6 +144,15 @@ void RegisterContentSchemes() {
schemes.savable_schemes.end());
GetMutableServiceWorkerSchemes() = std::move(schemes.service_worker_schemes);
+
+ // NOTE(juvaldma)(Chromium 67.0.3396.47)
+ //
+ // This list only applies to Chromium proper whereas Blink uses it's own
+ // hardcoded list (see blink::URLSchemesRegistry).
+ for (auto& cs : url::CustomScheme::GetSchemes()) {
+ if (cs.flags & url::CustomScheme::ServiceWorkersAllowed)
+ GetMutableServiceWorkerSchemes().push_back(cs.name);
+ }
}
void ReRegisterContentSchemesForTests() {