summaryrefslogtreecommitdiffstats
path: root/src/core/content_browser_client_qt.cpp
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2019-11-26 13:21:02 +0100
committerJüri Valdmann <juri.valdmann@qt.io>2019-11-28 15:06:49 +0100
commit8a1bf3a9a59509d33d5c4e45b743d9b57f5c44ac (patch)
tree98b35c407fa5687188f07f17010c2756b80db404 /src/core/content_browser_client_qt.cpp
parent496bb6214668dbcf559a10be132f2fb4cfc67922 (diff)
Fix loading resources over qrc
The network service patch causes some test failures (with network service *disabled*) because of the new method override IsHandledURL that was added to ContentBrowserClientQt. The problem is that CanRequestURL in ChildSecurityPolicyImpl forbids child processes from requesting URLs which should be handled by the browser process, that is, URLs for which IsHandledURL is true. Fix by explicitly granting permission to request custom schemes. Change-Id: I970061de7ffb224de6121b85c1d5025a76f71e9a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/content_browser_client_qt.cpp')
-rw-r--r--src/core/content_browser_client_qt.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 49617329e..2c9967fec 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -284,9 +284,16 @@ void ContentBrowserClientQt::RenderProcessWillLaunch(content::RenderProcessHost*
base::BindOnce(&net::URLRequestContextGetter::GetURLRequestContext, base::Unretained(profile->GetRequestContext())),
base::BindOnce(&ContentBrowserClientQt::AddNetworkHintsMessageFilter, base::Unretained(this), id));
+ // Allow requesting custom schemes.
+ const auto policy = content::ChildProcessSecurityPolicy::GetInstance();
+ const auto profileQt = static_cast<ProfileQt *>(host->GetBrowserContext());
+ const auto profileAdapter = profileQt->profileAdapter();
+ for (const QByteArray &scheme : profileAdapter->customUrlSchemes())
+ policy->GrantRequestScheme(id, scheme.toStdString());
+
// FIXME: Add a settings variable to enable/disable the file scheme.
- content::ChildProcessSecurityPolicy::GetInstance()->GrantRequestScheme(id, url::kFileScheme);
- static_cast<ProfileQt*>(host->GetBrowserContext())->m_profileAdapter->userResourceController()->renderProcessStartedWithHost(host);
+ policy->GrantRequestScheme(id, url::kFileScheme);
+ profileAdapter->userResourceController()->renderProcessStartedWithHost(host);
host->AddFilter(new BrowserMessageFilterQt(id, profile));
#if QT_CONFIG(webengine_printing_and_pdf)
host->AddFilter(new PrintingMessageFilterQt(host->GetID()));