diff options
author | Michal Klocek <michal.klocek@qt.io> | 2020-02-13 14:28:47 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2020-02-21 09:31:00 +0100 |
commit | 50bc8b124705c33c5e27f035b1eab756e14247ba (patch) | |
tree | 0816305b672bbe85c3242c91dcc50cee4c7607a2 /src | |
parent | 7cc93a0953e5f923699c1945b17706364f0f2160 (diff) |
Fix not working proxy_pac test with network service
Due to sandboxing we can no longer pass pac file.
Pass it as data url instead by reading the pac file and
encoding into base64.
Fix failing proxypac url on windows.
Fixes: QTBUG-81557
Change-Id: I3dc3da4fbd3cce4e903c75022b8e9fe5faf71604
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/web_engine_context.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index deb67fe6f..79c093fab 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -49,6 +49,7 @@ #include "base/task/sequence_manager/thread_controller_with_message_pump_impl.h" #include "base/threading/thread_restrictions.h" #include "cc/base/switches.h" +#include "chrome/common/chrome_switches.h" #if QT_CONFIG(webengine_printing_and_pdf) #include "chrome/browser/printing/print_job_manager.h" #include "components/printing/browser/features.h" @@ -212,6 +213,21 @@ bool usingSoftwareDynamicGL() #endif } +void setupProxyPac(base::CommandLine *commandLine){ + if (commandLine->HasSwitch(switches::kProxyPacUrl)) { + QUrl pac_url(toQt(commandLine->GetSwitchValueASCII(switches::kProxyPacUrl))); + if (pac_url.isValid() && pac_url.isLocalFile()) { + QFile file(pac_url.toLocalFile()); + if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { + QByteArray ba = file.readAll(); + commandLine->RemoveSwitch(switches::kProxyPacUrl); + commandLine->AppendSwitchASCII(switches::kProxyPacUrl, + ba.toBase64().prepend("data:application/x-javascript-config;base64,").toStdString()); + } + } + } +} + scoped_refptr<QtWebEngineCore::WebEngineContext> WebEngineContext::m_handle; bool WebEngineContext::m_destroyed = false; @@ -463,7 +479,7 @@ WebEngineContext::WebEngineContext() #endif base::CommandLine* parsedCommandLine = commandLine(); - + setupProxyPac(parsedCommandLine); parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE)); // Enable sandboxing on OS X and Linux (Desktop / Embedded) by default. |