]> git.saurik.com Git - wxWidgets.git/blame - src/msw/webview_ie.cpp
Don't pass raw urls to logging functions in the wxWebView sample as they can contain...
[wxWidgets.git] / src / msw / webview_ie.cpp
CommitLineData
61b98a2d 1/////////////////////////////////////////////////////////////////////////////
8290e3cd 2// Name: src/msw/webview_ie.cpp
61b98a2d
SL
3// Purpose: wxMSW wxWebViewIE class implementation for web view component
4// Author: Marianne Gagnon
5// Id: $Id$
6// Copyright: (c) 2010 Marianne Gagnon
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
384b8d9f
SL
10// For compilers that support precompilation, includes "wx.h".
11#include "wx/wxprec.h"
12
13#if defined(__BORLANDC__)
14 #pragma hdrstop
15#endif
16
8290e3cd 17#include "wx/msw/webview_ie.h"
61b98a2d
SL
18
19#if wxHAVE_WEB_BACKEND_IE
20
21#include <olectl.h>
22#include <oleidl.h>
23#include <exdispid.h>
24#include <exdisp.h>
25#include <mshtml.h>
26
97ad1425 27#ifdef __MINGW32__
61b98a2d
SL
28// FIXME: Seems like MINGW does not have these, how to handle cleanly?
29#define DISPID_COMMANDSTATECHANGE 105
30typedef enum CommandStateChangeConstants {
31 CSC_UPDATECOMMANDS = (int) 0xFFFFFFFF,
32 CSC_NAVIGATEFORWARD = 0x1,
33 CSC_NAVIGATEBACK = 0x2
34} CommandStateChangeConstants;
35
36
37// FIXME: Seems like MINGW does not have these, how to handle cleanly?
38#define DISPID_NAVIGATECOMPLETE2 252
39#define DISPID_NAVIGATEERROR 271
40#define OLECMDID_OPTICAL_ZOOM 63
41#define INET_E_ERROR_FIRST 0x800C0002L
42#define INET_E_INVALID_URL 0x800C0002L
43#define INET_E_NO_SESSION 0x800C0003L
44#define INET_E_CANNOT_CONNECT 0x800C0004L
45#define INET_E_RESOURCE_NOT_FOUND 0x800C0005L
46#define INET_E_OBJECT_NOT_FOUND 0x800C0006L
47#define INET_E_DATA_NOT_AVAILABLE 0x800C0007L
48#define INET_E_DOWNLOAD_FAILURE 0x800C0008L
49#define INET_E_AUTHENTICATION_REQUIRED 0x800C0009L
50#define INET_E_NO_VALID_MEDIA 0x800C000AL
51#define INET_E_CONNECTION_TIMEOUT 0x800C000BL
52#define INET_E_INVALID_REQUEST 0x800C000CL
53#define INET_E_UNKNOWN_PROTOCOL 0x800C000DL
54#define INET_E_SECURITY_PROBLEM 0x800C000EL
55#define INET_E_CANNOT_LOAD_DATA 0x800C000FL
56#define INET_E_CANNOT_INSTANTIATE_OBJECT 0x800C0010L
57#define INET_E_QUERYOPTION_UNKNOWN 0x800C0013L
58#define INET_E_REDIRECT_FAILED 0x800C0014L
59#define INET_E_REDIRECT_TO_DIR 0x800C0015L
60#define INET_E_CANNOT_LOCK_REQUEST 0x800C0016L
61#define INET_E_USE_EXTEND_BINDING 0x800C0017L
62#define INET_E_TERMINATED_BIND 0x800C0018L
63#define INET_E_INVALID_CERTIFICATE 0x800C0019L
64#define INET_E_CODE_DOWNLOAD_DECLINED 0x800C0100L
65#define INET_E_RESULT_DISPATCHED 0x800C0200L
66#define INET_E_CANNOT_REPLACE_SFP_FILE 0x800C0300L
67#define INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY 0x800C0500L
68#define INET_E_CODE_INSTALL_SUPPRESSED 0x800C0400L
69
70#define REFRESH_COMPLETELY 3
97ad1425 71#endif
61b98a2d
SL
72
73BEGIN_EVENT_TABLE(wxWebViewIE, wxControl)
97ad1425
SL
74 EVT_ACTIVEX(wxID_ANY, wxWebViewIE::onActiveXEvent)
75 EVT_ERASE_BACKGROUND(wxWebViewIE::onEraseBg)
61b98a2d
SL
76END_EVENT_TABLE()
77
78bool wxWebViewIE::Create(wxWindow* parent,
79 wxWindowID id,
80 const wxString& url,
81 const wxPoint& pos,
82 const wxSize& size,
83 long style,
84 const wxString& name)
85{
86 if (!wxControl::Create(parent, id, pos, size, style,
87 wxDefaultValidator, name))
88 {
89 return false;
90 }
91
92 m_webBrowser = NULL;
93 m_canNavigateBack = false;
94 m_canNavigateForward = false;
95 m_isBusy = false;
96
97 if (::CoCreateInstance(CLSID_WebBrowser, NULL,
98 CLSCTX_INPROC_SERVER, // CLSCTX_INPROC,
99 IID_IWebBrowser2 , (void**)&m_webBrowser) != 0)
100 {
101 wxLogError("Failed to initialize IE, CoCreateInstance returned an error");
102 return false;
103 }
104
105 m_ie.SetDispatchPtr(m_webBrowser); // wxAutomationObject will release itself
106
107 m_webBrowser->put_RegisterAsBrowser(VARIANT_TRUE);
108 m_webBrowser->put_RegisterAsDropTarget(VARIANT_TRUE);
109 //m_webBrowser->put_Silent(VARIANT_FALSE);
110
111 m_container = new wxActiveXContainer(this, IID_IWebBrowser2, m_webBrowser);
112
113 SetBackgroundStyle(wxBG_STYLE_PAINT);
114 SetDoubleBuffered(true);
115 return true;
116}
117
118
119void wxWebViewIE::LoadUrl(const wxString& url)
120{
121 wxVariant out = m_ie.CallMethod("Navigate", (BSTR) url.wc_str(),
122 NULL, NULL, NULL, NULL);
123
124 // FIXME: why is out value null??
125 //(HRESULT)(out.GetLong()) == S_OK;
126}
127
128void wxWebViewIE::SetPage(const wxString& html, const wxString& baseUrl)
129{
130 LoadUrl("about:blank");
131
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
135 wxYield();
136
137 wxVariant documentVariant = m_ie.GetProperty("Document");
138 void* documentPtr = documentVariant.GetVoidPtr();
139
140 wxASSERT (documentPtr != NULL);
141
142 // TODO: consider the "baseUrl" parameter if possible
143 // TODO: consider encoding
144 BSTR bstr = SysAllocString(html.wc_str());
145
146 // Creates a new one-dimensional array
147 SAFEARRAY *psaStrings = SafeArrayCreateVector(VT_VARIANT, 0, 1);
148 if (psaStrings != NULL)
149 {
150 VARIANT *param;
151 HRESULT hr = SafeArrayAccessData(psaStrings, (LPVOID*)&param);
152 param->vt = VT_BSTR;
153 param->bstrVal = bstr;
154
155 hr = SafeArrayUnaccessData(psaStrings);
156
157 IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
158 document->write(psaStrings);
159
160 // SafeArrayDestroy calls SysFreeString for each BSTR
161 SafeArrayDestroy(psaStrings);
162 }
163 else
164 {
165 wxLogError("wxWebViewIE::SetPage() : psaStrings is NULL");
166 }
167
168}
169
170wxString wxWebViewIE::GetPageSource()
171{
172 wxVariant documentVariant = m_ie.GetProperty("Document");
173 void* documentPtr = documentVariant.GetVoidPtr();
174
175 if (documentPtr == NULL)
176 {
177 return wxEmptyString;
178 }
179
180 IHTMLDocument2* document = (IHTMLDocument2*)documentPtr;
181
182 IHTMLElement *bodyTag = NULL;
183 IHTMLElement *htmlTag = NULL;
184 document->get_body(&bodyTag);
185 wxASSERT(bodyTag != NULL);
186
187 document->Release();
188 bodyTag->get_parentElement(&htmlTag);
189 wxASSERT(htmlTag != NULL);
190
191 BSTR bstr;
192 htmlTag->get_outerHTML(&bstr);
193
194 bodyTag->Release();
195 htmlTag->Release();
196
197 //wxMessageBox(wxString(bstr));
198
199 // TODO: check encoding
200 return wxString(bstr);
201}
202
203// FIXME? retrieve OLECMDID_GETZOOMRANGE instead of hardcoding range 0-4
204wxWebViewZoom wxWebViewIE::GetZoom()
205{
206 const int zoom = GetIETextZoom();
207
208 switch (zoom)
209 {
210 case 0:
211 return wxWEB_VIEW_ZOOM_TINY;
212 break;
213 case 1:
214 return wxWEB_VIEW_ZOOM_SMALL;
215 break;
216 case 2:
217 return wxWEB_VIEW_ZOOM_MEDIUM;
218 break;
219 case 3:
220 return wxWEB_VIEW_ZOOM_LARGE;
221 break;
222 case 4:
223 return wxWEB_VIEW_ZOOM_LARGEST;
224 break;
225 default:
226 wxASSERT(false);
227 return wxWEB_VIEW_ZOOM_MEDIUM;
228 }
229}
230void wxWebViewIE::SetZoom(wxWebViewZoom zoom)
231{
232 // I know I could cast from enum to int since wxWebViewZoom happens to
233 // match with IE's zoom levels, but I don't like doing that, what if enum
234 // values change...
235 switch (zoom)
236 {
237 case wxWEB_VIEW_ZOOM_TINY:
238 SetIETextZoom(0);
239 break;
240 case wxWEB_VIEW_ZOOM_SMALL:
241 SetIETextZoom(1);
242 break;
243 case wxWEB_VIEW_ZOOM_MEDIUM:
244 SetIETextZoom(2);
245 break;
246 case wxWEB_VIEW_ZOOM_LARGE:
247 SetIETextZoom(3);
248 break;
249 case wxWEB_VIEW_ZOOM_LARGEST:
250 SetIETextZoom(4);
251 break;
252 default:
253 wxASSERT(false);
254 }
255}
256
257void wxWebViewIE::SetIETextZoom(int level)
258{
259 VARIANT zoomVariant;
260 VariantInit (&zoomVariant);
261 V_VT(&zoomVariant) = VT_I4;
262 V_I4(&zoomVariant) = level;
263
264 HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
265 OLECMDEXECOPT_DONTPROMPTUSER,
266 &zoomVariant, NULL);
267 wxASSERT (result == S_OK);
268
269 VariantClear (&zoomVariant);
270}
271
272int wxWebViewIE::GetIETextZoom()
273{
274 VARIANT zoomVariant;
275 VariantInit (&zoomVariant);
276 V_VT(&zoomVariant) = VT_I4;
277 V_I4(&zoomVariant) = 4;
278
279 HRESULT result = m_webBrowser->ExecWB(OLECMDID_ZOOM,
280 OLECMDEXECOPT_DONTPROMPTUSER,
281 NULL, &zoomVariant);
282 wxASSERT (result == S_OK);
283
284 int zoom = V_I4(&zoomVariant);
285 // wxMessageBox(wxString::Format("Zoom : %i", zoom));
286 VariantClear (&zoomVariant);
287
288 return zoom;
289}
290
291void wxWebViewIE::SetIEOpticalZoom(float zoom)
292{
293 // TODO: add support for optical zoom (IE7+ only)
294
295 // TODO: get range from OLECMDID_OPTICAL_GETZOOMRANGE instead of hardcoding?
296 wxASSERT(zoom >= 10.0f);
297 wxASSERT(zoom <= 1000.0f);
298
299 VARIANT zoomVariant;
300 VariantInit (&zoomVariant);
301 V_VT(&zoomVariant) = VT_I4;
302 V_I4(&zoomVariant) = (zoom * 100.0f);
303
304 HRESULT result = m_webBrowser->ExecWB((OLECMDID)OLECMDID_OPTICAL_ZOOM,
305 OLECMDEXECOPT_DODEFAULT,
306 &zoomVariant,
307 NULL);
308 wxASSERT (result == S_OK);
309}
310
311float wxWebViewIE::GetIEOpticalZoom()
312{
313 // TODO: add support for optical zoom (IE7+ only)
314
315 VARIANT zoomVariant;
316 VariantInit (&zoomVariant);
317 V_VT(&zoomVariant) = VT_I4;
318 V_I4(&zoomVariant) = -1;
319
320 HRESULT result = m_webBrowser->ExecWB((OLECMDID)OLECMDID_OPTICAL_ZOOM,
321 OLECMDEXECOPT_DODEFAULT, NULL,
322 &zoomVariant);
323 wxASSERT (result == S_OK);
324
325 const int zoom = V_I4(&zoomVariant);
326 VariantClear (&zoomVariant);
327
328 return zoom / 100.0f;
329}
330
331void wxWebViewIE::SetZoomType(wxWebViewZoomType)
332{
333 // TODO: add support for optical zoom (IE7+ only)
334 wxASSERT(false);
335}
336
337wxWebViewZoomType wxWebViewIE::GetZoomType() const
338{
339 // TODO: add support for optical zoom (IE7+ only)
340 return wxWEB_VIEW_ZOOM_TYPE_TEXT;
341}
342
343bool wxWebViewIE::CanSetZoomType(wxWebViewZoomType) const
344{
345 // both are supported
346 // TODO: IE6 only supports text zoom, check if it's IE6 first
347 return true;
348}
349
350void wxWebViewIE::Print()
351{
352 m_webBrowser->ExecWB(OLECMDID_PRINTPREVIEW,
353 OLECMDEXECOPT_DODEFAULT, NULL, NULL);
354}
355
356void wxWebViewIE::GoBack()
357{
358 wxVariant out = m_ie.CallMethod("GoBack");
359
360 // FIXME: why is out value null??
361 //return (HRESULT)(out.GetLong()) == S_OK;
362}
363
364void wxWebViewIE::GoForward()
365{
366 wxVariant out = m_ie.CallMethod("GoForward");
367
368 // FIXME: why is out value null??
369 //return (HRESULT)(out.GetLong()) == S_OK;
370}
371
372void wxWebViewIE::Stop()
373{
374 wxVariant out = m_ie.CallMethod("Stop");
375
376 // FIXME: why is out value null??
377 //return (HRESULT)(out.GetLong()) == S_OK;
378}
379
380
381void wxWebViewIE::Reload(wxWebViewReloadFlags flags)
382{
7aa18fc7
SL
383 VARIANTARG level;
384 VariantInit(&level);
385 V_VT(&level) = VT_I2;
61b98a2d 386
7aa18fc7 387 switch(flags)
61b98a2d 388 {
7aa18fc7
SL
389 case wxWEB_VIEW_RELOAD_DEFAULT:
390 V_I2(&level) = REFRESH_NORMAL;
391 break;
392 case wxWEB_VIEW_RELOAD_NO_CACHE:
393 V_I2(&level) = REFRESH_COMPLETELY;
394 break;
395 default:
396 wxFAIL_MSG("Unexpected reload type");
61b98a2d
SL
397 }
398
7aa18fc7 399 m_webBrowser->Refresh2(&level);
61b98a2d
SL
400}
401
402bool wxWebViewIE::IsOfflineMode()
403{
404 wxVariant out = m_ie.GetProperty("Offline");
405
406 wxASSERT(out.GetType() == "bool");
407
408 return out.GetBool();
409}
410
411void wxWebViewIE::SetOfflineMode(bool offline)
412{
413 // FIXME: the wxWidgets docs do not really document what the return
414 // parameter of PutProperty is
415 const bool success = m_ie.PutProperty("Offline", (offline ?
416 VARIANT_TRUE :
417 VARIANT_FALSE));
418 wxASSERT(success);
419}
420
421bool wxWebViewIE::IsBusy()
422{
423 if (m_isBusy) return true;
424
425 wxVariant out = m_ie.GetProperty("Busy");
426
427 wxASSERT(out.GetType() == "bool");
428
429 return out.GetBool();
430}
431
432wxString wxWebViewIE::GetCurrentURL()
433{
434 wxVariant out = m_ie.GetProperty("LocationURL");
435
436 wxASSERT(out.GetType() == "string");
437 return out.GetString();
438}
439
440wxString wxWebViewIE::GetCurrentTitle()
441{
442 wxVariant out = m_ie.GetProperty("LocationName");
443
444 wxASSERT(out.GetType() == "string");
445 return out.GetString();
446}
447
448void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
449{
450 if (m_webBrowser == NULL) return;
451
452 switch (evt.GetDispatchId())
453 {
454 case DISPID_BEFORENAVIGATE2:
455 {
456 m_isBusy = true;
457
458 wxString url = evt[1].GetString();
459 wxString target = evt[3].GetString();
460
461 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATING,
462 GetId(), url, target, true);
463 event.SetEventObject(this);
464 HandleWindowEvent(event);
465
466 if (event.IsVetoed())
467 {
468 wxActiveXEventNativeMSW* nativeParams =
469 evt.GetNativeParameters();
470 *V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
471 }
472
473 // at this point, either the navigation event has been cancelled
474 // and we're not busy, either it was accepted and IWebBrowser2's
475 // Busy property will be true; so we don't need our override
476 // flag anymore.
477 m_isBusy = false;
478
479 break;
480 }
481
482 case DISPID_NAVIGATECOMPLETE2:
483 {
484 wxString url = evt[1].GetString();
485 // TODO: set target parameter if possible
486 wxString target = wxEmptyString;
487 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_NAVIGATED,
488 GetId(), url, target, false);
489 event.SetEventObject(this);
490 HandleWindowEvent(event);
491 break;
492 }
493
494 case DISPID_PROGRESSCHANGE:
495 {
496 // download progress
497 break;
498 }
499
500 case DISPID_DOCUMENTCOMPLETE:
501 {
502 wxString url = evt[1].GetString();
503 // TODO: set target parameter if possible
504 wxString target = wxEmptyString;
505 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_LOADED, GetId(),
506 url, target, false);
507 event.SetEventObject(this);
508 HandleWindowEvent(event);
509 break;
510 }
511
512 case DISPID_STATUSTEXTCHANGE:
513 {
514 break;
515 }
516
517 case DISPID_TITLECHANGE:
518 {
519 break;
520 }
521
522 case DISPID_NAVIGATEERROR:
523 {
524 wxWebNavigationError errorType = wxWEB_NAV_ERR_OTHER;
525 wxString errorCode = "?";
526 switch (evt[3].GetLong())
527 {
528 case INET_E_INVALID_URL: // (0x800C0002L or -2146697214)
529 errorCode = "INET_E_INVALID_URL";
530 errorType = wxWEB_NAV_ERR_REQUEST;
531 break;
532 case INET_E_NO_SESSION: // (0x800C0003L or -2146697213)
533 errorCode = "INET_E_NO_SESSION";
534 errorType = wxWEB_NAV_ERR_CONNECTION;
535 break;
536 case INET_E_CANNOT_CONNECT: // (0x800C0004L or -2146697212)
537 errorCode = "INET_E_CANNOT_CONNECT";
538 errorType = wxWEB_NAV_ERR_CONNECTION;
539 break;
540 case INET_E_RESOURCE_NOT_FOUND: // (0x800C0005L or -2146697211)
541 errorCode = "INET_E_RESOURCE_NOT_FOUND";
542 errorType = wxWEB_NAV_ERR_NOT_FOUND;
543 break;
544 case INET_E_OBJECT_NOT_FOUND: // (0x800C0006L or -2146697210)
545 errorCode = "INET_E_OBJECT_NOT_FOUND";
546 errorType = wxWEB_NAV_ERR_NOT_FOUND;
547 break;
548 case INET_E_DATA_NOT_AVAILABLE: // (0x800C0007L or -2146697209)
549 errorCode = "INET_E_DATA_NOT_AVAILABLE";
550 errorType = wxWEB_NAV_ERR_NOT_FOUND;
551 break;
552 case INET_E_DOWNLOAD_FAILURE: // (0x800C0008L or -2146697208)
553 errorCode = "INET_E_DOWNLOAD_FAILURE";
554 errorType = wxWEB_NAV_ERR_CONNECTION;
555 break;
556 case INET_E_AUTHENTICATION_REQUIRED: // (0x800C0009L or -2146697207)
557 errorCode = "INET_E_AUTHENTICATION_REQUIRED";
558 errorType = wxWEB_NAV_ERR_AUTH;
559 break;
560 case INET_E_NO_VALID_MEDIA: // (0x800C000AL or -2146697206)
561 errorCode = "INET_E_NO_VALID_MEDIA";
562 errorType = wxWEB_NAV_ERR_REQUEST;
563 break;
564 case INET_E_CONNECTION_TIMEOUT: // (0x800C000BL or -2146697205)
565 errorCode = "INET_E_CONNECTION_TIMEOUT";
566 errorType = wxWEB_NAV_ERR_CONNECTION;
567 break;
568 case INET_E_INVALID_REQUEST: // (0x800C000CL or -2146697204)
569 errorCode = "INET_E_INVALID_REQUEST";
570 errorType = wxWEB_NAV_ERR_REQUEST;
571 break;
572 case INET_E_UNKNOWN_PROTOCOL: // (0x800C000DL or -2146697203)
573 errorCode = "INET_E_UNKNOWN_PROTOCOL";
574 errorType = wxWEB_NAV_ERR_REQUEST;
575 break;
576 case INET_E_SECURITY_PROBLEM: // (0x800C000EL or -2146697202)
577 errorCode = "INET_E_SECURITY_PROBLEM";
578 errorType = wxWEB_NAV_ERR_SECURITY;
579 break;
580 case INET_E_CANNOT_LOAD_DATA: // (0x800C000FL or -2146697201)
581 errorCode = "INET_E_CANNOT_LOAD_DATA";
582 errorType = wxWEB_NAV_ERR_OTHER;
583 break;
584 case INET_E_CANNOT_INSTANTIATE_OBJECT:
585 // CoCreateInstance will return an error code if this happens,
586 // we'll handle this above.
587 return;
588 break;
589 case INET_E_REDIRECT_FAILED: // (0x800C0014L or -2146697196)
590 errorCode = "INET_E_REDIRECT_FAILED";
591 errorType = wxWEB_NAV_ERR_OTHER;
592 break;
593 case INET_E_REDIRECT_TO_DIR: // (0x800C0015L or -2146697195)
594 errorCode = "INET_E_REDIRECT_TO_DIR";
595 errorType = wxWEB_NAV_ERR_REQUEST;
596 break;
597 case INET_E_CANNOT_LOCK_REQUEST: // (0x800C0016L or -2146697194)
598 errorCode = "INET_E_CANNOT_LOCK_REQUEST";
599 errorType = wxWEB_NAV_ERR_OTHER;
600 break;
601 case INET_E_USE_EXTEND_BINDING: // (0x800C0017L or -2146697193)
602 errorCode = "INET_E_USE_EXTEND_BINDING";
603 errorType = wxWEB_NAV_ERR_OTHER;
604 break;
605 case INET_E_TERMINATED_BIND: // (0x800C0018L or -2146697192)
606 errorCode = "INET_E_TERMINATED_BIND";
607 errorType = wxWEB_NAV_ERR_OTHER;
608 break;
609 case INET_E_INVALID_CERTIFICATE: // (0x800C0019L or -2146697191)
610 errorCode = "INET_E_INVALID_CERTIFICATE";
611 errorType = wxWEB_NAV_ERR_CERTIFICATE;
612 break;
613 case INET_E_CODE_DOWNLOAD_DECLINED: // (0x800C0100L or -2146696960)
614 errorCode = "INET_E_CODE_DOWNLOAD_DECLINED";
615 errorType = wxWEB_NAV_ERR_USER_CANCELLED;
616 break;
617 case INET_E_RESULT_DISPATCHED: // (0x800C0200L or -2146696704)
618 // cancel request cancelled...
619 errorCode = "INET_E_RESULT_DISPATCHED";
620 errorType = wxWEB_NAV_ERR_OTHER;
621 break;
622 case INET_E_CANNOT_REPLACE_SFP_FILE: // (0x800C0300L or -2146696448)
623 errorCode = "INET_E_CANNOT_REPLACE_SFP_FILE";
624 errorType = wxWEB_NAV_ERR_SECURITY;
625 break;
626 case INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY:
627 errorCode = "INET_E_CODE_INSTALL_BLOCKED_BY_HASH_POLICY";
628 errorType = wxWEB_NAV_ERR_SECURITY;
629 break;
630 case INET_E_CODE_INSTALL_SUPPRESSED:
631 errorCode = "INET_E_CODE_INSTALL_SUPPRESSED";
632 errorType = wxWEB_NAV_ERR_SECURITY;
633 break;
634 }
635
636 wxString url = evt[1].GetString();
637 wxString target = evt[2].GetString();
638 wxWebNavigationEvent event(wxEVT_COMMAND_WEB_VIEW_ERROR, GetId(),
639 url, target, false);
640 event.SetEventObject(this);
641 event.SetInt(errorType);
642 event.SetString(errorCode);
643 HandleWindowEvent(event);
644 break;
645 }
646
647 case DISPID_COMMANDSTATECHANGE:
648 {
649 long commandId = evt[0].GetLong();
650 bool enable = evt[1].GetBool();
651 if (commandId == CSC_NAVIGATEBACK)
652 {
653 m_canNavigateBack = enable;
654 }
655 else if (commandId == CSC_NAVIGATEFORWARD)
656 {
657 m_canNavigateForward = enable;
658 }
be19c556 659 break;
61b98a2d 660 }
61b98a2d 661 case DISPID_NEWWINDOW2:
61b98a2d 662 {
61b98a2d
SL
663 wxActiveXEventNativeMSW* nativeParams = evt.GetNativeParameters();
664 // Cancel the attempt to open a new window
665 *V_BOOLREF(&nativeParams->pDispParams->rgvarg[0]) = VARIANT_TRUE;
be19c556
SL
666 break;
667 }
61b98a2d
SL
668 }
669
670 evt.Skip();
671}
672
673#endif