summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-02-02 13:13:10 +0100
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-02-02 13:13:10 +0100
commitca731a7446f0485886a04474415a21d2f64e3f8b (patch)
tree9ee153440866fbb28535d204f4dc467f36e867d0 /src
parent98f6e0c9d28dbcbecc560abde7606bff7c8e4d99 (diff)
parent82f4d13a13b40d9cb7710f6dd4190175a272a394 (diff)
Merge 5.6 into 5.6.0
Diffstat (limited to 'src')
m---------src/3rdparty0
-rw-r--r--src/core/api/qwebengineurlrequestjob.h4
-rw-r--r--src/core/config/common.pri10
-rw-r--r--src/core/config/embedded_qnx.pri2
-rw-r--r--src/core/config/linux.pri4
-rw-r--r--src/core/config/mac_osx.pri2
-rw-r--r--src/core/config/windows.pri2
-rw-r--r--src/core/url_request_context_getter_qt.cpp5
-rw-r--r--src/core/url_request_context_getter_qt.h2
-rw-r--r--src/core/url_request_custom_job.cpp232
-rw-r--r--src/core/url_request_custom_job.h41
-rw-r--r--src/core/url_request_custom_job_delegate.cpp19
-rw-r--r--src/core/url_request_custom_job_delegate.h8
-rw-r--r--src/webengine/doc/src/webengineview.qdoc16
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp18
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.cpp12
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection_p.h2
18 files changed, 274 insertions, 106 deletions
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 77b91185050176b88c446fdb1b33b92dd737dd8
+Subproject 3f655a31b4979b0862e5aec1c8f47b597464749
diff --git a/src/core/api/qwebengineurlrequestjob.h b/src/core/api/qwebengineurlrequestjob.h
index 922299fd9..84741b791 100644
--- a/src/core/api/qwebengineurlrequestjob.h
+++ b/src/core/api/qwebengineurlrequestjob.h
@@ -44,8 +44,8 @@
#include <QtCore/qurl.h>
namespace QtWebEngineCore {
-class URLRequestCustomJob;
class URLRequestCustomJobDelegate;
+class URLRequestCustomJobShared;
} // namespace
QT_BEGIN_NAMESPACE
@@ -76,7 +76,7 @@ public:
private:
QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *);
- friend class QtWebEngineCore::URLRequestCustomJob;
+ friend class QtWebEngineCore::URLRequestCustomJobShared;
QtWebEngineCore::URLRequestCustomJobDelegate* d_ptr;
};
diff --git a/src/core/config/common.pri b/src/core/config/common.pri
new file mode 100644
index 000000000..c5921a573
--- /dev/null
+++ b/src/core/config/common.pri
@@ -0,0 +1,10 @@
+# Shared configuration for all our supported platforms
+
+# Trigger Qt-specific build conditions.
+GYP_CONFIG += use_qt=1
+# We do not want to ship more external binary blobs, so let v8 embed its startup data.
+GYP_CONFIG += v8_use_external_startup_data=0
+# Disable printing since we don't support it yet
+GYP_CONFIG += enable_basic_printing=0 enable_print_preview=0
+# WebSpeech requires Google API keys and adds dependencies on speex and flac.
+GYP_CONFIG += enable_web_speech=0
diff --git a/src/core/config/embedded_qnx.pri b/src/core/config/embedded_qnx.pri
index 7fd35c976..34470d2d8 100644
--- a/src/core/config/embedded_qnx.pri
+++ b/src/core/config/embedded_qnx.pri
@@ -1,5 +1,7 @@
GYP_ARGS += "-D qt_os=\"embedded_qnx\" -I config/embedded_qnx.gypi"
+include(common.pri)
+
GYP_CONFIG += \
disable_nacl=1 \
enable_plugins=0 \
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index 9868d6848..00e25ec58 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -1,3 +1,5 @@
+include(common.pri)
+
# linux_use_bundled_gold currently relies on a hardcoded relative path from chromium/src/out/(Release|Debug)
# Disable it along with the -Wl,--threads flag just in case gold isn't installed on the system.
GYP_CONFIG += \
@@ -34,11 +36,9 @@ use?(system_libevent): GYP_CONFIG += use_system_libevent=1
use?(system_libwebp): GYP_CONFIG += use_system_libwebp=1
use?(system_libsrtp): GYP_CONFIG += use_system_libsrtp=1
use?(system_libxslt): GYP_CONFIG += use_system_libxml=1
-use?(system_flac): GYP_CONFIG += use_system_flac=1
use?(system_jsoncpp): GYP_CONFIG += use_system_jsoncpp=1
use?(system_opus): GYP_CONFIG += use_system_opus=1
use?(system_snappy): GYP_CONFIG += use_system_snappy=1
-use?(system_speex): GYP_CONFIG += use_system_speex=1
use?(system_vpx): GYP_CONFIG += use_system_libvpx=1
use?(system_icu): GYP_CONFIG += use_system_icu=1
use?(system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1
diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri
index 93c77623c..940b47982 100644
--- a/src/core/config/mac_osx.pri
+++ b/src/core/config/mac_osx.pri
@@ -1,3 +1,5 @@
+include(common.pri)
+
QMAKE_CLANG_DIR = "/usr"
QMAKE_CLANG_PATH = $$eval(QMAKE_MAC_SDK.macx-clang.$${QMAKE_MAC_SDK}.QMAKE_CXX)
!isEmpty(QMAKE_CLANG_PATH) {
diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index 1e875f308..760ed5b6f 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -1,5 +1,7 @@
GYP_ARGS += "-D qt_os=\"win32\" -I config/windows.gypi"
+include(common.pri)
+
GYP_CONFIG += \
disable_nacl=1 \
remoting=0 \
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 618354d1c..20efec295 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -127,8 +127,9 @@ void URLRequestContextGetterQt::updateStorageSettings()
content::BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
content::BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
));
- if (m_storage)
+ if (m_storage) {
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestContextGetterQt::generateStorage, this));
+ }
}
}
@@ -283,7 +284,7 @@ void URLRequestContextGetterQt::generateUserAgent()
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_storage);
- m_storage->set_http_user_agent_settings(new HttpUserAgentSettingsQt(m_browserContext));
+ m_storage->set_http_user_agent_settings(new HttpUserAgentSettingsQt(m_browserContext.constData()));
}
void URLRequestContextGetterQt::updateHttpCache()
diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h
index 8740c65a2..555d56784 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -94,7 +94,7 @@ private:
bool m_ignoreCertificateErrors;
QAtomicInt m_updateCookieStore;
QAtomicInt m_updateHttpCache;
- BrowserContextAdapter *m_browserContext;
+ QExplicitlySharedDataPointer<BrowserContextAdapter> m_browserContext;
content::ProtocolHandlerMap m_protocolHandlers;
QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index 907f71c2e..07087c247 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -56,46 +56,33 @@ namespace QtWebEngineCore {
URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, QWebEngineUrlSchemeHandler *schemeHandler)
: URLRequestJob(request, networkDelegate)
- , m_device(0)
, m_schemeHandler(schemeHandler)
- , m_error(0)
- , m_started(false)
- , m_weakFactoryIO(this)
- , m_weakFactoryUI(this)
+ , m_shared(new URLRequestCustomJobShared(this))
{
}
URLRequestCustomJob::~URLRequestCustomJob()
{
- QMutexLocker lock(&m_mutex);
- if (m_delegate) {
- m_delegate->m_job = 0;
- m_delegate->deleteLater();
- }
- if (m_device && m_device->isOpen())
- m_device->close();
+ if (m_shared)
+ m_shared->killJob();
+}
+
+static void startAsync(URLRequestCustomJobShared *shared)
+{
+ shared->startAsync();
}
void URLRequestCustomJob::Start()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&URLRequestCustomJob::startAsync, m_weakFactoryIO.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, base::Bind(&startAsync, m_shared));
}
void URLRequestCustomJob::Kill()
{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- QMutexLocker lock(&m_mutex);
- if (m_delegate) {
- m_delegate->m_job = 0;
- m_delegate->deleteLater();
- }
- m_delegate = 0;
- if (m_device && m_device->isOpen())
- m_device->close();
- m_device = 0;
- m_weakFactoryIO.InvalidateWeakPtrs();
- m_weakFactoryUI.InvalidateWeakPtrs();
+ if (m_shared)
+ m_shared->killJob();
+ m_shared = 0;
URLRequestJob::Kill();
}
@@ -103,8 +90,11 @@ void URLRequestCustomJob::Kill()
bool URLRequestCustomJob::GetMimeType(std::string *mimeType) const
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- if (m_mimeType.size() > 0) {
- *mimeType = m_mimeType;
+ if (!m_shared)
+ return false;
+ QMutexLocker lock(&m_shared->m_mutex);
+ if (m_shared->m_mimeType.size() > 0) {
+ *mimeType = m_shared->m_mimeType;
return true;
}
return false;
@@ -113,8 +103,11 @@ bool URLRequestCustomJob::GetMimeType(std::string *mimeType) const
bool URLRequestCustomJob::GetCharset(std::string* charset)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- if (m_charset.size() > 0) {
- *charset = m_charset;
+ if (!m_shared)
+ return false;
+ QMutexLocker lock(&m_shared->m_mutex);
+ if (m_shared->m_charset.size() > 0) {
+ *charset = m_shared->m_charset;
return true;
}
return false;
@@ -123,128 +116,223 @@ bool URLRequestCustomJob::GetCharset(std::string* charset)
bool URLRequestCustomJob::IsRedirectResponse(GURL* location, int* http_status_code)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- QMutexLocker lock(&m_mutex);
- if (m_redirect.is_valid()) {
- *location = m_redirect;
+ if (!m_shared)
+ return false;
+ QMutexLocker lock(&m_shared->m_mutex);
+ if (m_shared->m_redirect.is_valid()) {
+ *location = m_shared->m_redirect;
*http_status_code = 303;
return true;
}
return false;
}
-void URLRequestCustomJob::setReplyMimeType(const std::string &mimeType)
+bool URLRequestCustomJob::ReadRawData(IOBuffer *buf, int bufSize, int *bytesRead)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ Q_ASSERT(bytesRead);
+ Q_ASSERT(m_shared);
+ QMutexLocker lock(&m_shared->m_mutex);
+ qint64 rv = m_shared->m_device ? m_shared->m_device->read(buf->data(), bufSize) : -1;
+ if (rv >= 0) {
+ *bytesRead = static_cast<int>(rv);
+ return true;
+ } else {
+ NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, ERR_FAILED));
+ }
+ return false;
+}
+
+URLRequestCustomJobShared::URLRequestCustomJobShared(URLRequestCustomJob *job)
+ : m_mutex(QMutex::Recursive)
+ , m_job(job)
+ , m_delegate(0)
+ , m_error(0)
+ , m_started(false)
+ , m_asyncInitialized(false)
+ , m_weakFactory(this)
+{
+}
+
+URLRequestCustomJobShared::~URLRequestCustomJobShared()
+{
+ Q_ASSERT(!m_job);
+ Q_ASSERT(!m_delegate);
+}
+
+void URLRequestCustomJobShared::killJob()
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ QMutexLocker lock(&m_mutex);
+ m_job = 0;
+ bool doDelete = false;
+ if (m_delegate) {
+ m_delegate->deleteLater();
+ } else {
+ // Do not delete yet if startAsync has not yet run.
+ doDelete = m_asyncInitialized;
+ }
+ if (m_device && m_device->isOpen())
+ m_device->close();
+ m_device = 0;
+ m_weakFactory.InvalidateWeakPtrs();
+ lock.unlock();
+ if (doDelete)
+ delete this;
+}
+
+void URLRequestCustomJobShared::unsetJobDelegate()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ QMutexLocker lock(&m_mutex);
+ m_delegate = 0;
+ bool doDelete = false;
+ if (m_job)
+ abort();
+ else
+ doDelete = true;
+ lock.unlock();
+ if (doDelete)
+ delete this;
+}
+
+void URLRequestCustomJobShared::setReplyMimeType(const std::string &mimeType)
+{
+ DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ QMutexLocker lock(&m_mutex);
m_mimeType = mimeType;
}
-void URLRequestCustomJob::setReplyCharset(const std::string &charset)
+void URLRequestCustomJobShared::setReplyCharset(const std::string &charset)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+ QMutexLocker lock(&m_mutex);
m_charset = charset;
}
-void URLRequestCustomJob::setReplyDevice(QIODevice *device)
+void URLRequestCustomJobShared::setReplyDevice(QIODevice *device)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
QMutexLocker lock(&m_mutex);
+ if (!m_job)
+ return;
m_device = device;
if (m_device && !m_device->isReadable())
m_device->open(QIODevice::ReadOnly);
if (m_device && m_device->isReadable())
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactoryUI.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJobShared::notifyStarted, m_weakFactory.GetWeakPtr()));
else
fail(ERR_INVALID_URL);
}
-bool URLRequestCustomJob::ReadRawData(IOBuffer *buf, int bufSize, int *bytesRead)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- Q_ASSERT(bytesRead);
- QMutexLocker lock(&m_mutex);
- qint64 rv = m_device ? m_device->read(buf->data(), bufSize) : -1;
- if (rv >= 0) {
- *bytesRead = static_cast<int>(rv);
- return true;
- } else {
- NotifyDone(URLRequestStatus(URLRequestStatus::FAILED, ERR_FAILED));
- }
- return false;
-}
-
-void URLRequestCustomJob::redirect(const GURL &url)
+void URLRequestCustomJobShared::redirect(const GURL &url)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- if (m_device || m_error)
- return;
QMutexLocker lock(&m_mutex);
+ if (m_device || m_error)
+ return;
+ if (!m_job)
+ return;
m_redirect = url;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyStarted, m_weakFactoryUI.GetWeakPtr()));
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJobShared::notifyStarted, m_weakFactory.GetWeakPtr()));
}
-void URLRequestCustomJob::abort()
+void URLRequestCustomJobShared::abort()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
QMutexLocker lock(&m_mutex);
if (m_device && m_device->isOpen())
m_device->close();
m_device = 0;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyCanceled, m_weakFactoryUI.GetWeakPtr()));
+ if (!m_job)
+ return;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJobShared::notifyCanceled, m_weakFactory.GetWeakPtr()));
}
-void URLRequestCustomJob::notifyCanceled()
+void URLRequestCustomJobShared::notifyCanceled()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ QMutexLocker lock(&m_mutex);
+ if (!m_job)
+ return;
if (m_started)
- NotifyDone(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED));
+ m_job->NotifyDone(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED));
else
- NotifyStartError(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED));
+ m_job->NotifyStartError(URLRequestStatus(URLRequestStatus::CANCELED, ERR_ABORTED));
}
-void URLRequestCustomJob::notifyStarted()
+void URLRequestCustomJobShared::notifyStarted()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+ QMutexLocker lock(&m_mutex);
+ if (!m_job)
+ return;
Q_ASSERT(!m_started);
m_started = true;
- NotifyHeadersComplete();
+ m_job->NotifyHeadersComplete();
}
-void URLRequestCustomJob::fail(int error)
+void URLRequestCustomJobShared::fail(int error)
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
QMutexLocker lock(&m_mutex);
m_error = error;
- content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJob::notifyFailure, m_weakFactoryUI.GetWeakPtr()));
+ if (!m_job)
+ return;
+ content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestCustomJobShared::notifyFailure, m_weakFactory.GetWeakPtr()));
}
-void URLRequestCustomJob::notifyFailure()
+void URLRequestCustomJobShared::notifyFailure()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
- m_mutex.lock();
+ QMutexLocker lock(&m_mutex);
+ if (!m_job)
+ return;
if (m_device)
m_device->close();
const URLRequestStatus status(URLRequestStatus::FAILED, m_error);
const bool started = m_started;
- m_mutex.unlock();
if (started)
- NotifyDone(status);
+ m_job->NotifyDone(status);
else
- NotifyStartError(status);
+ m_job->NotifyStartError(status);
}
-void URLRequestCustomJob::startAsync()
+GURL URLRequestCustomJobShared::requestUrl()
+{
+ QMutexLocker lock(&m_mutex);
+ if (!m_job)
+ return GURL();
+ return m_job->request()->url();
+}
+
+std::string URLRequestCustomJobShared::requestMethod()
+{
+ QMutexLocker lock(&m_mutex);
+ if (!m_job)
+ return std::string();
+ return m_job->request()->method();
+}
+
+void URLRequestCustomJobShared::startAsync()
{
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
Q_ASSERT(!m_started);
Q_ASSERT(!m_delegate);
QMutexLocker lock(&m_mutex);
+ if (!m_job) {
+ lock.unlock();
+ delete this;
+ return;
+ }
m_delegate = new URLRequestCustomJobDelegate(this);
- lock.unlock();
+ m_asyncInitialized = true;
QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(m_delegate);
- m_schemeHandler->requestStarted(requestJob);
+ if (m_job)
+ m_job->m_schemeHandler->requestStarted(requestJob);
}
} // namespace
diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h
index be5cae43c..eedb41814 100644
--- a/src/core/url_request_custom_job.h
+++ b/src/core/url_request_custom_job.h
@@ -50,6 +50,7 @@ QT_FORWARD_DECLARE_CLASS(QWebEngineUrlSchemeHandler)
namespace QtWebEngineCore {
class URLRequestCustomJobDelegate;
+class URLRequestCustomJobShared;
// A request job that handles reading custom URL schemes
class URLRequestCustomJob : public net::URLRequestJob {
@@ -62,6 +63,25 @@ public:
virtual bool GetCharset(std::string *charset) Q_DECL_OVERRIDE;
virtual bool IsRedirectResponse(GURL* location, int* http_status_code) Q_DECL_OVERRIDE;
+protected:
+ virtual ~URLRequestCustomJob();
+
+private:
+ QWebEngineUrlSchemeHandler *m_schemeHandler;
+ URLRequestCustomJobShared *m_shared;
+
+ friend class URLRequestCustomJobShared;
+
+ DISALLOW_COPY_AND_ASSIGN(URLRequestCustomJob);
+};
+
+// A shared state between URLRequestCustomJob living on the IO thread
+// and URLRequestCustomJobDelegate living on the UI thread.
+class URLRequestCustomJobShared {
+public:
+ URLRequestCustomJobShared(URLRequestCustomJob *job);
+ ~URLRequestCustomJobShared();
+
void setReplyMimeType(const std::string &);
void setReplyCharset(const std::string &);
void setReplyDevice(QIODevice *);
@@ -70,29 +90,28 @@ public:
void fail(int);
void abort();
-protected:
- virtual ~URLRequestCustomJob();
+ void killJob();
+ void unsetJobDelegate();
+
void startAsync();
void notifyStarted();
void notifyFailure();
void notifyCanceled();
-private:
+ GURL requestUrl();
+ std::string requestMethod();
+
QMutex m_mutex;
QPointer<QIODevice> m_device;
- QPointer<URLRequestCustomJobDelegate> m_delegate;
- QWebEngineUrlSchemeHandler *m_schemeHandler;
+ URLRequestCustomJob *m_job;
+ URLRequestCustomJobDelegate *m_delegate;
std::string m_mimeType;
std::string m_charset;
int m_error;
GURL m_redirect;
bool m_started;
- base::WeakPtrFactory<URLRequestCustomJob> m_weakFactoryIO;
- base::WeakPtrFactory<URLRequestCustomJob> m_weakFactoryUI;
-
- friend class URLRequestCustomJobDelegate;
-
- DISALLOW_COPY_AND_ASSIGN(URLRequestCustomJob);
+ bool m_asyncInitialized;
+ base::WeakPtrFactory<URLRequestCustomJobShared> m_weakFactory;
};
} // namespace QtWebEngineCore
diff --git a/src/core/url_request_custom_job_delegate.cpp b/src/core/url_request_custom_job_delegate.cpp
index 0650242c8..1a3e08e52 100644
--- a/src/core/url_request_custom_job_delegate.cpp
+++ b/src/core/url_request_custom_job_delegate.cpp
@@ -44,39 +44,40 @@
namespace QtWebEngineCore {
-URLRequestCustomJobDelegate::URLRequestCustomJobDelegate(URLRequestCustomJob *job)
- : m_job(job)
+URLRequestCustomJobDelegate::URLRequestCustomJobDelegate(URLRequestCustomJobShared *shared)
+ : m_shared(shared)
{
}
URLRequestCustomJobDelegate::~URLRequestCustomJobDelegate()
{
+ m_shared->unsetJobDelegate();
}
QUrl URLRequestCustomJobDelegate::url() const
{
- return toQt(m_job->request()->url());
+ return toQt(m_shared->requestUrl());
}
QByteArray URLRequestCustomJobDelegate::method() const
{
- return QByteArray::fromStdString(m_job->request()->method());
+ return QByteArray::fromStdString(m_shared->requestMethod());
}
void URLRequestCustomJobDelegate::setReply(const QByteArray &contentType, QIODevice *device)
{
- m_job->setReplyMimeType(contentType.toStdString());
- m_job->setReplyDevice(device);
+ m_shared->setReplyMimeType(contentType.toStdString());
+ m_shared->setReplyDevice(device);
}
void URLRequestCustomJobDelegate::abort()
{
- m_job->abort();
+ m_shared->abort();
}
void URLRequestCustomJobDelegate::redirect(const QUrl &url)
{
- m_job->redirect(toGurl(url));
+ m_shared->redirect(toGurl(url));
}
void URLRequestCustomJobDelegate::fail(Error error)
@@ -102,7 +103,7 @@ void URLRequestCustomJobDelegate::fail(Error error)
break;
}
if (net_error)
- m_job->fail(net_error);
+ m_shared->fail(net_error);
}
} // namespace
diff --git a/src/core/url_request_custom_job_delegate.h b/src/core/url_request_custom_job_delegate.h
index 5b6137820..e066e85cc 100644
--- a/src/core/url_request_custom_job_delegate.h
+++ b/src/core/url_request_custom_job_delegate.h
@@ -46,7 +46,7 @@ QT_FORWARD_DECLARE_CLASS(QIODevice)
namespace QtWebEngineCore {
-class URLRequestCustomJob;
+class URLRequestCustomJobShared;
class QWEBENGINE_EXPORT URLRequestCustomJobDelegate : public QObject {
Q_OBJECT
@@ -72,10 +72,10 @@ public:
void fail(Error);
private:
- URLRequestCustomJobDelegate(URLRequestCustomJob *job);
+ URLRequestCustomJobDelegate(URLRequestCustomJobShared *shared);
- friend class URLRequestCustomJob;
- URLRequestCustomJob *m_job;
+ friend class URLRequestCustomJobShared;
+ URLRequestCustomJobShared *m_shared;
};
} // namespace
diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc
index a8cd1eb56..1d71a9cd9 100644
--- a/src/webengine/doc/src/webengineview.qdoc
+++ b/src/webengine/doc/src/webengineview.qdoc
@@ -29,6 +29,22 @@
\inqmlmodule QtWebEngine
\since QtWebEngine 1.0
\brief A WebEngineView renders web content within a QML application.
+
+ The WebEngineView type enables QML applications to render regions of dynamic web content. It
+ may share the screen with other QML types, such as a TabView, or fill the screen, as specified
+ within the QML application.
+
+ \section1 Rendering to OpenGL Surface
+
+ When using a QQuickRenderControl to render a Qt Quick user interface to an OpenGL surface, the
+ WebEngineView type is not rendered correctly. The web engine view attempts to use a global
+ OpenGL context created by \l QtWebEngine::initialize(), but there is no public API for accessing
+ that context in order to share it with the \c QQuickRenderControl context.
+
+ To have the web engine view rendered correctly, it is possible to manually create a new
+ offscreen context that is shared with the \c QQuickRenderControl and to call the non-public
+ function \c qt_gl_set_global_share_context(), rather than calling \c initialize().
+ If \c initialize() is called after setting a global context, it will do nothing.
*/
/*!
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index aacf6c455..b1bf33067 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -107,6 +107,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, m_isBeingAdopted(false)
, m_backgroundColor(Qt::white)
, fullscreenMode(false)
+ , webChannel(nullptr)
{
memset(actions, 0, sizeof(actions));
}
@@ -227,6 +228,8 @@ void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, W
Q_UNUSED(userGesture);
QWebEnginePage *newPage = q->createWindow(toWindowType(disposition));
+ if (!newPage)
+ return;
// Mark the new page as being in the process of being adopted, so that a second mouse move event
// sent by newWebContents->initialize() gets filtered in RenderWidgetHostViewQt::forwardEvent.
@@ -240,7 +243,7 @@ void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, W
newPage->d_func()->m_isBeingAdopted = true;
// Overwrite the new page's WebContents with ours.
- if (newPage && newPage->d_func() != this) {
+ if (newPage->d_func() != this) {
newPage->d_func()->adapter = newWebContents;
newWebContents->initialize(newPage->d_func());
if (!initialGeometry.isEmpty())
@@ -405,8 +408,14 @@ void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input)
{
QExplicitlySharedDataPointer<WebContentsAdapter> newWebContents = WebContentsAdapter::createFromSerializedNavigationHistory(input, this);
if (newWebContents) {
+ // Keep the old adapter referenced so the user-scripts are not
+ // unregistered immediately.
+ QExplicitlySharedDataPointer<WebContentsAdapter> oldWebContents = adapter;
adapter = newWebContents.data();
adapter->initialize(this);
+ if (webChannel)
+ adapter->setWebChannel(webChannel);
+ scriptCollection.d->rebindToContents(adapter.data());
}
}
@@ -517,7 +526,7 @@ QWebEngineSettings *QWebEnginePage::settings() const
QWebChannel *QWebEnginePage::webChannel() const
{
Q_D(const QWebEnginePage);
- return d->adapter->webChannel();
+ return d->webChannel;
}
/*!
@@ -534,7 +543,10 @@ QWebChannel *QWebEnginePage::webChannel() const
void QWebEnginePage::setWebChannel(QWebChannel *channel)
{
Q_D(QWebEnginePage);
- d->adapter->setWebChannel(channel);
+ if (d->webChannel != channel) {
+ d->webChannel = channel;
+ d->adapter->setWebChannel(channel);
+ }
}
/*!
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 9cc4553d1..18110d923 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -151,6 +151,7 @@ public:
bool m_isBeingAdopted;
QColor m_backgroundColor;
bool fullscreenMode;
+ QWebChannel *webChannel;
mutable QtWebEngineCore::CallbackDirectory m_callbacks;
mutable QAction *actions[QWebEnginePage::WebActionCount];
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
index 9967cde85..117c35b5a 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
@@ -220,3 +220,15 @@ void QWebEngineScriptCollectionPrivate::reserve(int capacity)
{
m_scriptController->reserve(m_contents, capacity);
}
+
+void QWebEngineScriptCollectionPrivate::rebindToContents(QtWebEngineCore::WebContentsAdapter *page)
+{
+ Q_ASSERT(m_contents);
+ Q_ASSERT(page);
+ Q_ASSERT(m_contents != page);
+
+ Q_FOREACH (const UserScript &script, m_scriptController->registeredScripts(m_contents)) {
+ m_scriptController->addUserScript(script, page);
+ }
+ m_contents = page;
+}
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection_p.h b/src/webenginewidgets/api/qwebenginescriptcollection_p.h
index cc6e88445..b5ae60a2c 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection_p.h
+++ b/src/webenginewidgets/api/qwebenginescriptcollection_p.h
@@ -69,6 +69,8 @@ public:
QList<QWebEngineScript> toList(const QString &scriptName = QString()) const;
QWebEngineScript find(const QString & name) const;
+ void rebindToContents(QtWebEngineCore::WebContentsAdapter *contents);
+
void insert(const QWebEngineScript &);
bool remove(const QWebEngineScript &);
void clear();