diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-02 11:09:26 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-02 11:09:26 +0100 |
commit | f51f50c22e770e1ab20ecccc8a32906e4014caed (patch) | |
tree | f1d561ef493a16a4eca9b65b097070b4bf48e939 /src/core | |
parent | c236dd2ac1ac047fa09f6606f4136a275d132d6d (diff) | |
parent | 8618813a60e4f15a104ce5127c01810a35440c30 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
.qmake.conf
tests/auto/quick/dialogs/tst_dialogs.cpp
Change-Id: I6840495a40e4e1e4512573c980816112ae5786d7
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/content_main_delegate_qt.cpp | 3 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 2 | ||||
-rw-r--r-- | src/core/web_engine_library_info.cpp | 32 | ||||
-rw-r--r-- | src/core/web_engine_library_info.h | 6 | ||||
-rw-r--r-- | src/core/web_engine_settings.cpp | 19 |
5 files changed, 51 insertions, 11 deletions
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index 2d7d1eb57..cf8582ef2 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -224,7 +224,8 @@ void ContentMainDelegateQt::PreSandboxStartup() #endif if (parsedCommandLine->HasSwitch(service_manager::switches::kApplicationName)) { - const std::string appName = parsedCommandLine->GetSwitchValueASCII(service_manager::switches::kApplicationName); + std::string appName = parsedCommandLine->GetSwitchValueASCII(service_manager::switches::kApplicationName); + appName = QByteArray::fromPercentEncoding(QByteArray::fromStdString(appName)).toStdString(); QCoreApplication::setApplicationName(QString::fromStdString(appName)); #if defined(OS_LINUX) media::AudioManager::SetGlobalAppName(appName); diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index a49d8103c..32701f230 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -648,7 +648,7 @@ WebEngineContext::WebEngineContext() setupProxyPac(parsedCommandLine); parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE)); - parsedCommandLine->AppendSwitchASCII(service_manager::switches::kApplicationName, QCoreApplication::applicationName().toStdString()); + parsedCommandLine->AppendSwitchASCII(service_manager::switches::kApplicationName, QCoreApplication::applicationName().toUtf8().toPercentEncoding().toStdString()); // Enable sandboxing on OS X and Linux (Desktop / Embedded) by default. bool disable_sandbox = qEnvironmentVariableIsSet(kDisableSandboxEnv); diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 9c99e7e22..fa9e34268 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -47,6 +47,7 @@ #include "content/public/common/content_paths.h" #include "ui/base/ui_base_paths.h" #include "ui/base/ui_base_switches.h" +#include "services/service_manager/sandbox/switches.h" #include "type_conversion.h" #include <QByteArray> @@ -56,7 +57,10 @@ #include <QLibraryInfo> #include <QLocale> #include <QStandardPaths> -#include <QString> + +#if defined(OS_WIN) +#include <windows.h> +#endif // OS_WIN #ifndef QTWEBENGINEPROCESS_NAME #error "No name defined for QtWebEngine's process" @@ -178,6 +182,14 @@ QString subProcessPath() if (processPath.isEmpty()) qFatal("Could not find %s", processBinary.toUtf8().constData()); +#if defined(OS_WIN) + base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess(); + if (!parsedCommandLine->HasSwitch(service_manager::switches::kNoSandbox)) { + if (WebEngineLibraryInfo::isUNCPath(processPath) || WebEngineLibraryInfo::isRemoteDrivePath(processPath)) + qCritical("Can not launch QtWebEngineProcess from network path if sandbox is enabled: %s.", processPath.toUtf8().constData()); + } +#endif + } @@ -351,3 +363,21 @@ std::string WebEngineLibraryInfo::getApplicationLocale() return parsedCommandLine->GetSwitchValueASCII(switches::kLang); } + +#if defined(OS_WIN) +bool WebEngineLibraryInfo::isRemoteDrivePath(const QString &path) +{ + WCHAR wDriveLetter[3]; + swprintf(wDriveLetter, L"%S", path.mid(0, 3).toStdString().c_str()); + return GetDriveType(wDriveLetter) == DRIVE_REMOTE; +} + +bool WebEngineLibraryInfo::isUNCPath(const QString &path) +{ + return (base::FilePath::IsSeparator(path.at(0).toLatin1()) + && base::FilePath::IsSeparator(path.at(1).toLatin1()) + && path.at(2) != "." && path.at(2) != "?" + && path.at(2).isLetter() && path.at(3) != ":"); +} + +#endif diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h index a5cd914d3..4d23d8921 100644 --- a/src/core/web_engine_library_info.h +++ b/src/core/web_engine_library_info.h @@ -43,6 +43,8 @@ #include "base/files/file_path.h" #include "base/strings/string16.h" +#include <QString> + enum { QT_RESOURCES_PAK = 5000, QT_RESOURCES_100P_PAK = 5001, @@ -56,6 +58,10 @@ public: // Called by localized_error in our custom chrome layer static base::string16 getApplicationName(); static std::string getApplicationLocale(); +#if defined(OS_WIN) + static bool isRemoteDrivePath(const QString &path); + static bool isUNCPath(const QString &path); +#endif }; diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 93c822f2f..693c6f6fb 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -112,9 +112,8 @@ WebEngineSettings::~WebEngineSettings() if (parentSettings) parentSettings->childSettings.remove(this); // In QML the profile and its settings may be garbage collected before the page and its settings. - for (WebEngineSettings *settings : qAsConst(childSettings)) { - settings->parentSettings = 0; - } + for (WebEngineSettings *settings : qAsConst(childSettings)) + settings->parentSettings = nullptr; } void WebEngineSettings::overrideWebPreferences(content::WebContents *webContents, content::WebPreferences *prefs) @@ -141,11 +140,15 @@ void WebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool bool WebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const { - if (!parentSettings) { - Q_ASSERT(s_defaultAttributes.contains(attr)); - return m_attributes.value(attr, s_defaultAttributes.value(attr)); - } - return m_attributes.value(attr, parentSettings->testAttribute(attr)); + auto it = m_attributes.constFind(attr); + if (it != m_attributes.constEnd()) + return *it; + + if (parentSettings) + return parentSettings->testAttribute(attr); + + Q_ASSERT(s_defaultAttributes.contains(attr)); + return s_defaultAttributes.value(attr); } bool WebEngineSettings::isAttributeExplicitlySet(QWebEngineSettings::WebAttribute attr) const |