Implement user agent access for macOS

This commit is contained in:
Tobias Taschner
2021-03-16 14:21:09 +01:00
parent 97e469c255
commit 18f5b01cc6
2 changed files with 20 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ public:
virtual bool IsAccessToDevToolsEnabled() const wxOVERRIDE;
virtual void EnableAccessToDevTools(bool enable = true) wxOVERRIDE;
virtual bool SetUserAgent(const wxString& userAgent) wxOVERRIDE;
//History functions
virtual void ClearHistory() wxOVERRIDE;
@@ -111,6 +112,7 @@ protected:
private:
OSXWebViewPtr m_webView;
wxStringToWebHandlerMap m_handlers;
wxString m_customUserAgent;
WX_NSObject m_navigationDelegate;
WX_NSObject m_UIDelegate;

View File

@@ -151,6 +151,9 @@ bool wxWebViewWebKit::Create(wxWindow *parent,
MacPostControlCreate(pos, size);
if (!m_customUserAgent.empty())
SetUserAgent(m_customUserAgent);
[m_webView setHidden:false];
@@ -328,6 +331,21 @@ void wxWebViewWebKit::EnableAccessToDevTools(bool enable)
[prefs performSelector:devToolsSelector withObject:(id)enable];
}
bool wxWebViewWebKit::SetUserAgent(const wxString& userAgent)
{
if (WX_IS_MACOS_AVAILABLE(10, 11))
{
if (m_webView)
m_webView.customUserAgent = wxCFStringRef(userAgent).AsNSString();
else
m_customUserAgent = userAgent;
return true;
}
else
return false;
}
void wxWebViewWebKit::SetZoomType(wxWebViewZoomType zoomType)
{
// there is only one supported zoom type at the moment so this setter