summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--src/imports/plugins.qmltypes12
-rw-r--r--src/imports/webview.cpp1
-rw-r--r--src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java39
-rw-r--r--src/plugins/android/qandroidwebview.cpp13
-rw-r--r--src/plugins/android/qandroidwebview_p.h2
-rw-r--r--src/plugins/darwin/qdarwinwebview.mm13
-rw-r--r--src/plugins/darwin/qdarwinwebview_p.h2
-rw-r--r--src/plugins/webengine/qwebenginewebview.cpp42
-rw-r--r--src/plugins/webengine/qwebenginewebview_p.h8
-rw-r--r--src/plugins/winrt/qwinrtwebview.cpp32
-rw-r--r--src/plugins/winrt/qwinrtwebview_p.h2
-rw-r--r--src/plugins/winrt/winrt.pro10
-rw-r--r--src/webview/qabstractwebview_p.h1
-rw-r--r--src/webview/qquickwebview.cpp19
-rw-r--r--src/webview/qquickwebview_p.h4
-rw-r--r--src/webview/qwebview.cpp21
-rw-r--r--src/webview/qwebview_p.h5
-rw-r--r--src/webview/qwebviewfactory.cpp2
-rw-r--r--src/webview/qwebviewinterface_p.h2
-rw-r--r--src/webview/webview.pro2
21 files changed, 228 insertions, 6 deletions
diff --git a/.qmake.conf b/.qmake.conf
index c1b75c7..76e7ef0 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,4 +2,4 @@ load(qt_build_config)
DEFINES += QT_NO_FOREACH
-MODULE_VERSION = 5.13.2
+MODULE_VERSION = 5.14.0
diff --git a/src/imports/plugins.qmltypes b/src/imports/plugins.qmltypes
index 3a143fd..945610e 100644
--- a/src/imports/plugins.qmltypes
+++ b/src/imports/plugins.qmltypes
@@ -4,7 +4,7 @@ import QtQuick.tooling 1.2
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtWebView 1.13'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtWebView 1.14'
Module {
dependencies: ["QtQuick 2.0"]
@@ -22,8 +22,12 @@ Module {
name: "QQuickWebView"
defaultProperty: "data"
prototype: "QQuickViewController"
- exports: ["QtWebView/WebView 1.0", "QtWebView/WebView 1.1"]
- exportMetaObjectRevisions: [0, 1]
+ exports: [
+ "QtWebView/WebView 1.0",
+ "QtWebView/WebView 1.1",
+ "QtWebView/WebView 1.14"
+ ]
+ exportMetaObjectRevisions: [0, 1, 14]
Enum {
name: "LoadStatus"
values: {
@@ -33,6 +37,7 @@ Module {
"LoadFailedStatus": 3
}
}
+ Property { name: "httpUserAgent"; revision: 14; type: "string" }
Property { name: "url"; type: "QUrl" }
Property { name: "loading"; revision: 1; type: "bool"; isReadonly: true }
Property { name: "loadProgress"; type: "int"; isReadonly: true }
@@ -44,6 +49,7 @@ Module {
revision: 1
Parameter { name: "loadRequest"; type: "QQuickWebViewLoadRequest"; isPointer: true }
}
+ Signal { name: "httpUserAgentChanged"; revision: 14 }
Method { name: "goBack" }
Method { name: "goForward" }
Method { name: "reload" }
diff --git a/src/imports/webview.cpp b/src/imports/webview.cpp
index d73ce09..c221655 100644
--- a/src/imports/webview.cpp
+++ b/src/imports/webview.cpp
@@ -56,6 +56,7 @@ public:
const QString &msg = QObject::tr("Cannot create separate instance of WebViewLoadRequest");
qmlRegisterType<QQuickWebView>(uri, 1, 0, "WebView");
qmlRegisterType<QQuickWebView, 1>(uri, 1, 1, "WebView");
+ qmlRegisterType<QQuickWebView, 14>(uri, 1, 14, "WebView");
qmlRegisterUncreatableType<QQuickWebViewLoadRequest>(uri, 1, 1, "WebViewLoadRequest", msg);
// Make sure we're always available under version x.QT_VERSION_MINOR
diff --git a/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java b/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
index 0f4b424..0bb36de 100644
--- a/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
+++ b/src/jar/src/org/qtproject/qt5/android/view/QtAndroidWebViewController.java
@@ -250,6 +250,45 @@ public class QtAndroidWebViewController
}
}
+ public String getUserAgent()
+ {
+ final String[] ua = {""};
+ final Semaphore sem = new Semaphore(0);
+ m_activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ua[0] = m_webView.getSettings().getUserAgentString();
+ sem.release();
+ }
+ });
+
+ try {
+ sem.tryAcquire(BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return ua[0];
+ }
+
+ public void setUserAgent(final String uaString)
+ {
+ final Semaphore sem = new Semaphore(0);
+ m_activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ m_webView.getSettings().setUserAgentString(uaString);
+ sem.release();
+ }
+ });
+
+ try {
+ sem.tryAcquire(BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
public void loadUrl(final String url)
{
if (url == null) {
diff --git a/src/plugins/android/qandroidwebview.cpp b/src/plugins/android/qandroidwebview.cpp
index 94e123c..3d2b98d 100644
--- a/src/plugins/android/qandroidwebview.cpp
+++ b/src/plugins/android/qandroidwebview.cpp
@@ -103,6 +103,19 @@ QAndroidWebViewPrivate::~QAndroidWebViewPrivate()
m_viewController.callMethod<void>("destroy");
}
+QString QAndroidWebViewPrivate::httpUserAgent() const
+{
+ return QString( m_viewController.callObjectMethod<jstring>("getUserAgent").toString());
+}
+
+void QAndroidWebViewPrivate::setHttpUserAgent(const QString &userAgent)
+{
+ m_viewController.callMethod<void>("setUserAgent",
+ "(Ljava/lang/String;)V",
+ QJNIObjectPrivate::fromString(userAgent).object());
+ Q_EMIT httpUserAgentChanged(userAgent);
+}
+
QUrl QAndroidWebViewPrivate::url() const
{
return QUrl::fromUserInput(m_viewController.callObjectMethod<jstring>("getUrl").toString());
diff --git a/src/plugins/android/qandroidwebview_p.h b/src/plugins/android/qandroidwebview_p.h
index 9c1d364..1498a98 100644
--- a/src/plugins/android/qandroidwebview_p.h
+++ b/src/plugins/android/qandroidwebview_p.h
@@ -64,6 +64,8 @@ public:
explicit QAndroidWebViewPrivate(QObject *p = 0);
~QAndroidWebViewPrivate() Q_DECL_OVERRIDE;
+ QString httpUserAgent() const Q_DECL_OVERRIDE;
+ void setHttpUserAgent(const QString &httpUserAgent) Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
bool canGoBack() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/darwin/qdarwinwebview.mm b/src/plugins/darwin/qdarwinwebview.mm
index ba99ac6..a9c711c 100644
--- a/src/plugins/darwin/qdarwinwebview.mm
+++ b/src/plugins/darwin/qdarwinwebview.mm
@@ -467,4 +467,17 @@ void QDarwinWebViewPrivate::runJavaScriptPrivate(const QString &script, int call
}];
}
+QString QDarwinWebViewPrivate::httpUserAgent() const
+{
+ return QString::fromNSString(wkWebView.customUserAgent);
+}
+
+void QDarwinWebViewPrivate::setHttpUserAgent(const QString &userAgent)
+{
+ if (!userAgent.isEmpty()) {
+ wkWebView.customUserAgent = userAgent.toNSString();
+ }
+ Q_EMIT httpUserAgentChanged(userAgent);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/darwin/qdarwinwebview_p.h b/src/plugins/darwin/qdarwinwebview_p.h
index 96fb09e..c69ee55 100644
--- a/src/plugins/darwin/qdarwinwebview_p.h
+++ b/src/plugins/darwin/qdarwinwebview_p.h
@@ -82,6 +82,8 @@ public:
explicit QDarwinWebViewPrivate(QObject *p = 0);
~QDarwinWebViewPrivate() Q_DECL_OVERRIDE;
+ QString httpUserAgent() const Q_DECL_OVERRIDE;
+ void setHttpUserAgent(const QString &httpUserAgent) Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
bool canGoBack() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/webengine/qwebenginewebview.cpp b/src/plugins/webengine/qwebenginewebview.cpp
index d083b8d..f16371d 100644
--- a/src/plugins/webengine/qwebenginewebview.cpp
+++ b/src/plugins/webengine/qwebenginewebview.cpp
@@ -65,7 +65,7 @@ static QByteArray qmlSource()
}
QWebEngineWebViewPrivate::QWebEngineWebViewPrivate(QObject *p)
- : QAbstractWebView(p)
+ : QAbstractWebView(p), m_profile(nullptr)
{
m_webEngineView.m_parent = this;
}
@@ -74,6 +74,17 @@ QWebEngineWebViewPrivate::~QWebEngineWebViewPrivate()
{
}
+QString QWebEngineWebViewPrivate::httpUserAgent() const
+{
+ return m_httpUserAgent;
+}
+
+void QWebEngineWebViewPrivate::setHttpUserAgent(const QString &userAgent)
+{
+ m_profile->setHttpUserAgent(userAgent);
+ Q_EMIT httpUserAgentChanged(userAgent);
+}
+
QUrl QWebEngineWebViewPrivate::url() const
{
return m_webEngineView->url();
@@ -195,6 +206,30 @@ void QWebEngineWebViewPrivate::q_loadingChanged(QQuickWebEngineLoadRequest *load
Q_EMIT loadingChanged(lr);
}
+void QWebEngineWebViewPrivate::q_profileChanged()
+{
+ auto profile = m_webEngineView->profile();
+ if (profile == m_profile)
+ return;
+
+ m_profile = profile;
+ auto userAgent = m_profile->httpUserAgent();
+ if (m_httpUserAgent == userAgent)
+ return;
+ m_httpUserAgent = userAgent;
+ QObject::connect(m_profile, &QQuickWebEngineProfile::httpUserAgentChanged, this, &QWebEngineWebViewPrivate::q_httpUserAgentChanged);
+ Q_EMIT httpUserAgentChanged(userAgent);
+}
+
+void QWebEngineWebViewPrivate::q_httpUserAgentChanged()
+{
+ QString httpUserAgent = m_profile->httpUserAgent();
+ if (m_httpUserAgent == httpUserAgent)
+ return;
+ m_httpUserAgent = httpUserAgent;
+ Q_EMIT httpUserAgentChanged(m_httpUserAgent);
+}
+
void QWebEngineWebViewPrivate::QQuickWebEngineViewPtr::init() const
{
Q_ASSERT(!m_webEngineView);
@@ -218,10 +253,15 @@ void QWebEngineWebViewPrivate::QQuickWebEngineViewPtr::init() const
component->setData(qmlSource(), QUrl::fromLocalFile(QLatin1String("")));
QQuickWebEngineView *webEngineView = qobject_cast<QQuickWebEngineView *>(component->create());
Q_ASSERT(webEngineView);
+ QQuickWebEngineProfile *profile = webEngineView->profile();
+ m_parent->m_profile = profile;
+ m_parent->m_httpUserAgent = profile->httpUserAgent();
QObject::connect(webEngineView, &QQuickWebEngineView::urlChanged, m_parent, &QWebEngineWebViewPrivate::q_urlChanged);
QObject::connect(webEngineView, &QQuickWebEngineView::loadProgressChanged, m_parent, &QWebEngineWebViewPrivate::q_loadProgressChanged);
QObject::connect(webEngineView, &QQuickWebEngineView::loadingChanged, m_parent, &QWebEngineWebViewPrivate::q_loadingChanged);
QObject::connect(webEngineView, &QQuickWebEngineView::titleChanged, m_parent, &QWebEngineWebViewPrivate::q_titleChanged);
+ QObject::connect(webEngineView, &QQuickWebEngineView::profileChanged,m_parent, &QWebEngineWebViewPrivate::q_profileChanged);
+ QObject::connect(profile, &QQuickWebEngineProfile::httpUserAgentChanged, m_parent, &QWebEngineWebViewPrivate::q_httpUserAgentChanged);
webEngineView->setParentItem(parentItem);
m_webEngineView.reset(webEngineView);
}
diff --git a/src/plugins/webengine/qwebenginewebview_p.h b/src/plugins/webengine/qwebenginewebview_p.h
index 88d6284..995f2f0 100644
--- a/src/plugins/webengine/qwebenginewebview_p.h
+++ b/src/plugins/webengine/qwebenginewebview_p.h
@@ -55,6 +55,8 @@
#include <QtQml/qqmlcomponent.h>
#include <private/qabstractwebview_p.h>
+#include <QtWebEngine/QQuickWebEngineProfile>
+
QT_BEGIN_NAMESPACE
@@ -68,6 +70,8 @@ public:
explicit QWebEngineWebViewPrivate(QObject *p = 0);
~QWebEngineWebViewPrivate() Q_DECL_OVERRIDE;
+ QString httpUserAgent() const Q_DECL_OVERRIDE;
+ void setHttpUserAgent(const QString &userAgent) Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
bool canGoBack() const Q_DECL_OVERRIDE;
@@ -95,12 +99,16 @@ private Q_SLOTS:
void q_loadProgressChanged();
void q_titleChanged();
void q_loadingChanged(QQuickWebEngineLoadRequest *loadRequest);
+ void q_profileChanged();
+ void q_httpUserAgentChanged();
protected:
void runJavaScriptPrivate(const QString& script,
int callbackId) Q_DECL_OVERRIDE;
private:
+ QQuickWebEngineProfile *m_profile;
+ QString m_httpUserAgent;
struct QQuickWebEngineViewPtr
{
inline QQuickWebEngineView *operator->() const
diff --git a/src/plugins/winrt/qwinrtwebview.cpp b/src/plugins/winrt/qwinrtwebview.cpp
index 0faf7d1..8deabdc 100644
--- a/src/plugins/winrt/qwinrtwebview.cpp
+++ b/src/plugins/winrt/qwinrtwebview.cpp
@@ -54,6 +54,8 @@
#include <windows.ui.xaml.controls.h>
#include <windows.ui.xaml.markup.h>
#include <windows.web.h>
+#include <urlmon.h>
+#include <WinInet.h>
using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
@@ -373,6 +375,36 @@ QWinRTWebViewPrivate::~QWinRTWebViewPrivate()
});
}
+QString QWinRTWebViewPrivate::httpUserAgent() const
+{
+#ifdef QT_WINRT_URLMKGETSESSIONOPTION_NOT_AVAILABLE
+ qWarning() << "Used Windows SDK version (" << QString::number(QT_UCRTVERSION) << ") does not "
+ "support getting or setting of the user agent property from within UWP applications. Consider updating to a more recent Windows 10 "
+ "SDK (16299 or above).";
+ return "";
+#else
+ char buffer[255];
+ unsigned long stringLength;
+ HRESULT hr = UrlMkGetSessionOption(0x10000001,&buffer,255,&stringLength,0);
+ Q_ASSERT_SUCCEEDED(hr);
+ return QString(buffer);
+#endif
+}
+
+void QWinRTWebViewPrivate::setHttpUserAgent(const QString &userAgent)
+{
+#ifdef QT_WINRT_URLMKSETSESSIONOPTION_NOT_AVAILABLE
+ Q_UNUSED(userAgent);
+ qWarning() << "Used Windows SDK version (" << QString::number(QT_UCRTVERSION) << ") does not "
+ "support getting or setting of the user agent property from within UWP applications. Consider updating to a more recent Windows 10 "
+ "SDK (16299 or above).";
+#else
+ HRESULT hr = UrlMkSetSessionOption(0x10000001,userAgent.toLocal8Bit().data(),userAgent.size(),0);
+ Q_ASSERT_SUCCEEDED(hr);
+ emit httpUserAgentChanged(userAgent);
+#endif
+}
+
QUrl QWinRTWebViewPrivate::url() const
{
ComPtr<IUriRuntimeClass> uri;
diff --git a/src/plugins/winrt/qwinrtwebview_p.h b/src/plugins/winrt/qwinrtwebview_p.h
index 3756b7d..0030824 100644
--- a/src/plugins/winrt/qwinrtwebview_p.h
+++ b/src/plugins/winrt/qwinrtwebview_p.h
@@ -75,6 +75,8 @@ public:
explicit QWinRTWebViewPrivate(QObject *parent = nullptr);
~QWinRTWebViewPrivate() Q_DECL_OVERRIDE;
+ QString httpUserAgent() const Q_DECL_OVERRIDE;
+ void setHttpUserAgent(const QString &userAgent) Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
bool canGoBack() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/winrt/winrt.pro b/src/plugins/winrt/winrt.pro
index dabcbfd..827b4ef 100644
--- a/src/plugins/winrt/winrt.pro
+++ b/src/plugins/winrt/winrt.pro
@@ -1,5 +1,6 @@
TARGET = qtwebview_winrt
QT += core gui webview-private
+LIBS_PRIVATE += -lurlmon
PLUGIN_TYPE = webview
PLUGIN_CLASS_NAME = QWinrtWebViewPlugin
@@ -15,6 +16,15 @@ SOURCES += \
HEADERS += \
qwinrtwebview_p.h
+WINDOWS_SDK_VERSION_STRING = $$(WindowsSDKVersion)
+WINDOWS_SDK_VERSION = $$member($$list($$split(WINDOWS_SDK_VERSION_STRING, .)), 2)
+
+lessThan(WINDOWS_SDK_VERSION, 16299) {
+ DEFINES += QT_WINRT_URLMKGETSESSIONOPTION_NOT_AVAILABLE
+ DEFINES += QT_WINRT_URLMKSETSESSIONOPTION_NOT_AVAILABLE
+ DEFINES += QT_UCRTVERSION=$$WINDOWS_SDK_VERSION
+}
+
OTHER_FILES +=
DISTFILES += \
diff --git a/src/webview/qabstractwebview_p.h b/src/webview/qabstractwebview_p.h
index d2eec30..e7c5653 100644
--- a/src/webview/qabstractwebview_p.h
+++ b/src/webview/qabstractwebview_p.h
@@ -70,6 +70,7 @@ Q_SIGNALS:
void loadProgressChanged(int progress);
void javaScriptResult(int id, const QVariant &result);
void requestFocus(bool focus);
+ void httpUserAgentChanged(const QString &httpUserAgent);
protected:
explicit QAbstractWebView(QObject *p = 0) : QObject(p) { }
diff --git a/src/webview/qquickwebview.cpp b/src/webview/qquickwebview.cpp
index 898154e..4441df4 100644
--- a/src/webview/qquickwebview.cpp
+++ b/src/webview/qquickwebview.cpp
@@ -101,6 +101,7 @@ QQuickWebView::QQuickWebView(QQuickItem *parent)
connect(m_webView, &QWebView::loadingChanged, this, &QQuickWebView::onLoadingChanged);
connect(m_webView, &QWebView::requestFocus, this, &QQuickWebView::onFocusRequest);
connect(m_webView, &QWebView::javaScriptResult, this, &QQuickWebView::onRunJavaScriptResult);
+ connect(m_webView, &QWebView::httpUserAgentChanged, this, &QQuickWebView::httpUserAgentChanged);
}
QQuickWebView::~QQuickWebView()
@@ -108,6 +109,24 @@ QQuickWebView::~QQuickWebView()
}
/*!
+ \qmlproperty url QtWebView::WebView::httpUserAgent
+ \since QtWebView 1.14
+ The user agent in use.
+
+ \note on WinRT, this property affects all WebViews of the application.
+*/
+
+void QQuickWebView::setHttpUserAgent(const QString &userAgent)
+{
+ m_webView->setHttpUserAgent(userAgent);
+}
+
+QString QQuickWebView::httpUserAgent() const
+{
+ return m_webView->httpUserAgent();
+}
+
+/*!
\qmlproperty url QtWebView::WebView::url
The URL of currently loaded web page. Changing this will trigger
diff --git a/src/webview/qquickwebview_p.h b/src/webview/qquickwebview_p.h
index 6534815..fef5af9 100644
--- a/src/webview/qquickwebview_p.h
+++ b/src/webview/qquickwebview_p.h
@@ -60,6 +60,7 @@ class QWebViewLoadRequestPrivate;
class Q_WEBVIEW_EXPORT QQuickWebView : public QQuickViewController, public QWebViewInterface
{
Q_OBJECT
+ Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged REVISION 14)
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged REVISION 1)
Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
@@ -79,6 +80,8 @@ public:
QQuickWebView(QQuickItem *parent = 0);
~QQuickWebView();
+ QString httpUserAgent() const Q_DECL_OVERRIDE;
+ void setHttpUserAgent(const QString &userAgent) Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
int loadProgress() const Q_DECL_OVERRIDE;
@@ -101,6 +104,7 @@ Q_SIGNALS:
void urlChanged();
Q_REVISION(1) void loadingChanged(QQuickWebViewLoadRequest *loadRequest);
void loadProgressChanged();
+ Q_REVISION(14) void httpUserAgentChanged();
protected:
void itemChange(ItemChange change, const ItemChangeData &value) Q_DECL_OVERRIDE;
diff --git a/src/webview/qwebview.cpp b/src/webview/qwebview.cpp
index 7e457be..943218b 100644
--- a/src/webview/qwebview.cpp
+++ b/src/webview/qwebview.cpp
@@ -54,6 +54,7 @@ QWebView::QWebView(QObject *p)
connect(d, &QAbstractWebView::urlChanged, this, &QWebView::onUrlChanged);
connect(d, &QAbstractWebView::loadingChanged, this, &QWebView::onLoadingChanged);
connect(d, &QAbstractWebView::loadProgressChanged, this, &QWebView::onLoadProgressChanged);
+ connect(d, &QAbstractWebView::httpUserAgentChanged, this, &QWebView::onHttpUserAgentChanged);
connect(d, &QAbstractWebView::requestFocus, this, &QWebView::requestFocus);
connect(d, &QAbstractWebView::javaScriptResult,
this, &QWebView::javaScriptResult);
@@ -63,6 +64,19 @@ QWebView::~QWebView()
{
}
+QString QWebView::httpUserAgent() const
+{
+ if (m_httpUserAgent.isEmpty()){
+ m_httpUserAgent = d->httpUserAgent();
+ }
+ return m_httpUserAgent;
+}
+
+void QWebView::setHttpUserAgent(const QString &userAgent)
+{
+ return d->setHttpUserAgent(userAgent);
+}
+
QUrl QWebView::url() const
{
return m_url;
@@ -193,7 +207,14 @@ void QWebView::onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest)
onUrlChanged(loadRequest.m_url);
Q_EMIT loadingChanged(loadRequest);
+}
+void QWebView::onHttpUserAgentChanged(const QString &userAgent)
+{
+ if (m_httpUserAgent == userAgent)
+ return;
+ m_httpUserAgent = userAgent;
+ Q_EMIT httpUserAgentChanged();
}
void QWebView::init()
diff --git a/src/webview/qwebview_p.h b/src/webview/qwebview_p.h
index aa09f03..380d701 100644
--- a/src/webview/qwebview_p.h
+++ b/src/webview/qwebview_p.h
@@ -77,6 +77,8 @@ public:
explicit QWebView(QObject *p = 0);
~QWebView() Q_DECL_OVERRIDE;
+ QString httpUserAgent() const Q_DECL_OVERRIDE;
+ void setHttpUserAgent(const QString &httpUserAgent) Q_DECL_OVERRIDE;
QUrl url() const Q_DECL_OVERRIDE;
void setUrl(const QUrl &url) Q_DECL_OVERRIDE;
bool canGoBack() const Q_DECL_OVERRIDE;
@@ -106,6 +108,7 @@ Q_SIGNALS:
void loadProgressChanged();
void javaScriptResult(int id, const QVariant &result);
void requestFocus(bool focus);
+ void httpUserAgentChanged();
protected:
void init() Q_DECL_OVERRIDE;
@@ -117,6 +120,7 @@ private Q_SLOTS:
void onUrlChanged(const QUrl &url);
void onLoadProgressChanged(int progress);
void onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest);
+ void onHttpUserAgentChanged(const QString &httpUserAgent);
private:
friend class QQuickViewController;
@@ -128,6 +132,7 @@ private:
int m_progress;
QString m_title;
QUrl m_url;
+ mutable QString m_httpUserAgent;
};
QT_END_NAMESPACE
diff --git a/src/webview/qwebviewfactory.cpp b/src/webview/qwebviewfactory.cpp
index 7a22fd1..8856168 100644
--- a/src/webview/qwebviewfactory.cpp
+++ b/src/webview/qwebviewfactory.cpp
@@ -64,6 +64,8 @@ public:
void setVisibility(QWindow::Visibility visibility) override { Q_UNUSED(visibility); }
void setVisible(bool visible) override { Q_UNUSED(visible); }
+ QString httpUserAgent() const override { return QString(); }
+ void setHttpUserAgent(const QString &userAgent) override { Q_UNUSED(userAgent) }
QUrl url() const override { return QUrl(); }
void setUrl(const QUrl &url) override { Q_UNUSED(url); }
bool canGoBack() const override { return false; }
diff --git a/src/webview/qwebviewinterface_p.h b/src/webview/qwebviewinterface_p.h
index a3216da..d9e566c 100644
--- a/src/webview/qwebviewinterface_p.h
+++ b/src/webview/qwebviewinterface_p.h
@@ -63,6 +63,8 @@ class QWebViewInterface
{
public:
virtual ~QWebViewInterface() {}
+ virtual QString httpUserAgent() const = 0;
+ virtual void setHttpUserAgent(const QString &httpUserAgent) = 0;
virtual QUrl url() const = 0;
virtual void setUrl(const QUrl &url) = 0;
virtual bool canGoBack() const = 0;
diff --git a/src/webview/webview.pro b/src/webview/webview.pro
index a1ba017..2203014 100644
--- a/src/webview/webview.pro
+++ b/src/webview/webview.pro
@@ -40,7 +40,7 @@ ANDROID_BUNDLED_JAR_DEPENDENCIES = \
ANDROID_PERMISSIONS = \
android.permission.ACCESS_FINE_LOCATION
ANDROID_LIB_DEPENDENCIES = \
- plugins/webview/libqtwebview_android.so
+ plugins/webview/libplugins_webview_qtwebview_android.so
HEADERS += $$PUBLIC_HEADERS $$PRIVATE_HEADERS