FIX:block HTTP links&open in default browser
fixed:https://jira.bambooolab.com/browse/STUDIO-3030 Block web page redirect requests and open them in the default browser Change-Id: Ie79f8259859fa6ba158f31710179a8c7c53d6fa4
This commit is contained in:
parent
297e4d1373
commit
46a48539bb
|
@ -58,6 +58,7 @@ ProjectPanel::ProjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos,
|
|||
main_sizer->Add(m_browser, wxSizerFlags().Expand().Proportion(1));
|
||||
m_browser->Bind(wxEVT_WEBVIEW_NAVIGATED, &ProjectPanel::on_navigated, this);
|
||||
m_browser->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, &ProjectPanel::OnScriptMessage, this, m_browser->GetId());
|
||||
Bind(wxEVT_WEBVIEW_NAVIGATING, &ProjectPanel::onWebNavigating, this, m_browser->GetId());
|
||||
|
||||
Bind(EVT_PROJECT_RELOAD, &ProjectPanel::on_reload, this);
|
||||
|
||||
|
@ -68,6 +69,19 @@ ProjectPanel::ProjectPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos,
|
|||
|
||||
ProjectPanel::~ProjectPanel() {}
|
||||
|
||||
|
||||
void ProjectPanel::onWebNavigating(wxWebViewEvent& evt)
|
||||
{
|
||||
wxString tmpUrl = evt.GetURL();
|
||||
//wxString NowUrl = m_browser->GetCurrentURL();
|
||||
|
||||
if (boost::starts_with(tmpUrl, "http://") || boost::starts_with(tmpUrl, "https://")) {
|
||||
m_browser->Stop();
|
||||
evt.Veto();
|
||||
wxLaunchDefaultApplication(tmpUrl);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::on_reload(wxCommandEvent& evt)
|
||||
{
|
||||
boost::thread reload = boost::thread([this] {
|
||||
|
|
|
@ -73,6 +73,7 @@ public:
|
|||
~ProjectPanel();
|
||||
|
||||
|
||||
void onWebNavigating(wxWebViewEvent& evt);
|
||||
void on_reload(wxCommandEvent& evt);
|
||||
void on_size(wxSizeEvent &event);
|
||||
void on_navigated(wxWebViewEvent& event);
|
||||
|
|
Loading…
Reference in New Issue