summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp14
-rw-r--r--src/core/api/qwebengineurlrequestinfo.h1
-rw-r--r--src/core/api/qwebengineurlrequestinfo_p.h2
-rw-r--r--src/core/api/qwebengineurlrequestjob.cpp38
-rw-r--r--src/core/api/qwebengineurlrequestjob.h14
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp28
-rw-r--r--src/core/api/qwebengineurlschemehandler.h9
-rw-r--r--src/core/api/qwebengineurlschemehandler_p.h19
-rw-r--r--src/core/browser_context_adapter.cpp11
-rw-r--r--src/core/browser_context_adapter.h8
-rw-r--r--src/core/config/embedded_linux.pri3
-rw-r--r--src/core/config/linux.pri35
-rw-r--r--src/core/cookie_monster_delegate_qt.cpp2
-rw-r--r--src/core/core_gyp_generator.pro2
-rw-r--r--src/core/core_module.pro2
-rw-r--r--src/core/custom_protocol_handler.cpp2
-rw-r--r--src/core/custom_protocol_handler.h6
-rw-r--r--src/core/custom_url_scheme_handler.cpp63
-rw-r--r--src/core/custom_url_scheme_handler.h71
-rw-r--r--src/core/download_manager_delegate_qt.cpp4
-rw-r--r--src/core/javascript_dialog_manager_qt.cpp6
-rw-r--r--src/core/javascript_dialog_manager_qt.h2
-rw-r--r--src/core/location_provider_qt.cpp17
-rw-r--r--src/core/network_delegate_qt.cpp3
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.cpp29
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.h3
-rw-r--r--src/core/url_request_context_getter_qt.cpp6
-rw-r--r--src/core/url_request_custom_job.cpp8
-rw-r--r--src/core/url_request_custom_job.h6
-rw-r--r--src/core/user_script.cpp11
-rw-r--r--src/core/user_script.h4
-rw-r--r--src/core/user_script_controller_host.cpp31
-rw-r--r--src/core/user_script_controller_host.h6
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h2
-rw-r--r--src/core/web_contents_delegate_qt.cpp24
-rw-r--r--src/core/web_contents_delegate_qt.h2
38 files changed, 230 insertions, 271 deletions
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
index b769081f8..e8ce65be3 100644
--- a/src/core/api/qwebengineurlrequestinfo.cpp
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -119,11 +119,12 @@ ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, Q
*/
-QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QByteArray &m)
+QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QUrl &fpu, const QByteArray &m)
: resourceType(resource)
, navigationType(navigation)
, shouldBlockRequest(false)
, url(u)
+ , firstPartyUrl(fpu)
, method(m)
{
}
@@ -218,6 +219,17 @@ QUrl QWebEngineUrlRequestInfo::requestUrl() const
return d->url;
}
+/*!
+ Returns the first party URL of the request.
+ The first party URL is the URL of the page that issued the request.
+*/
+
+QUrl QWebEngineUrlRequestInfo::firstPartyUrl() const
+{
+ Q_D(const QWebEngineUrlRequestInfo);
+ return d->firstPartyUrl;
+}
+
/*!
Returns the HTTP method of the request (for example, GET or POST).
diff --git a/src/core/api/qwebengineurlrequestinfo.h b/src/core/api/qwebengineurlrequestinfo.h
index 7c016d20d..e6e225051 100644
--- a/src/core/api/qwebengineurlrequestinfo.h
+++ b/src/core/api/qwebengineurlrequestinfo.h
@@ -86,6 +86,7 @@ public:
NavigationType navigationType() const;
QUrl requestUrl() const;
+ QUrl firstPartyUrl() const;
QByteArray requestMethod() const;
void block(bool shouldBlock);
diff --git a/src/core/api/qwebengineurlrequestinfo_p.h b/src/core/api/qwebengineurlrequestinfo_p.h
index b6a304a03..1b1279d27 100644
--- a/src/core/api/qwebengineurlrequestinfo_p.h
+++ b/src/core/api/qwebengineurlrequestinfo_p.h
@@ -58,6 +58,7 @@ public:
QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource
, QWebEngineUrlRequestInfo::NavigationType navigation
, const QUrl &u
+ , const QUrl &fpu
, const QByteArray &m);
QWebEngineUrlRequestInfo::ResourceType resourceType;
@@ -65,6 +66,7 @@ public:
bool shouldBlockRequest;
QUrl url;
+ QUrl firstPartyUrl;
const QByteArray method;
QHash<QByteArray, QByteArray> extraHeaders;
diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp
index d9f3833b9..0e56ba5b3 100644
--- a/src/core/api/qwebengineurlrequestjob.cpp
+++ b/src/core/api/qwebengineurlrequestjob.cpp
@@ -48,18 +48,36 @@ QT_BEGIN_NAMESPACE
\since 5.6
A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must
- be handled by the derived implementations of the class.
+ be handled by the derived implementations of the class. The job can be handled by calling
+ either reply(), redirect(), or fail().
- A job can be handled by calling either reply(), redirect() or fail().
-
- The class is owned by QtWebEngine and does not need to be deleted. Note QtWebEngine may delete
- the job when it is no longer needed, so the signal QObject::destroyed() must be monitored if
- a pointer to the object is stored.
+ The class is owned by the web engine and does not need to be deleted. However, the web engine
+ may delete the job when it is no longer needed, and therefore the signal QObject::destroyed()
+ must be monitored if a pointer to the object is stored.
\inmodule QtWebEngineCore
*/
/*!
+ \enum QWebEngineUrlRequestJob::Error
+
+ This enum type holds the type of the error that occurred:
+
+ \value NoError
+ The request was successful.
+ \value UrlNotFound
+ The requested URL was not found.
+ \value UrlInvalid
+ The requested URL is invalid.
+ \value RequestAborted
+ The request was canceled.
+ \value RequestDenied
+ The request was denied.
+ \value RequestFailed
+ The request failed.
+*/
+
+/*!
\internal
*/
QWebEngineUrlRequestJob::QWebEngineUrlRequestJob(URLRequestCustomJobDelegate * p)
@@ -92,7 +110,7 @@ QByteArray QWebEngineUrlRequestJob::requestMethod() const
}
/*!
- Replies the request with \a device with the mime-type \a contentType.
+ Replies to the request with \a device and the MIME type \a contentType.
*/
void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device)
{
@@ -100,7 +118,9 @@ void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *de
}
/*!
- Fails the request with error \a error.
+ Fails the request with the error \a r.
+
+ \sa Error
*/
void QWebEngineUrlRequestJob::fail(Error r)
{
@@ -108,7 +128,7 @@ void QWebEngineUrlRequestJob::fail(Error r)
}
/*!
- Tell the request is redirected to \a url.
+ Redirects the request to \a url.
*/
void QWebEngineUrlRequestJob::redirect(const QUrl &url)
{
diff --git a/src/core/api/qwebengineurlrequestjob.h b/src/core/api/qwebengineurlrequestjob.h
index 098d46c93..fc9f4d911 100644
--- a/src/core/api/qwebengineurlrequestjob.h
+++ b/src/core/api/qwebengineurlrequestjob.h
@@ -37,17 +37,6 @@
#ifndef QWEBENGINEURLREQUESTJOB_H
#define QWEBENGINEURLREQUESTJOB_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
#include "qtwebenginecoreglobal.h"
#include <QtCore/qbytearray.h>
@@ -55,6 +44,7 @@
#include <QtCore/qurl.h>
namespace QtWebEngineCore {
+class URLRequestCustomJob;
class URLRequestCustomJobDelegate;
} // namespace
@@ -86,7 +76,7 @@ public:
private:
QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *);
- friend class QWebEngineUrlSchemeHandlerPrivate;
+ friend class QtWebEngineCore::URLRequestCustomJob;
QtWebEngineCore::URLRequestCustomJobDelegate* d_ptr;
};
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
index 330648893..e6c20dbca 100644
--- a/src/core/api/qwebengineurlschemehandler.cpp
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -43,31 +43,25 @@ QT_BEGIN_NAMESPACE
/*!
\class QWebEngineUrlSchemeHandler
- \brief The QWebEngineUrlSchemeHandler base class for handling custom URL schemes.
+ \brief The QWebEngineUrlSchemeHandler is a base class for handling custom URL schemes.
\since 5.6
- To implement a custom URL scheme for QtWebEngine you must write a class derived from this class,
+ To implement a custom URL scheme for QtWebEngine, you must write a class derived from this class,
and reimplement requestStarted().
\inmodule QtWebEngineCore
*/
-QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q)
- : CustomUrlSchemeHandler(scheme)
- , q_ptr(q)
-{
-}
+/*!
+ \fn QWebEngineUrlSchemeHandler::destroyed(QWebEngineUrlSchemeHandler *handler)
-QWebEngineUrlSchemeHandlerPrivate::~QWebEngineUrlSchemeHandlerPrivate()
-{
-}
+ This signal is emitted when the custom URL scheme handler \a handler is deleted.
+*/
-bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCustomJobDelegate *job)
+QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme)
+ : m_scheme(scheme)
{
- QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(job);
- q_ptr->requestStarted(requestJob);
- return true;
}
/*!
@@ -78,12 +72,16 @@ bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCus
*/
QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent)
: QObject(parent)
- , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this))
+ , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme))
{
}
+/*!
+ Deletes a custom URL scheme handler.
+*/
QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler()
{
+ Q_EMIT destroyed(this);
delete d_ptr;
}
diff --git a/src/core/api/qwebengineurlschemehandler.h b/src/core/api/qwebengineurlschemehandler.h
index b6f6a69f0..1b6a66706 100644
--- a/src/core/api/qwebengineurlschemehandler.h
+++ b/src/core/api/qwebengineurlschemehandler.h
@@ -42,6 +42,10 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qobject.h>
+namespace QtWebEngineCore {
+class URLRequestContextGetterQt;
+}
+
QT_BEGIN_NAMESPACE
class QWebEngineUrlRequestJob;
@@ -57,11 +61,12 @@ public:
virtual void requestStarted(QWebEngineUrlRequestJob*) = 0;
+Q_SIGNALS:
+ void destroyed(QWebEngineUrlSchemeHandler*);
+
private:
Q_DISABLE_COPY(QWebEngineUrlSchemeHandler)
Q_DECLARE_PRIVATE(QWebEngineUrlSchemeHandler)
- friend class QWebEngineProfile;
- friend class QQuickWebEngineProfile;
QWebEngineUrlSchemeHandlerPrivate *d_ptr;
};
diff --git a/src/core/api/qwebengineurlschemehandler_p.h b/src/core/api/qwebengineurlschemehandler_p.h
index dc4b272b3..d63666326 100644
--- a/src/core/api/qwebengineurlschemehandler_p.h
+++ b/src/core/api/qwebengineurlschemehandler_p.h
@@ -48,27 +48,18 @@
// We mean it.
//
-#include "qwebengineurlschemehandler.h"
-
-#include "custom_url_scheme_handler.h"
+#include <QtCore/qbytearray.h>
QT_BEGIN_NAMESPACE
-class QWebEngineProfile;
-class QWebEngineUrlRequestJob;
-class QWebEngineUrlSchemeHandler;
-
-class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler {
+class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate {
public:
- Q_DECLARE_PUBLIC(QWebEngineUrlSchemeHandler)
-
- QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *);
- virtual ~QWebEngineUrlSchemeHandlerPrivate();
+ QWebEngineUrlSchemeHandlerPrivate(const QByteArray &);
- virtual bool handleJob(QtWebEngineCore::URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE;
+ const QByteArray &scheme() const { return m_scheme; }
private:
- QWebEngineUrlSchemeHandler *q_ptr;
+ QByteArray m_scheme;
};
QT_END_NAMESPACE
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 660c6ffb2..345741847 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -255,12 +255,12 @@ void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent)
{
if (m_httpUserAgent == userAgent)
return;
- m_httpUserAgent = userAgent;
+ m_httpUserAgent = userAgent.simplified();
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
Q_FOREACH (content::WebContentsImpl *web_contents, list)
if (web_contents->GetBrowserContext() == m_browserContext.data())
- web_contents->SetUserAgentOverride(userAgent.toStdString());
+ web_contents->SetUserAgentOverride(m_httpUserAgent.toStdString());
if (m_browserContext->url_request_getter_.get())
m_browserContext->url_request_getter_->updateUserAgent();
@@ -354,7 +354,7 @@ void BrowserContextAdapter::setHttpCacheMaxSize(int maxSize)
m_browserContext->url_request_getter_->updateHttpCache();
}
-QVector<CustomUrlSchemeHandler*> &BrowserContextAdapter::customUrlSchemeHandlers()
+QHash<QByteArray, QWebEngineUrlSchemeHandler *> &BrowserContextAdapter::customUrlSchemeHandlers()
{
return m_customUrlSchemeHandlers;
}
@@ -365,10 +365,9 @@ void BrowserContextAdapter::updateCustomUrlSchemeHandlers()
m_browserContext->url_request_getter_->updateStorageSettings();
}
-void BrowserContextAdapter::removeCustomUrlSchemeHandler(CustomUrlSchemeHandler *handler)
+void BrowserContextAdapter::removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
{
- m_customUrlSchemeHandlers.removeOne(handler);
- Q_ASSERT(!m_customUrlSchemeHandlers.contains(handler));
+ m_customUrlSchemeHandlers.remove(handler->scheme());
}
UserScriptControllerHost *BrowserContextAdapter::userScriptController()
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index 0bca1bf8b..5272268f7 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -48,6 +48,7 @@
#include "api/qwebenginecookiestoreclient.h"
#include "api/qwebengineurlrequestinterceptor.h"
+#include "api/qwebengineurlschemehandler.h"
QT_FORWARD_DECLARE_CLASS(QObject)
@@ -55,7 +56,6 @@ namespace QtWebEngineCore {
class BrowserContextAdapterClient;
class BrowserContextQt;
-class CustomUrlSchemeHandler;
class DownloadManagerDelegateQt;
class UserScriptControllerHost;
class WebEngineVisitedLinksManager;
@@ -145,9 +145,9 @@ public:
bool trackVisitedLinks() const;
bool persistVisitedLinks() const;
- QVector<CustomUrlSchemeHandler*> &customUrlSchemeHandlers();
+ QHash<QByteArray, QWebEngineUrlSchemeHandler *> &customUrlSchemeHandlers();
void updateCustomUrlSchemeHandlers();
- void removeCustomUrlSchemeHandler(CustomUrlSchemeHandler*);
+ void removeCustomUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
UserScriptControllerHost *userScriptController();
void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply);
@@ -173,7 +173,7 @@ private:
QString m_httpAcceptLanguage;
PersistentCookiesPolicy m_persistentCookiesPolicy;
VisitedLinksPolicy m_visitedLinksPolicy;
- QVector<CustomUrlSchemeHandler*> m_customUrlSchemeHandlers;
+ QHash<QByteArray, QWebEngineUrlSchemeHandler *> m_customUrlSchemeHandlers;
QList<BrowserContextAdapterClient*> m_clients;
int m_httpCacheMaxSize;
diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri
index cd12204f9..50f94147e 100644
--- a/src/core/config/embedded_linux.pri
+++ b/src/core/config/embedded_linux.pri
@@ -33,9 +33,6 @@ GYP_CONFIG += \
toolkit_views=1 \
use_custom_freetype=0 \
use_libpci=0 \
- use_nss_certs=0 \
- use_openssl=1 \
- use_openssl_certs=1 \
use_ozone=1 \
use_system_fontconfig=1 \
icu_use_data_file_flag=0 \
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index 4c2e70daf..7f269245e 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -18,23 +18,28 @@ GYP_CONFIG += \
use_kerberos=0 \
use_pango=0
-contains(QT_CONFIG, system-zlib): config_system_minizip: GYP_CONFIG += use_system_zlib=1
+!use?(nss) {
+ GYP_CONFIG += use_nss_certs=0 \
+ use_openssl=1 \
+ use_openssl_certs=1
+}
+
+contains(QT_CONFIG, system-zlib): use?(system_minizip): GYP_CONFIG += use_system_zlib=1
contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1
contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1
-contains(QT_CONFIG, system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1
!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0
-config_system_libevent: GYP_CONFIG += use_system_libevent=1
-config_system_libwebp: GYP_CONFIG += use_system_libwebp=1
-config_system_libsrtp: GYP_CONFIG += use_system_libsrtp=1
-config_system_libxslt: GYP_CONFIG += use_system_libxml=1
-config_system_flac: GYP_CONFIG += use_system_flac=1
-config_system_jsoncpp: GYP_CONFIG += use_system_jsoncpp=1
-config_system_opus: GYP_CONFIG += use_system_opus=1
-config_system_snappy: GYP_CONFIG += use_system_snappy=1
-config_system_speex: GYP_CONFIG += use_system_speex=1
-config_system_vpx: GYP_CONFIG += use_system_libvpx=1
-
-contains(WEBENGINE_CONFIG, use_system_icu): GYP_CONFIG += use_system_icu=1
-contains(WEBENGINE_CONFIG, use_system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1
+use?(system_harfbuzz): GYP_CONFIG += use_system_harfbuzz=1
+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/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp
index 7838617ba..7622614ca 100644
--- a/src/core/cookie_monster_delegate_qt.cpp
+++ b/src/core/cookie_monster_delegate_qt.cpp
@@ -49,7 +49,7 @@
namespace QtWebEngineCore {
static GURL sourceUrlForCookie(const QNetworkCookie &cookie) {
- QString urlFragment = QString("%1%2").arg(cookie.domain()).arg(cookie.path());
+ QString urlFragment = QStringLiteral("%1%2").arg(cookie.domain()).arg(cookie.path());
return net::cookie_util::CookieOriginToURL(urlFragment.toStdString(), /* is_https */ cookie.isSecure());
}
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index c1b8179e0..813626dc3 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -45,7 +45,6 @@ SOURCES = \
content_main_delegate_qt.cpp \
cookie_monster_delegate_qt.cpp \
custom_protocol_handler.cpp \
- custom_url_scheme_handler.cpp \
delegated_frame_node.cpp \
desktop_screen_qt.cpp \
dev_tools_http_handler_delegate_qt.cpp \
@@ -117,7 +116,6 @@ HEADERS = \
content_main_delegate_qt.h \
cookie_monster_delegate_qt.h \
custom_protocol_handler.h \
- custom_url_scheme_handler.h \
delegated_frame_node.h \
desktop_screen_qt.h \
dev_tools_http_handler_delegate_qt.h \
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index cf253a735..68d46cd5a 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -22,7 +22,7 @@ osx {
} else:msvc {
# Simulate -whole-archive by passing the list of object files that belong to the public
# API library as response file to the linker.
- LIBS_PRIVATE += /OPT:REF
+ QMAKE_LFLAGS += /OPT:REF
QMAKE_LFLAGS += @$${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib.objects
} else {
LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive
diff --git a/src/core/custom_protocol_handler.cpp b/src/core/custom_protocol_handler.cpp
index f140f98cf..fd1a4de41 100644
--- a/src/core/custom_protocol_handler.cpp
+++ b/src/core/custom_protocol_handler.cpp
@@ -43,7 +43,7 @@
namespace QtWebEngineCore {
-CustomProtocolHandler::CustomProtocolHandler(CustomUrlSchemeHandler *schemeHandler)
+CustomProtocolHandler::CustomProtocolHandler(QWebEngineUrlSchemeHandler *schemeHandler)
: m_schemeHandler(schemeHandler)
{
}
diff --git a/src/core/custom_protocol_handler.h b/src/core/custom_protocol_handler.h
index 225bb0567..94da28673 100644
--- a/src/core/custom_protocol_handler.h
+++ b/src/core/custom_protocol_handler.h
@@ -45,6 +45,7 @@
#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
QT_FORWARD_DECLARE_CLASS(QIODevice)
+QT_FORWARD_DECLARE_CLASS(QWebEngineUrlSchemeHandler)
namespace net {
class NetworkDelegate;
@@ -54,20 +55,19 @@ class URLRequestJob;
namespace QtWebEngineCore {
class BrowserContextAdapter;
-class CustomUrlSchemeHandler;
// Implements a ProtocolHandler for custom URL schemes.
// If |network_delegate_| is NULL then all file requests will fail with ERR_ACCESS_DENIED.
class QWEBENGINE_EXPORT CustomProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
- CustomProtocolHandler(CustomUrlSchemeHandler *);
+ CustomProtocolHandler(QWebEngineUrlSchemeHandler *);
virtual net::URLRequestJob *MaybeCreateJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate) const Q_DECL_OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(CustomProtocolHandler);
- CustomUrlSchemeHandler *m_schemeHandler;
+ QWebEngineUrlSchemeHandler *m_schemeHandler;
};
} // namespace
diff --git a/src/core/custom_url_scheme_handler.cpp b/src/core/custom_url_scheme_handler.cpp
deleted file mode 100644
index 29791b555..000000000
--- a/src/core/custom_url_scheme_handler.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "custom_url_scheme_handler.h"
-#include "custom_protocol_handler.h"
-
-namespace QtWebEngineCore {
-
-CustomUrlSchemeHandler::CustomUrlSchemeHandler(const QByteArray &scheme)
- : m_scheme(scheme)
-{
-}
-
-QByteArray CustomUrlSchemeHandler::scheme() const
-{
- return m_scheme;
-}
-
-void CustomUrlSchemeHandler::setScheme(const QByteArray &scheme)
-{
- m_scheme = scheme;
-}
-
-CustomProtocolHandler *CustomUrlSchemeHandler::createProtocolHandler()
-{
- // Will be owned by the JobFactory.
- return new CustomProtocolHandler(this);
-}
-
-} // namespace
diff --git a/src/core/custom_url_scheme_handler.h b/src/core/custom_url_scheme_handler.h
deleted file mode 100644
index d866628de..000000000
--- a/src/core/custom_url_scheme_handler.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPLv3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CUSTOM_URL_SCHEME_HANDLER_H_
-#define CUSTOM_URL_SCHEME_HANDLER_H_
-
-#include "qtwebenginecoreglobal.h"
-
-#include <QtCore/QByteArray>
-#include <QtCore/QScopedPointer>
-
-QT_FORWARD_DECLARE_CLASS(QIODevice)
-
-namespace QtWebEngineCore {
-
-class BrowserContextAdapter;
-class CustomProtocolHandler;
-class URLRequestCustomJobDelegate;
-
-class QWEBENGINE_EXPORT CustomUrlSchemeHandler {
-public:
- explicit CustomUrlSchemeHandler(const QByteArray &);
- virtual ~CustomUrlSchemeHandler() { }
-
- QByteArray scheme() const;
- void setScheme(const QByteArray &);
- CustomProtocolHandler *createProtocolHandler();
-
- virtual bool handleJob(URLRequestCustomJobDelegate*) = 0;
-
-private:
- QByteArray m_scheme;
-};
-
-
-} // namespace
-
-#endif // CUSTOM_URL_SCHEME_HANDLER_H_
diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp
index c01dcf63d..e9af98fd8 100644
--- a/src/core/download_manager_delegate_qt.cpp
+++ b/src/core/download_manager_delegate_qt.cpp
@@ -40,6 +40,7 @@
#include "content/public/browser/download_item.h"
#include "content/public/browser/save_page_type.h"
#include "content/public/browser/web_contents.h"
+#include "net/http/http_content_disposition.h"
#include <QDir>
#include <QFile>
@@ -104,6 +105,9 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i
std::string suggestedFilename = item->GetSuggestedFilename();
if (suggestedFilename.empty())
+ suggestedFilename = net::HttpContentDisposition(item->GetContentDisposition(), std::string()).filename();
+
+ if (suggestedFilename.empty())
suggestedFilename = item->GetTargetFilePath().AsUTF8Unsafe();
if (suggestedFilename.empty())
diff --git a/src/core/javascript_dialog_manager_qt.cpp b/src/core/javascript_dialog_manager_qt.cpp
index fdcd7bdbc..24d426098 100644
--- a/src/core/javascript_dialog_manager_qt.cpp
+++ b/src/core/javascript_dialog_manager_qt.cpp
@@ -67,6 +67,12 @@ void JavaScriptDialogManagerQt::RunJavaScriptDialog(content::WebContents *webCon
runDialogForContents(webContents, dialogType, toQt(messageText).toHtmlEscaped(), toQt(defaultPromptText).toHtmlEscaped(), toQt(originUrl), callback);
}
+void JavaScriptDialogManagerQt::RunBeforeUnloadDialog(content::WebContents *webContents, const base::string16 &messageText,
+ bool isReload, const content::JavaScriptDialogManager::DialogClosedCallback &callback) {
+ Q_UNUSED(isReload);
+ runDialogForContents(webContents, WebContentsAdapterClient::UnloadDialog, toQt(messageText).toHtmlEscaped(), QString() , QUrl(), callback);
+}
+
bool JavaScriptDialogManagerQt::HandleJavaScriptDialog(content::WebContents *contents, bool accept, const base::string16 *promptOverride)
{
QSharedPointer<JavaScriptDialogController> dialog = m_activeDialogs.value(contents);
diff --git a/src/core/javascript_dialog_manager_qt.h b/src/core/javascript_dialog_manager_qt.h
index 8bf7ac6b9..fb47166c1 100644
--- a/src/core/javascript_dialog_manager_qt.h
+++ b/src/core/javascript_dialog_manager_qt.h
@@ -63,7 +63,7 @@ public:
const content::JavaScriptDialogManager::DialogClosedCallback &callback, bool *didSuppressMessage) Q_DECL_OVERRIDE;
virtual void RunBeforeUnloadDialog(content::WebContents *, const base::string16 &messageText, bool isReload,
- const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE { Q_UNUSED(messageText); Q_UNUSED(isReload); Q_UNUSED(callback); }
+ const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE;
virtual bool HandleJavaScriptDialog(content::WebContents *, bool accept, const base::string16 *promptOverride) Q_DECL_OVERRIDE;
virtual void CancelActiveAndPendingDialogs(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
virtual void ResetDialogState(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp
index d17fc3d21..e3be01b36 100644
--- a/src/core/location_provider_qt.cpp
+++ b/src/core/location_provider_qt.cpp
@@ -60,7 +60,7 @@ public:
QtPositioningHelper(LocationProviderQt *provider);
~QtPositioningHelper();
- bool start(bool highAccuracy);
+ void start(bool highAccuracy);
void stop();
void refresh();
@@ -88,15 +88,20 @@ QtPositioningHelper::~QtPositioningHelper()
m_locationProvider->m_positioningHelper = 0;
}
-bool QtPositioningHelper::start(bool highAccuracy)
+void QtPositioningHelper::start(bool highAccuracy)
{
DCHECK_CURRENTLY_ON(BrowserThread::UI);
Q_UNUSED(highAccuracy);
// FIXME: go through availableSources until one supports QGeoPositionInfoSource::SatellitePositioningMethods
// for the highAccuracy case.
m_positionInfoSource = QGeoPositionInfoSource::createDefaultSource(this);
- if (!m_positionInfoSource)
- return false;
+ if (!m_positionInfoSource) {
+ qWarning("Failed to initialize location provider: The system either has no default "
+ "position source, no valid plugins could be found or the user does not have "
+ "the right permissions.");
+ error(QGeoPositionInfoSource::UnknownSourceError);
+ return;
+ }
connect(m_positionInfoSource, &QGeoPositionInfoSource::positionUpdated, this, &QtPositioningHelper::updatePosition);
// disambiguate the error getter and the signal in QGeoPositionInfoSource.
@@ -105,7 +110,7 @@ bool QtPositioningHelper::start(bool highAccuracy)
connect(m_positionInfoSource, &QGeoPositionInfoSource::updateTimeout, this, &QtPositioningHelper::timeout);
m_positionInfoSource->startUpdates();
- return true;
+ return;
}
void QtPositioningHelper::stop()
@@ -208,7 +213,7 @@ bool LocationProviderQt::StartProvider(bool highAccuracy)
m_positioningHelper = new QtPositioningHelper(this);
m_positioningHelper->moveToThread(guiThread);
}
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(base::IgnoreResult(&QtPositioningHelper::start)
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(&QtPositioningHelper::start
, base::Unretained(m_positioningHelper), highAccuracy));
return true;
}
diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp
index 38fd3c710..3f67e7c0d 100644
--- a/src/core/network_delegate_qt.cpp
+++ b/src/core/network_delegate_qt.cpp
@@ -55,7 +55,7 @@
namespace QtWebEngineCore {
-static int pageTransitionToNavigationType(ui::PageTransition transition)
+int pageTransitionToNavigationType(ui::PageTransition transition)
{
int32 qualifier = ui::PageTransitionGetQualifier(transition);
@@ -106,6 +106,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::C
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType)
, static_cast<QWebEngineUrlRequestInfo::NavigationType>(navigationType)
, qUrl
+ , toQt(request->first_party_for_cookies())
, QByteArray::fromStdString(request->method()));
QWebEngineUrlRequestInfo requestInfo(infoPrivate);
if (interceptor->interceptRequest(requestInfo)) {
diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp
index b63ecd5c7..e6c513bf6 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.cpp
+++ b/src/core/resource_dispatcher_host_delegate_qt.cpp
@@ -130,6 +130,35 @@ void ResourceDispatcherHostLoginDelegateQt::destroy()
m_request = 0;
}
+static void LaunchURL(const GURL& url, int render_process_id, int render_view_id,
+ ui::PageTransition page_transition, bool is_main_frame)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ content::RenderViewHost *render_view_host = content::RenderViewHost::FromID(render_process_id, render_view_id);
+ if (!render_view_host)
+ return;
+ content::WebContents* webContents = content::WebContents::FromRenderViewHost(render_view_host);
+ if (!webContents)
+ return;
+ WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
+ contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame);
+}
+
+bool ResourceDispatcherHostDelegateQt::HandleExternalProtocol(const GURL& url, int child_id, int route_id,
+ bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture)
+{
+ Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ // We don't want to launch external applications unless it is based on a user action
+ if (!has_user_gesture)
+ return false;
+
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&LaunchURL, url, child_id, route_id, page_transition, is_main_frame));
+ return true;
+}
+
content::ResourceDispatcherHostLoginDelegate *ResourceDispatcherHostDelegateQt::CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
{
// ResourceDispatcherHostLoginDelegateQt is ref-counted and will be released after we called ClearLoginDelegateForRequest.
diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/resource_dispatcher_host_delegate_qt.h
index d62292995..57eaa3bc5 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.h
+++ b/src/core/resource_dispatcher_host_delegate_qt.h
@@ -86,6 +86,9 @@ private:
class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate {
public:
+ virtual bool HandleExternalProtocol(const GURL& url, int child_id, int route_id,
+ bool is_main_frame, ui::PageTransition page_transition, bool has_user_gesture) Q_DECL_OVERRIDE;
+
virtual content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) Q_DECL_OVERRIDE;
};
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index c9ebf7f3b..771a662b9 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -66,9 +66,9 @@
#include "net/url_request/ftp_protocol_handler.h"
#include "net/ftp/ftp_network_layer.h"
+#include "api/qwebengineurlschemehandler.h"
#include "browser_context_adapter.h"
#include "custom_protocol_handler.h"
-#include "custom_url_scheme_handler.h"
#include "cookie_monster_delegate_qt.h"
#include "content_client_qt.h"
#include "network_delegate_qt.h"
@@ -350,8 +350,8 @@ void URLRequestContextGetterQt::generateJobFactory()
m_jobFactory->SetProtocolHandler(url::kFtpScheme,
new net::FtpProtocolHandler(new net::FtpNetworkLayer(m_urlRequestContext->host_resolver())));
- Q_FOREACH (CustomUrlSchemeHandler* handler, m_browserContext->customUrlSchemeHandlers()) {
- m_jobFactory->SetProtocolHandler(handler->scheme().toStdString(), handler->createProtocolHandler());
+ Q_FOREACH (QWebEngineUrlSchemeHandler *handler, m_browserContext->customUrlSchemeHandlers()) {
+ m_jobFactory->SetProtocolHandler(handler->scheme().toStdString(), new CustomProtocolHandler(handler));
}
m_urlRequestContext->set_job_factory(m_jobFactory.get());
diff --git a/src/core/url_request_custom_job.cpp b/src/core/url_request_custom_job.cpp
index afdcecdfe..0a81d04a1 100644
--- a/src/core/url_request_custom_job.cpp
+++ b/src/core/url_request_custom_job.cpp
@@ -37,7 +37,8 @@
#include "url_request_custom_job.h"
#include "url_request_custom_job_delegate.h"
-#include "custom_url_scheme_handler.h"
+#include "api/qwebengineurlrequestjob.h"
+#include "api/qwebengineurlschemehandler.h"
#include "type_conversion.h"
#include "content/public/browser/browser_thread.h"
@@ -53,7 +54,7 @@ using namespace net;
namespace QtWebEngineCore {
-URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, CustomUrlSchemeHandler *schemeHandler)
+URLRequestCustomJob::URLRequestCustomJob(URLRequest *request, NetworkDelegate *networkDelegate, QWebEngineUrlSchemeHandler *schemeHandler)
: URLRequestJob(request, networkDelegate)
, m_device(0)
, m_schemeHandler(schemeHandler)
@@ -236,7 +237,8 @@ void URLRequestCustomJob::startAsync()
QMutexLocker lock(&m_mutex);
m_delegate = new URLRequestCustomJobDelegate(this);
lock.unlock();
- m_schemeHandler->handleJob(m_delegate);
+ QWebEngineUrlRequestJob *requestJob = new QWebEngineUrlRequestJob(m_delegate);
+ m_schemeHandler->requestStarted(requestJob);
}
} // namespace
diff --git a/src/core/url_request_custom_job.h b/src/core/url_request_custom_job.h
index 60a1d60b9..a994c467a 100644
--- a/src/core/url_request_custom_job.h
+++ b/src/core/url_request_custom_job.h
@@ -45,16 +45,16 @@
#include <QtCore/QPointer>
QT_FORWARD_DECLARE_CLASS(QIODevice)
+QT_FORWARD_DECLARE_CLASS(QWebEngineUrlSchemeHandler)
namespace QtWebEngineCore {
-class CustomUrlSchemeHandler;
class URLRequestCustomJobDelegate;
// A request job that handles reading custom URL schemes
class URLRequestCustomJob : public net::URLRequestJob {
public:
- URLRequestCustomJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate, CustomUrlSchemeHandler *schemeHandler);
+ URLRequestCustomJob(net::URLRequest *request, net::NetworkDelegate *networkDelegate, QWebEngineUrlSchemeHandler *schemeHandler);
virtual void Start() Q_DECL_OVERRIDE;
virtual void Kill() Q_DECL_OVERRIDE;
virtual bool ReadRawData(net::IOBuffer *buf, int bufSize, int *bytesRead) Q_DECL_OVERRIDE;
@@ -81,7 +81,7 @@ private:
QMutex m_mutex;
QPointer<QIODevice> m_device;
QPointer<URLRequestCustomJobDelegate> m_delegate;
- CustomUrlSchemeHandler *m_schemeHandler;
+ QWebEngineUrlSchemeHandler *m_schemeHandler;
std::string m_mimeType;
std::string m_charset;
int m_error;
diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp
index fb293c56a..179febc48 100644
--- a/src/core/user_script.cpp
+++ b/src/core/user_script.cpp
@@ -168,14 +168,3 @@ UserScriptData &UserScript::data() const
}
} // namespace QtWebEngineCore
-
-QT_BEGIN_NAMESPACE
-uint qHash(const QtWebEngineCore::UserScript &script, uint seed)
-{
- if (script.isNull())
- return 0;
- return qHash(script.sourceCode(), seed) ^ qHash(script.name(), seed)
- ^ (script.injectionPoint() | (script.runsOnSubFrames() << 4))
- ^ script.worldId();
-}
-QT_END_NAMESPACE
diff --git a/src/core/user_script.h b/src/core/user_script.h
index 7aeba9131..69c32c7ba 100644
--- a/src/core/user_script.h
+++ b/src/core/user_script.h
@@ -93,8 +93,4 @@ private:
} // namespace QtWebEngineCore
-QT_BEGIN_NAMESPACE
-uint qHash(const QtWebEngineCore::UserScript &, uint seed = 0);
-QT_END_NAMESPACE
-
#endif // USER_SCRIPT_H
diff --git a/src/core/user_script_controller_host.cpp b/src/core/user_script_controller_host.cpp
index d57518275..a0d3f6fed 100644
--- a/src/core/user_script_controller_host.cpp
+++ b/src/core/user_script_controller_host.cpp
@@ -116,9 +116,11 @@ void UserScriptControllerHost::addUserScript(const UserScript &script, WebConten
return;
// Global scripts should be dispatched to all our render processes.
if (!adapter) {
- m_profileWideScripts.insert(script);
- Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
- renderer->Send(new UserScriptController_AddScript(script.data()));
+ if (!m_profileWideScripts.contains(script)) {
+ m_profileWideScripts.append(script);
+ Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
+ renderer->Send(new UserScriptController_AddScript(script.data()));
+ }
} else {
content::WebContents *contents = adapter->webContents();
ContentsScriptsMap::iterator it = m_perContentsScripts.find(contents);
@@ -126,11 +128,13 @@ void UserScriptControllerHost::addUserScript(const UserScript &script, WebConten
// We need to keep track of RenderView/RenderViewHost changes for a given contents
// in order to make sure the scripts stay in sync
new WebContentsObserverHelper(this, contents);
- it = m_perContentsScripts.insert(contents, (QSet<UserScript>() << script));
+ it = m_perContentsScripts.insert(contents, (QList<UserScript>() << script));
} else {
- QSet<UserScript> currentScripts = it.value();
- currentScripts.insert(script);
- m_perContentsScripts.insert(contents, currentScripts);
+ QList<UserScript> currentScripts = it.value();
+ if (!currentScripts.contains(script)) {
+ currentScripts.append(script);
+ m_perContentsScripts.insert(contents, currentScripts);
+ }
}
contents->Send(new RenderViewObserverHelper_AddScript(contents->GetRoutingID(), script.data()));
}
@@ -151,7 +155,8 @@ bool UserScriptControllerHost::removeUserScript(const UserScript &script, WebCon
if (script.isNull())
return false;
if (!adapter) {
- QSet<UserScript>::iterator it = m_profileWideScripts.find(script);
+ QList<UserScript>::iterator it
+ = std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script);
if (it == m_profileWideScripts.end())
return false;
Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses)
@@ -161,12 +166,12 @@ bool UserScriptControllerHost::removeUserScript(const UserScript &script, WebCon
content::WebContents *contents = adapter->webContents();
if (!m_perContentsScripts.contains(contents))
return false;
- QSet<UserScript> &set(m_perContentsScripts[contents]);
- QSet<UserScript>::iterator it = set.find(script);
- if (it == set.end())
+ QList<UserScript> &list(m_perContentsScripts[contents]);
+ QList<UserScript>::iterator it = std::find(list.begin(), list.end(), script);
+ if (it == list.end())
return false;
contents->Send(new RenderViewObserverHelper_RemoveScript(contents->GetRoutingID(), (*it).data()));
- set.erase(it);
+ list.erase(it);
}
return true;
}
@@ -184,7 +189,7 @@ void UserScriptControllerHost::clearAllScripts(WebContentsAdapter *adapter)
}
}
-const QSet<UserScript> UserScriptControllerHost::registeredScripts(WebContentsAdapter *adapter) const
+const QList<UserScript> UserScriptControllerHost::registeredScripts(WebContentsAdapter *adapter) const
{
if (!adapter)
return m_profileWideScripts;
diff --git a/src/core/user_script_controller_host.h b/src/core/user_script_controller_host.h
index 49c96b333..3884fb3b9 100644
--- a/src/core/user_script_controller_host.h
+++ b/src/core/user_script_controller_host.h
@@ -64,7 +64,7 @@ public:
bool removeUserScript(const UserScript &script, WebContentsAdapter *adapter);
void clearAllScripts(WebContentsAdapter *adapter);
void reserve(WebContentsAdapter *adapter, int count);
- const QSet<UserScript> registeredScripts(WebContentsAdapter *adapter) const;
+ const QList<UserScript> registeredScripts(WebContentsAdapter *adapter) const;
void renderProcessStartedWithHost(content::RenderProcessHost *renderer);
@@ -75,8 +75,8 @@ private:
void webContentsDestroyed(content::WebContents *);
- QSet<UserScript> m_profileWideScripts;
- typedef QHash<content::WebContents *, QSet<UserScript>> ContentsScriptsMap;
+ QList<UserScript> m_profileWideScripts;
+ typedef QHash<content::WebContents *, QList<UserScript>> ContentsScriptsMap;
ContentsScriptsMap m_perContentsScripts;
QSet<content::RenderProcessHost *> m_observedProcesses;
QScopedPointer<RenderProcessObserverHelper> m_renderProcessObserver;
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 81c945d5c..2ab2e9471 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -576,6 +576,12 @@ void WebContentsAdapter::selectAll()
d->webContents->SelectAll();
}
+void WebContentsAdapter::requestClose()
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->DispatchBeforeUnload(false);
+}
+
void WebContentsAdapter::unselect()
{
Q_D(const WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index c2ab65762..6e356befd 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -129,6 +129,7 @@ public:
void inspectElementAt(const QPoint &location);
bool hasInspector() const;
void exitFullScreen();
+ void requestClose();
void wasShown();
void wasHidden();
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 42e3e4500..4a857b320 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -147,6 +147,7 @@ public:
AlertDialog,
ConfirmDialog,
PromptDialog,
+ UnloadDialog,
// Leave room for potential new specs
InternalAuthorizationDialog = 0x10,
};
@@ -207,6 +208,7 @@ public:
virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry) = 0;
virtual void close() = 0;
+ virtual void windowCloseRejected() = 0;
virtual bool contextMenuRequested(const WebEngineContextMenuData&) = 0;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) = 0;
virtual void requestFullScreen(bool) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index eb9c42edc..497910a9c 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -43,6 +43,7 @@
#include "browser_context_adapter.h"
#include "file_picker_controller.h"
#include "media_capture_devices_dispatcher.h"
+#include "network_delegate_qt.h"
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
#include "web_contents_adapter_p.h"
@@ -64,6 +65,8 @@
#include "content/public/common/web_preferences.h"
#include "ui/events/latency_info.h"
+#include <QDesktopServices>
+
namespace QtWebEngineCore {
// Maps the LogSeverity defines in base/logging.h to the web engines message levels.
@@ -357,6 +360,18 @@ void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingO
m_viewClient->runGeolocationPermissionRequest(requestingOrigin);
}
+extern int pageTransitionToNavigationType(ui::PageTransition transition);
+
+void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame)
+{
+ int navigationRequestAction = WebContentsAdapterClient::AcceptRequest;
+ m_viewClient->navigationRequested(pageTransitionToNavigationType(page_transition), url, navigationRequestAction, is_main_frame);
+#ifndef QT_NO_DESKTOPSERVICES
+ if (navigationRequestAction == WebContentsAdapterClient::AcceptRequest)
+ QDesktopServices::openUrl(url);
+#endif
+}
+
void WebContentsDelegateQt::ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text)
{
Q_UNUSED(web_contents);
@@ -375,4 +390,13 @@ void WebContentsDelegateQt::MoveValidationMessage(content::WebContents *web_cont
m_viewClient->moveValidationMessage(toQt(anchor_in_root_view));
}
+void WebContentsDelegateQt::BeforeUnloadFired(content::WebContents *tab, bool proceed, bool *proceed_to_fire_unload)
+{
+ Q_UNUSED(tab);
+ Q_ASSERT(proceed_to_fire_unload);
+ *proceed_to_fire_unload = proceed;
+ if (!proceed)
+ m_viewClient->windowCloseRejected();
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 3fda96113..abdf75fe5 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -91,6 +91,7 @@ public:
virtual void ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text) Q_DECL_OVERRIDE;
virtual void HideValidationMessage(content::WebContents *web_contents) Q_DECL_OVERRIDE;
virtual void MoveValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view) Q_DECL_OVERRIDE;
+ void BeforeUnloadFired(content::WebContents* tab, bool proceed, bool* proceed_to_fire_unload) Q_DECL_OVERRIDE;
// WebContentsObserver overrides
virtual void RenderFrameDeleted(content::RenderFrameHost *render_frame_host) Q_DECL_OVERRIDE;
@@ -107,6 +108,7 @@ public:
void overrideWebPreferences(content::WebContents *, content::WebPreferences*);
void allowCertificateError(const QSharedPointer<CertificateErrorController> &) ;
void requestGeolocationPermission(const QUrl &requestingOrigin);
+ void launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame);
private:
WebContentsAdapter *createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);