diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-17 09:23:05 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2019-05-17 09:23:05 +0000 |
commit | 0f081baa31facec779057de29eec14c6f458f6a6 (patch) | |
tree | 989110595da0d3ca42a78eaa73078ad24431a2d4 /src/core | |
parent | a4eeb9dbd995d598bd3a639dd450def7c242b383 (diff) | |
parent | 4561b5a83966792b7325e63c91d78a6f70e65961 (diff) |
Merge "Merge remote-tracking branch 'origin/5.13' into dev" into refs/staging/dev
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/config/linux.pri | 1 | ||||
-rw-r--r-- | src/core/configure.json | 1 | ||||
-rw-r--r-- | src/core/profile_adapter.cpp | 42 |
3 files changed, 32 insertions, 12 deletions
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 95b7a4bda..fcce4c316 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -36,6 +36,7 @@ clang { gn_args += \ is_clang=true \ clang_use_chrome_plugins=false \ + clang_use_default_sample_profile=false \ clang_base_path=\"$${clang_prefix}\" linux-clang-libc++: gn_args += use_libcxx=true diff --git a/src/core/configure.json b/src/core/configure.json index 6bc6a213c..bb8ad7997 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -5,6 +5,7 @@ "gui-private", "printsupport" ], + "condition": "module.gui", "testDir": "../../config.tests", "commandline": { "options": { diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp index a275952e7..ff0199833 100644 --- a/src/core/profile_adapter.cpp +++ b/src/core/profile_adapter.cpp @@ -443,18 +443,32 @@ void ProfileAdapter::setHttpCacheMaxSize(int maxSize) m_profile->m_profileIOData->updateHttpCache(); } -static bool isInternalScheme(const QByteArray &scheme) +enum class SchemeType { Protected, Overridable, Custom }; +static SchemeType schemeType(const QByteArray &canonicalScheme) { - static QSet<QByteArray> internalSchemes{ - QByteArrayLiteral("qrc"), - QByteArrayLiteral("data"), + static const QSet<QByteArray> blacklist{ + QByteArrayLiteral("about"), QByteArrayLiteral("blob"), - QByteArrayLiteral("http"), - QByteArrayLiteral("https"), - QByteArrayLiteral("ftp"), + QByteArrayLiteral("data"), QByteArrayLiteral("javascript"), + QByteArrayLiteral("qrc"), + // See also kStandardURLSchemes in url/url_util.cc (through url::IsStandard below) + }; + + static const QSet<QByteArray> whitelist{ + QByteArrayLiteral("gopher"), }; - return internalSchemes.contains(scheme); + + bool standardSyntax = url::IsStandard(canonicalScheme.data(), url::Component(0, canonicalScheme.size())); + bool customScheme = QWebEngineUrlScheme::schemeByName(canonicalScheme) != QWebEngineUrlScheme(); + bool blacklisted = blacklist.contains(canonicalScheme); + bool whitelisted = whitelist.contains(canonicalScheme); + + if (whitelisted) + return SchemeType::Overridable; + if (blacklisted || (standardSyntax && !customScheme)) + return SchemeType::Protected; + return SchemeType::Custom; } QWebEngineUrlSchemeHandler *ProfileAdapter::urlSchemeHandler(const QByteArray &scheme) @@ -480,7 +494,7 @@ void ProfileAdapter::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) auto it = m_customUrlSchemeHandlers.begin(); while (it != m_customUrlSchemeHandlers.end()) { if (it.value() == handler) { - if (isInternalScheme(it.key())) { + if (schemeType(it.key()) == SchemeType::Protected) { qWarning("Cannot remove the URL scheme handler for an internal scheme: %s", it.key().constData()); continue; } @@ -497,7 +511,7 @@ void ProfileAdapter::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) void ProfileAdapter::removeUrlScheme(const QByteArray &scheme) { QByteArray canonicalScheme = scheme.toLower(); - if (isInternalScheme(canonicalScheme)) { + if (schemeType(canonicalScheme) == SchemeType::Protected) { qWarning("Cannot remove the URL scheme handler for an internal scheme: %s", scheme.constData()); return; } @@ -509,15 +523,19 @@ void ProfileAdapter::installUrlSchemeHandler(const QByteArray &scheme, QWebEngin { Q_ASSERT(handler); QByteArray canonicalScheme = scheme.toLower(); - if (isInternalScheme(canonicalScheme)) { + SchemeType type = schemeType(canonicalScheme); + + if (type == SchemeType::Protected) { qWarning("Cannot install a URL scheme handler overriding internal scheme: %s", scheme.constData()); return; } + if (m_customUrlSchemeHandlers.value(canonicalScheme, handler) != handler) { qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData()); return; } - if (QWebEngineUrlScheme::schemeByName(canonicalScheme) == QWebEngineUrlScheme()) + + if (type == SchemeType::Custom) qWarning("Please register the custom scheme '%s' via QWebEngineUrlScheme::registerScheme() " "before installing the custom scheme handler.", scheme.constData()); |