summaryrefslogtreecommitdiffstats
path: root/src/plugins/winrt/qwinrtwebview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/winrt/qwinrtwebview.cpp')
-rw-r--r--src/plugins/winrt/qwinrtwebview.cpp32
1 files changed, 32 insertions, 0 deletions
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;