1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/webview_ie.cpp
3 // Purpose: wxMSW wxWebViewIE class implementation for web view component
4 // Author: Marianne Gagnon
6 // Copyright: (c) 2010 Marianne Gagnon, Steven Lamerton
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
13 #if defined(__BORLANDC__)
17 #include "wx/msw/webview_ie.h"
27 // Various definitions are missing from mingw
29 typedef enum CommandStateChangeConstants
{
30 CSC_UPDATECOMMANDS
= (int) 0xFFFFFFFF,
31 CSC_NAVIGATEFORWARD
= 0x1,
32 CSC_NAVIGATEBACK
= 0x2
33 } CommandStateChangeConstants
;
35 #define DISPID_COMMANDSTATECHANGE 105
36 #define DISPID_NAVIGATECOMPLETE2 252
37 #define DISPID_NAVIGATEERROR 271
38 #define DISPID_NEWWINDOW3 273
39 #define OLECMDID_OPTICAL_ZOOM 63
40 #define INET_E_ERROR_FIRST 0x800C0002L
41 #define INET_E_INVALID_URL 0x800C0002L
42 #define INET_E_NO_SESSION 0x800C0003L
43 #define INET_E_CANNOT_CONNECT 0x800C0004L
44 #define INET_E_RESOURCE_NOT_FOUND 0x800C0005L
45 #define INET_E_OBJECT_NOT_FOUND 0x800C0006L
46 #define INET_E_DATA_NOT_AVAILABLE 0x800C0007L
47 #define INET_E_DOWNLOAD_FAILURE 0x800C0008L
48 #define INET_E_AUTHENTICATION_REQUIRED 0x800C0009L
49 #define INET_E_NO_VALID_MEDIA 0x800C000AL
50 #define INET_E_CONNECTION_TIMEOUT 0x800C000BL
51 #define INET_E_INVALID_REQUEST 0x800C000CL
52 #define INET_E_UNKNOWN_PROTOCOL 0x800C000DL
53 #define INET_E_SECURITY_PROBLEM 0x800C000EL
54 #define INET_E_CANNOT_LOAD_DATA 0x800C000FL
55 #define INET_E_CANNOT_INSTANTIATE_OBJECT 0x800C0010L
56 #define INET_E_QUERYOPTION_UNKNOWN 0x800C0013L
57 #define INET_E_REDIRECT_FAILED 0x800C0014L
58 #define INET_E_REDIRECT_TO_DIR 0x800C0015L
59 #define INET_E_CANNOT_LOCK_REQUEST 0x800C0016L
60 #define INET_E_USE_EXTEND_BINDING 0x800C0017L
61 #define INET_E_TERMINATED_BIND 0x800C0018L
62 #define INET_E_INVALID_CERTIFICATE 0x800C0019L
63 #define INET_E_CODE_DOWNLOAD_DECLINED 0x800C0100L
64 #define INET_E_RESULT_DISPATCHED 0x800C0200L
65 #define INET_E_CANNOT_REPLACE_SFP_FILE 0x800C0300L
66 #define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY 0x800C0500L
67 #define INET_E_CODE_INSTALL_SUPPRESSED 0x800C0400L
69 #define REFRESH_NORMAL 0
70 #define REFRESH_COMPLETELY 3
73 BEGIN_EVENT_TABLE(wxWebViewIE
, wxControl
)
74 EVT_ACTIVEX(wxID_ANY
, wxWebViewIE::onActiveXEvent
)
75 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg
)
78 bool wxWebViewIE::Create(wxWindow
* parent
,
86 if (!wxControl::Create(parent
, id
, pos
, size
, style
,
87 wxDefaultValidator
, name
))
93 m_canNavigateBack
= false;
94 m_canNavigateForward
= false;
96 m_historyLoadingFromList
= false;
97 m_historyEnabled
= true;
98 m_historyPosition
= -1;
100 if (::CoCreateInstance(CLSID_WebBrowser
, NULL
,
101 CLSCTX_INPROC_SERVER
, // CLSCTX_INPROC,
102 IID_IWebBrowser2
, (void**)&m_webBrowser
) != 0)
104 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
108 m_ie
.SetDispatchPtr(m_webBrowser
); // wxAutomationObject will release itself
110 m_webBrowser
->put_RegisterAsBrowser(VARIANT_TRUE
);
111 m_webBrowser
->put_RegisterAsDropTarget(VARIANT_TRUE
);
112 //m_webBrowser->put_Silent(VARIANT_FALSE);
114 m_container
= new wxActiveXContainer(this, IID_IWebBrowser2
, m_webBrowser
);
116 SetBackgroundStyle(wxBG_STYLE_PAINT
);
117 SetDoubleBuffered(true);
123 void wxWebViewIE::LoadUrl(const wxString
& url
)
125 m_ie
.CallMethod("Navigate", (BSTR
) url
.wc_str(), NULL
, NULL
, NULL
, NULL
);
128 void wxWebViewIE::SetPage(const wxString
& html
, const wxString
&)
130 LoadUrl("about:blank");
132 // Let the wx events generated for navigation events be processed, so
133 // that the underlying IE component completes its Document object.
134 // FIXME: calling wxYield is not elegant nor very reliable probably
137 // TODO: consider the "baseUrl" parameter if possible
138 // TODO: consider encoding
139 BSTR bstr
= SysAllocString(html
.wc_str());
141 // Creates a new one-dimensional array
142 SAFEARRAY
*psaStrings
= SafeArrayCreateVector(VT_VARIANT
, 0, 1);
143 if (psaStrings
!= NULL
)
146 HRESULT hr
= SafeArrayAccessData(psaStrings
, (LPVOID
*)¶m
);
148 param
->bstrVal
= bstr
;
150 hr
= SafeArrayUnaccessData(psaStrings
);
151 IHTMLDocument2
* document
= GetDocument();
152 document
->write(psaStrings
);
154 // SafeArrayDestroy calls SysFreeString for each BSTR
155 SafeArrayDestroy(psaStrings
);
159 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
164 wxString
wxWebViewIE::GetPageSource()
166 IHTMLDocument2
* document
= GetDocument();
167 IHTMLElement
*bodyTag
= NULL
;
168 IHTMLElement
*htmlTag
= NULL
;
170 HRESULT hr
= document
->get_body(&bodyTag
);
173 hr
= bodyTag
->get_parentElement(&htmlTag
);
176 htmlTag
->get_outerHTML(&bstr
);
183 return wxString(bstr
);
186 // FIXME? retrieve OLECMDID_GETZOOMRANGE instead of hardcoding range 0-4
187 wxWebViewZoom
wxWebViewIE::GetZoom()
189 const int zoom
= GetIETextZoom();
194 return wxWEB_VIEW_ZOOM_TINY
;
197 return wxWEB_VIEW_ZOOM_SMALL
;
200 return wxWEB_VIEW_ZOOM_MEDIUM
;
203 return wxWEB_VIEW_ZOOM_LARGE
;
206 return wxWEB_VIEW_ZOOM_LARGEST
;
210 return wxWEB_VIEW_ZOOM_MEDIUM
;
213 void wxWebViewIE::SetZoom(wxWebViewZoom zoom
)
215 // I know I could cast from enum to int since wxWebViewZoom happens to
216 // match with IE's zoom levels, but I don't like doing that, what if enum
220 case wxWEB_VIEW_ZOOM_TINY
:
223 case wxWEB_VIEW_ZOOM_SMALL
:
226 case wxWEB_VIEW_ZOOM_MEDIUM
:
229 case wxWEB_VIEW_ZOOM_LARGE
:
232 case wxWEB_VIEW_ZOOM_LARGEST
:
240 void wxWebViewIE::SetIETextZoom(int level
)
243 VariantInit (&zoomVariant
);
244 V_VT(&zoomVariant
) = VT_I4
;
245 V_I4(&zoomVariant
) = level
;
247 HRESULT result
= m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
248 OLECMDEXECOPT_DONTPROMPTUSER
,
250 wxASSERT (result
== S_OK
);
252 VariantClear (&zoomVariant
);
255 int wxWebViewIE::GetIETextZoom()
258 VariantInit (&zoomVariant
);
259 V_VT(&zoomVariant
) = VT_I4
;
260 V_I4(&zoomVariant
) = 4;
262 HRESULT result
= m_webBrowser
->ExecWB(OLECMDID_ZOOM
,
263 OLECMDEXECOPT_DONTPROMPTUSER
,
265 wxASSERT (result
== S_OK
);
267 int zoom
= V_I4(&zoomVariant
);
268 VariantClear (&zoomVariant
);
273 void wxWebViewIE::SetIEOpticalZoom(float zoom
)
275 // TODO: add support for optical zoom (IE7+ only)
277 // TODO: get range from OLECMDID_OPTICAL_GETZOOMRANGE instead of hardcoding?
278 wxASSERT(zoom
>= 10.0f
);
279 wxASSERT(zoom
<= 1000.0f
);
282 VariantInit (&zoomVariant
);
283 V_VT(&zoomVariant
) = VT_I4
;
284 V_I4(&zoomVariant
) = (zoom
* 100.0f
);
286 HRESULT result
= m_webBrowser
->ExecWB((OLECMDID
)OLECMDID_OPTICAL_ZOOM
,
287 OLECMDEXECOPT_DODEFAULT
,
290 wxASSERT (result
== S_OK
);
293 float wxWebViewIE::GetIEOpticalZoom()
295 // TODO: add support for optical zoom (IE7+ only)
298 VariantInit (&zoomVariant
);
299 V_VT(&zoomVariant
) = VT_I4
;
300 V_I4(&zoomVariant
) = -1;
302 HRESULT result
= m_webBrowser
->ExecWB((OLECMDID
)OLECMDID_OPTICAL_ZOOM
,
303 OLECMDEXECOPT_DODEFAULT
, NULL
,
305 wxASSERT (result
== S_OK
);
307 const int zoom
= V_I4(&zoomVariant
);
308 VariantClear (&zoomVariant
);
310 return zoom
/ 100.0f
;
313 void wxWebViewIE::SetZoomType(wxWebViewZoomType
)
315 // TODO: add support for optical zoom (IE7+ only)
319 wxWebViewZoomType
wxWebViewIE::GetZoomType() const
321 // TODO: add support for optical zoom (IE7+ only)
322 return wxWEB_VIEW_ZOOM_TYPE_TEXT
;
325 bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType
) const
327 // both are supported
328 // TODO: IE6 only supports text zoom, check if it's IE6 first
332 void wxWebViewIE::Print()
334 m_webBrowser
->ExecWB(OLECMDID_PRINTPREVIEW
,
335 OLECMDEXECOPT_DODEFAULT
, NULL
, NULL
);
338 bool wxWebViewIE::CanGoBack()
341 return m_historyPosition
> 0;
346 bool wxWebViewIE::CanGoForward()
349 return m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1;
354 void wxWebViewIE::LoadHistoryItem(wxSharedPtr
<wxWebHistoryItem
> item
)
357 for(unsigned int i
= 0; i
< m_historyList
.size(); i
++)
359 //We compare the actual pointers to find the correct item
360 if(m_historyList
[i
].get() == item
.get())
363 wxASSERT_MSG(pos
!= static_cast<int>(m_historyList
.size()),
364 "invalid history item");
365 m_historyLoadingFromList
= true;
366 LoadUrl(item
->GetUrl());
367 m_historyPosition
= pos
;
370 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewIE::GetBackwardHistory()
372 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > backhist
;
373 //As we don't have std::copy or an iterator constructor in the wxwidgets
374 //native vector we construct it by hand
375 for(int i
= 0; i
< m_historyPosition
; i
++)
377 backhist
.push_back(m_historyList
[i
]);
382 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > wxWebViewIE::GetForwardHistory()
384 wxVector
<wxSharedPtr
<wxWebHistoryItem
> > forwardhist
;
385 //As we don't have std::copy or an iterator constructor in the wxwidgets
386 //native vector we construct it by hand
387 for(int i
= m_historyPosition
+ 1; i
< static_cast<int>(m_historyList
.size()); i
++)
389 forwardhist
.push_back(m_historyList
[i
]);
394 void wxWebViewIE::GoBack()
396 LoadHistoryItem(m_historyList
[m_historyPosition
- 1]);
399 void wxWebViewIE::GoForward()
401 LoadHistoryItem(m_historyList
[m_historyPosition
+ 1]);
404 void wxWebViewIE::Stop()
406 m_ie
.CallMethod("Stop");
409 void wxWebViewIE::ClearHistory()
411 m_historyList
.clear();
412 m_historyPosition
= -1;
415 void wxWebViewIE::EnableHistory(bool enable
)
417 m_historyEnabled
= enable
;
418 m_historyList
.clear();
419 m_historyPosition
= -1;
422 void wxWebViewIE::Reload(wxWebViewReloadFlags flags
)
426 V_VT(&level
) = VT_I2
;
430 case wxWEB_VIEW_RELOAD_DEFAULT
:
431 V_I2(&level
) = REFRESH_NORMAL
;
433 case wxWEB_VIEW_RELOAD_NO_CACHE
:
434 V_I2(&level
) = REFRESH_COMPLETELY
;
437 wxFAIL_MSG("Unexpected reload type");
440 m_webBrowser
->Refresh2(&level
);
443 bool wxWebViewIE::IsOfflineMode()
445 wxVariant out
= m_ie
.GetProperty("Offline");
447 wxASSERT(out
.GetType() == "bool");
449 return out
.GetBool();
452 void wxWebViewIE::SetOfflineMode(bool offline
)
454 // FIXME: the wxWidgets docs do not really document what the return
455 // parameter of PutProperty is
456 const bool success
= m_ie
.PutProperty("Offline", (offline
?
462 bool wxWebViewIE::IsBusy()
464 if (m_isBusy
) return true;
466 wxVariant out
= m_ie
.GetProperty("Busy");
468 wxASSERT(out
.GetType() == "bool");
470 return out
.GetBool();
473 wxString
wxWebViewIE::GetCurrentURL()
475 wxVariant out
= m_ie
.GetProperty("LocationURL");
477 wxASSERT(out
.GetType() == "string");
478 return out
.GetString();
481 wxString
wxWebViewIE::GetCurrentTitle()
483 IHTMLDocument2
* document
= GetDocument();
486 document
->get_nameProp(&title
);
488 return wxString(title
);
491 bool wxWebViewIE::CanCut()
493 return CanExecCommand("Cut");
496 bool wxWebViewIE::CanCopy()
498 return CanExecCommand("Copy");
500 bool wxWebViewIE::CanPaste()
502 return CanExecCommand("Paste");
505 void wxWebViewIE::Cut()
510 void wxWebViewIE::Copy()
515 void wxWebViewIE::Paste()
517 ExecCommand("Paste");
520 bool wxWebViewIE::CanUndo()
522 return CanExecCommand("Undo");
524 bool wxWebViewIE::CanRedo()
526 return CanExecCommand("Redo");
529 void wxWebViewIE::Undo()
534 void wxWebViewIE::Redo()
539 void wxWebViewIE::SetEditable(bool enable
)
541 IHTMLDocument2
* document
= GetDocument();
543 document
->put_designMode(SysAllocString(L
"On"));
545 document
->put_designMode(SysAllocString(L
"Off"));
550 bool wxWebViewIE::IsEditable()
552 IHTMLDocument2
* document
= GetDocument();
554 document
->get_designMode(&mode
);
555 if(wxString(mode
) == "On")
563 void wxWebViewIE::SelectAll()
565 ExecCommand("SelectAll");
568 bool wxWebViewIE::HasSelection()
570 IHTMLDocument2
* document
= GetDocument();
571 IHTMLSelectionObject
* selection
;
573 HRESULT hr
= document
->get_selection(&selection
);
576 selection
->get_type(&type
);
577 selection
->Release();
580 return wxString(type
) != "None";
583 void wxWebViewIE::DeleteSelection()
585 ExecCommand("Delete");
588 wxString
wxWebViewIE::GetSelectedText()
590 IHTMLDocument2
* document
= GetDocument();
591 IHTMLSelectionObject
* selection
;
593 HRESULT hr
= document
->get_selection(&selection
);
597 hr
= selection
->createRange(&disrange
);
600 IHTMLTxtRange
* range
;
601 hr
= disrange
->QueryInterface(IID_IHTMLTxtRange
, (void**)&range
);
605 range
->get_text(&text
);
606 selected
= wxString(text
);
611 selection
->Release();
617 bool wxWebViewIE::CanExecCommand(wxString command
)
619 IHTMLDocument2
* document
= GetDocument();
620 VARIANT_BOOL enabled
;
622 document
->queryCommandEnabled(SysAllocString(command
.wc_str()), &enabled
);
625 return (enabled
== VARIANT_TRUE
);
628 void wxWebViewIE::ExecCommand(wxString command
)
630 IHTMLDocument2
* document
= GetDocument();
631 document
->execCommand(SysAllocString(command
.wc_str()), VARIANT_FALSE
, VARIANT(), NULL
);
635 IHTMLDocument2
* wxWebViewIE::GetDocument()
637 wxVariant variant
= m_ie
.GetProperty("Document");
638 IHTMLDocument2
* document
= (IHTMLDocument2
*)variant
.GetVoidPtr();
645 void wxWebViewIE::onActiveXEvent(wxActiveXEvent
& evt
)
647 if (m_webBrowser
== NULL
) return;
649 switch (evt
.GetDispatchId())
651 case DISPID_BEFORENAVIGATE2
:
655 wxString url
= evt
[1].GetString();
656 wxString target
= evt
[3].GetString();
658 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING
,
659 GetId(), url
, target
, true);
660 event
.SetEventObject(this);
661 HandleWindowEvent(event
);
663 if (event
.IsVetoed())
665 wxActiveXEventNativeMSW
* nativeParams
=
666 evt
.GetNativeParameters();
667 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[0]) = VARIANT_TRUE
;
670 // at this point, either the navigation event has been cancelled
671 // and we're not busy, either it was accepted and IWebBrowser2's
672 // Busy property will be true; so we don't need our override
679 case DISPID_NAVIGATECOMPLETE2
:
681 wxString url
= evt
[1].GetString();
682 // TODO: set target parameter if possible
683 wxString target
= wxEmptyString
;
684 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED
,
685 GetId(), url
, target
, false);
686 event
.SetEventObject(this);
687 HandleWindowEvent(event
);
691 case DISPID_PROGRESSCHANGE
:
697 case DISPID_DOCUMENTCOMPLETE
:
699 //Only send a complete even if we are actually finished, this brings
700 //the event in to line with webkit
702 m_webBrowser
->get_ReadyState( &rs
);
703 if(rs
!= READYSTATE_COMPLETE
)
706 wxString url
= evt
[1].GetString();
708 //As we are complete we also add to the history list, but not if the
709 //page is not the main page, ie it is a subframe
710 if(m_historyEnabled
&& !m_historyLoadingFromList
&& url
== GetCurrentURL())
712 //If we are not at the end of the list, then erase everything
713 //between us and the end before adding the new page
714 if(m_historyPosition
!= static_cast<int>(m_historyList
.size()) - 1)
716 m_historyList
.erase(m_historyList
.begin() + m_historyPosition
+ 1,
717 m_historyList
.end());
719 wxSharedPtr
<wxWebHistoryItem
> item(new wxWebHistoryItem(url
, GetCurrentTitle()));
720 m_historyList
.push_back(item
);
723 //Reset as we are done now
724 m_historyLoadingFromList
= false;
725 // TODO: set target parameter if possible
726 wxString target
= wxEmptyString
;
727 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_LOADED
, GetId(),
729 event
.SetEventObject(this);
730 HandleWindowEvent(event
);
734 case DISPID_STATUSTEXTCHANGE
:
739 case DISPID_TITLECHANGE
:
744 case DISPID_NAVIGATEERROR
:
746 wxWebNavigationError errorType
= wxWEB_NAV_ERR_OTHER
;
747 wxString errorCode
= "?";
748 switch (evt
[3].GetLong())
750 case INET_E_INVALID_URL
: // (0x800C0002L or -2146697214)
751 errorCode
= "INET_E_INVALID_URL";
752 errorType
= wxWEB_NAV_ERR_REQUEST
;
754 case INET_E_NO_SESSION
: // (0x800C0003L or -2146697213)
755 errorCode
= "INET_E_NO_SESSION";
756 errorType
= wxWEB_NAV_ERR_CONNECTION
;
758 case INET_E_CANNOT_CONNECT
: // (0x800C0004L or -2146697212)
759 errorCode
= "INET_E_CANNOT_CONNECT";
760 errorType
= wxWEB_NAV_ERR_CONNECTION
;
762 case INET_E_RESOURCE_NOT_FOUND
: // (0x800C0005L or -2146697211)
763 errorCode
= "INET_E_RESOURCE_NOT_FOUND";
764 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
766 case INET_E_OBJECT_NOT_FOUND
: // (0x800C0006L or -2146697210)
767 errorCode
= "INET_E_OBJECT_NOT_FOUND";
768 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
770 case INET_E_DATA_NOT_AVAILABLE
: // (0x800C0007L or -2146697209)
771 errorCode
= "INET_E_DATA_NOT_AVAILABLE";
772 errorType
= wxWEB_NAV_ERR_NOT_FOUND
;
774 case INET_E_DOWNLOAD_FAILURE
: // (0x800C0008L or -2146697208)
775 errorCode
= "INET_E_DOWNLOAD_FAILURE";
776 errorType
= wxWEB_NAV_ERR_CONNECTION
;
778 case INET_E_AUTHENTICATION_REQUIRED
: // (0x800C0009L or -2146697207)
779 errorCode
= "INET_E_AUTHENTICATION_REQUIRED";
780 errorType
= wxWEB_NAV_ERR_AUTH
;
782 case INET_E_NO_VALID_MEDIA
: // (0x800C000AL or -2146697206)
783 errorCode
= "INET_E_NO_VALID_MEDIA";
784 errorType
= wxWEB_NAV_ERR_REQUEST
;
786 case INET_E_CONNECTION_TIMEOUT
: // (0x800C000BL or -2146697205)
787 errorCode
= "INET_E_CONNECTION_TIMEOUT";
788 errorType
= wxWEB_NAV_ERR_CONNECTION
;
790 case INET_E_INVALID_REQUEST
: // (0x800C000CL or -2146697204)
791 errorCode
= "INET_E_INVALID_REQUEST";
792 errorType
= wxWEB_NAV_ERR_REQUEST
;
794 case INET_E_UNKNOWN_PROTOCOL
: // (0x800C000DL or -2146697203)
795 errorCode
= "INET_E_UNKNOWN_PROTOCOL";
796 errorType
= wxWEB_NAV_ERR_REQUEST
;
798 case INET_E_SECURITY_PROBLEM
: // (0x800C000EL or -2146697202)
799 errorCode
= "INET_E_SECURITY_PROBLEM";
800 errorType
= wxWEB_NAV_ERR_SECURITY
;
802 case INET_E_CANNOT_LOAD_DATA
: // (0x800C000FL or -2146697201)
803 errorCode
= "INET_E_CANNOT_LOAD_DATA";
804 errorType
= wxWEB_NAV_ERR_OTHER
;
806 case INET_E_CANNOT_INSTANTIATE_OBJECT
:
807 // CoCreateInstance will return an error code if this happens,
808 // we'll handle this above.
811 case INET_E_REDIRECT_FAILED
: // (0x800C0014L or -2146697196)
812 errorCode
= "INET_E_REDIRECT_FAILED";
813 errorType
= wxWEB_NAV_ERR_OTHER
;
815 case INET_E_REDIRECT_TO_DIR
: // (0x800C0015L or -2146697195)
816 errorCode
= "INET_E_REDIRECT_TO_DIR";
817 errorType
= wxWEB_NAV_ERR_REQUEST
;
819 case INET_E_CANNOT_LOCK_REQUEST
: // (0x800C0016L or -2146697194)
820 errorCode
= "INET_E_CANNOT_LOCK_REQUEST";
821 errorType
= wxWEB_NAV_ERR_OTHER
;
823 case INET_E_USE_EXTEND_BINDING
: // (0x800C0017L or -2146697193)
824 errorCode
= "INET_E_USE_EXTEND_BINDING";
825 errorType
= wxWEB_NAV_ERR_OTHER
;
827 case INET_E_TERMINATED_BIND
: // (0x800C0018L or -2146697192)
828 errorCode
= "INET_E_TERMINATED_BIND";
829 errorType
= wxWEB_NAV_ERR_OTHER
;
831 case INET_E_INVALID_CERTIFICATE
: // (0x800C0019L or -2146697191)
832 errorCode
= "INET_E_INVALID_CERTIFICATE";
833 errorType
= wxWEB_NAV_ERR_CERTIFICATE
;
835 case INET_E_CODE_DOWNLOAD_DECLINED
: // (0x800C0100L or -2146696960)
836 errorCode
= "INET_E_CODE_DOWNLOAD_DECLINED";
837 errorType
= wxWEB_NAV_ERR_USER_CANCELLED
;
839 case INET_E_RESULT_DISPATCHED
: // (0x800C0200L or -2146696704)
840 // cancel request cancelled...
841 errorCode
= "INET_E_RESULT_DISPATCHED";
842 errorType
= wxWEB_NAV_ERR_OTHER
;
844 case INET_E_CANNOT_REPLACE_SFP_FILE
: // (0x800C0300L or -2146696448)
845 errorCode
= "INET_E_CANNOT_REPLACE_SFP_FILE";
846 errorType
= wxWEB_NAV_ERR_SECURITY
;
848 case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY
:
849 errorCode
= "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
850 errorType
= wxWEB_NAV_ERR_SECURITY
;
852 case INET_E_CODE_INSTALL_SUPPRESSED
:
853 errorCode
= "INET_E_CODE_INSTALL_SUPPRESSED";
854 errorType
= wxWEB_NAV_ERR_SECURITY
;
858 wxString url
= evt
[1].GetString();
859 wxString target
= evt
[2].GetString();
860 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_ERROR
, GetId(),
862 event
.SetEventObject(this);
863 event
.SetInt(errorType
);
864 event
.SetString(errorCode
);
865 HandleWindowEvent(event
);
869 case DISPID_COMMANDSTATECHANGE
:
871 long commandId
= evt
[0].GetLong();
872 bool enable
= evt
[1].GetBool();
873 if (commandId
== CSC_NAVIGATEBACK
)
875 m_canNavigateBack
= enable
;
877 else if (commandId
== CSC_NAVIGATEFORWARD
)
879 m_canNavigateForward
= enable
;
883 case DISPID_NEWWINDOW3
:
885 wxString url
= evt
[4].GetString();
887 wxWebNavigationEvent
event(wxEVT_COMMAND_WEB_VIEW_NEWWINDOW
,
888 GetId(), url
, wxEmptyString
, true);
889 event
.SetEventObject(this);
890 HandleWindowEvent(event
);
892 //If we veto the event then we cancel the new window
893 if (event
.IsVetoed())
895 wxActiveXEventNativeMSW
* nativeParams
= evt
.GetNativeParameters();
896 *V_BOOLREF(&nativeParams
->pDispParams
->rgvarg
[3]) = VARIANT_TRUE
;