Allow distinguishing user- from script-opened wxWebView windows

Add wxWebViewEvent::GetNavigationAction() returning a value that can be
either wxWEBVIEW_NAV_ACTION_USER for the links opened by the user, or
wxWEBVIEW_NAV_ACTION_OTHER for the other ones (e.g. opened from
JavaScript code on the page).

Closes #15402.
This commit is contained in:
Steven Lamerton
2018-08-19 22:27:34 +02:00
committed by Vadim Zeitlin
parent 91aa6ba36e
commit b61123cd7d
7 changed files with 84 additions and 13 deletions

View File

@@ -22,6 +22,7 @@
#include <exdispid.h>
#include <exdisp.h>
#include <mshtml.h>
#include <shobjidl.h>
#include "wx/msw/registry.h"
#include "wx/msw/missing.h"
#include "wx/msw/ole/safearray.h"
@@ -1472,9 +1473,15 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
case DISPID_NEWWINDOW3:
{
wxString url = evt[4].GetString();
long flags = evt[2].GetLong();
wxWebViewNavigationActionFlags navFlags = wxWEBVIEW_NAV_ACTION_OTHER;
if(flags & NWMF_USERINITED || flags & NWMF_USERREQUESTED)
navFlags = wxWEBVIEW_NAV_ACTION_USER;
wxWebViewEvent event(wxEVT_WEBVIEW_NEWWINDOW,
GetId(), url, wxEmptyString);
GetId(), url, wxEmptyString, navFlags);
event.SetEventObject(this);
HandleWindowEvent(event);