fix(macos): disable App Transport Security (#1157)
* feat(webview): enable context menu This enables the ability (at least on MacOS) to reload the webview. * fix(webview): add handler for webview error Adding this un-covered the following error when trying to load a the printer page using http and hostname: ``` OnError: error loading page about:blank wxWEBVIEW_NAV_ERR_OTHER The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. ``` * fix(macos): disable App Transport Security policy Disables the [App Transport Security](https://developer.apple.com/documentation/bundleresources/information_property_list/nsapptransportsecurity) policy that blocks loading http urls (via hostname...ip addresses were fine because ip addresses can't have certs, so they would be excluded from the ATS restriction). Resolves #791
This commit is contained in:
parent
a636df63c1
commit
c675d979a7
4 changed files with 44 additions and 1 deletions
|
@ -118,5 +118,13 @@
|
|||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<!-- Disable App Transport Security. Resolves https://github.com/SoftFever/OrcaSlicer/issues/791 -->
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
<key>NSAllowsArbitraryLoadsInWebContent</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -30,6 +30,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||
return;
|
||||
}
|
||||
|
||||
Bind(wxEVT_WEBVIEW_ERROR, &PrinterWebView::OnError, this);
|
||||
|
||||
SetSizer(topsizer);
|
||||
|
||||
topsizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
||||
|
@ -83,6 +85,38 @@ void PrinterWebView::OnClose(wxCloseEvent& evt)
|
|||
this->Hide();
|
||||
}
|
||||
|
||||
void PrinterWebView::OnError(wxWebViewEvent &evt)
|
||||
{
|
||||
auto e = "unknown error";
|
||||
switch (evt.GetInt()) {
|
||||
case wxWEBVIEW_NAV_ERR_CONNECTION:
|
||||
e = "wxWEBVIEW_NAV_ERR_CONNECTION";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_CERTIFICATE:
|
||||
e = "wxWEBVIEW_NAV_ERR_CERTIFICATE";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_AUTH:
|
||||
e = "wxWEBVIEW_NAV_ERR_AUTH";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_SECURITY:
|
||||
e = "wxWEBVIEW_NAV_ERR_SECURITY";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_NOT_FOUND:
|
||||
e = "wxWEBVIEW_NAV_ERR_NOT_FOUND";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_REQUEST:
|
||||
e = "wxWEBVIEW_NAV_ERR_REQUEST";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_USER_CANCELLED:
|
||||
e = "wxWEBVIEW_NAV_ERR_USER_CANCELLED";
|
||||
break;
|
||||
case wxWEBVIEW_NAV_ERR_OTHER:
|
||||
e = "wxWEBVIEW_NAV_ERR_OTHER";
|
||||
break;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": error loading page %1% %2% %3% %4%") %evt.GetURL() %evt.GetTarget() %e %evt.GetString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // GUI
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
void load_url(wxString& url);
|
||||
void UpdateState();
|
||||
void OnClose(wxCloseEvent& evt);
|
||||
void OnError(wxWebViewEvent& evt);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
|
|||
#ifndef __WIN32__
|
||||
});
|
||||
#endif
|
||||
webView->EnableContextMenu(false);
|
||||
webView->EnableContextMenu(true);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": failed. Use fake web view.";
|
||||
webView = new FakeWebView;
|
||||
|
|
Loading…
Reference in a new issue