summaryrefslogtreecommitdiffstats
path: root/src/core/url_request_custom_job.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-25 11:47:47 +0200
committerAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2016-04-25 12:40:00 +0200
commit658a964cf2593e6da3b1a822124e796bbe354d36 (patch)
tree8c35a964023069a974f1c54cd679490593e485f2 /src/core/url_request_custom_job.cpp
parent63cf26268996ae5580c77095a252696fa549b593 (diff)
parenta3318c84b022282a5a4a2babc51d1e3ca634e25b (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Diffstat (limited to 'src/core/url_request_custom_job.cpp')
-rw-r--r--src/core/url_request_custom_job.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index 79a54650c..921be0b41 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -42,6 +42,7 @@
#include "api/qwebengineurlrequestjob.h"
#include "api/qwebengineurlschemehandler.h"
+#include "browser_context_adapter.h"
#include "type_conversion.h"
#include "content/public/browser/browser_thread.h"
@@ -57,9 +58,11 @@ using namespace net;
namespace QtWebEngineCore {
-URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, QWebEngineUrlSchemeHandler *schemeHandler)
+URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate,
+ const std::string &scheme, QWeakPointer<const BrowserContextAdapter> adapter)
: URLRequestJob(request, networkDelegate)
- , m_schemeHandler(schemeHandler)
+ , m_scheme(scheme)
+ , m_adapter(adapter)
, m_shared(new URLRequestCustomJobShared(this))
{
}
@@ -328,11 +331,22 @@ void URLRequestCustomJobShared::startAsync()
delete this;
return;
}
- m_delegate = new URLRequestCustomJobDelegate(this);
- m_asyncInitialized = true;
- QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(m_delegate);
- if (m_job)
- m_job->m_schemeHandler->requestStarted(requestJob);
+
+ QWebEngineUrlSchemeHandler *schemeHandler = 0;
+ QSharedPointer<const BrowserContextAdapter> browserContext = m_job->m_adapter.toStrongRef();
+ if (browserContext)
+ schemeHandler = browserContext->customUrlSchemeHandlers()[toQByteArray(m_job->m_scheme)];
+ if (schemeHandler) {
+ m_delegate = new URLRequestCustomJobDelegate(this);
+ m_asyncInitialized = true;
+ QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(m_delegate);
+ schemeHandler->requestStarted(requestJob);
+ } else {
+ lock.unlock();
+ abort();
+ delete this;
+ return;
+ }
}
} // namespace