Implement user agent access for macOS
This commit is contained in:
@@ -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;
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user