-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathwebview_chromium3.cpp
673 lines (567 loc) · 21.1 KB
/
webview_chromium3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
/////////////////////////////////////////////////////////////////////////////
// Author: Steven Lamerton
// Copyright: (c) 2013 Steven Lamerton
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "webview_chromium.h"
#if CEF_API == 3
#include "webview_chromium.h"
#include <wx/webview.h>
#include <wx/filesys.h>
#include <wx/msw/private.h>
#ifdef __VISUALC__
#pragma warning(push)
#pragma warning(disable:4100)
#endif
#include <include/cef_app.h>
#include <include/cef_browser.h>
#include <include/cef_string_visitor.h>
#ifdef __VISUALC__
#pragma warning(pop)
#endif
extern const char wxWebViewBackendChromium[] = "wxWebViewChromium";
wxIMPLEMENT_DYNAMIC_CLASS(wxWebViewChromium, wxWebView);
class wxStringVisitor : public CefStringVisitor
{
public:
enum StringType {
PAGE_SOURCE,
PAGE_TEXT,
};
wxStringVisitor(wxWebViewChromium* webview, StringType type) : m_webview(webview), m_type(type) {}
void Visit(const CefString& string)
{
switch(m_type)
{
case PAGE_SOURCE:
m_webview->SetPageSource(string.ToWString());
break;
case PAGE_TEXT:
m_webview->SetPageText(string.ToWString());
break;
}
}
private:
StringType m_type;
wxWebViewChromium *m_webview;
IMPLEMENT_REFCOUNTING(wxStringVisitor);
};
bool wxWebViewChromium::Create(wxWindow* parent,
wxWindowID id,
const wxString& url,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if (!wxControl::Create(parent, id, pos, size, style,
wxDefaultValidator, name))
{
return false;
}
m_historyLoadingFromList = false;
m_historyEnabled = true;
m_historyPosition = -1;
m_zoomLevel = wxWEBVIEW_ZOOM_MEDIUM;
CefBrowserSettings browsersettings;
CefWindowInfo info;
m_clientHandler = new ClientHandler();
m_clientHandler->SetWebView(this);
#ifdef __WXMSW__
// Initialize window info to the defaults for a child window
info.SetAsChild(GetHWND(), wxGetClientRect(this->GetHWND()));
#endif
// Creat the new child browser window, we do this async as we use a multi
// threaded message loop
#if CHROME_VERSION_BUILD >= 1650
CefBrowserHost::CreateBrowser(info, static_cast<CefRefPtr<CefClient>>(m_clientHandler),
url.ToStdString(), browsersettings, NULL);
#else
CefBrowserHost::CreateBrowser(info, static_cast<CefRefPtr<CefClient>>(m_clientHandler),
url.ToStdString(), browsersettings);
#endif
this->Bind(wxEVT_SIZE, &wxWebViewChromium::OnSize, this);
return true;
}
wxWebViewChromium::~wxWebViewChromium()
{
CefRefPtr<CefBrowser> browser = m_clientHandler->GetBrowser();
if(browser.get()) {
// Let the browser window know we are about to destroy it.
browser->GetHost()->ParentWindowWillClose();
}
}
void wxWebViewChromium::OnSize(wxSizeEvent& event)
{
wxSize size = GetClientSize();
#ifdef __WXMSW__
if(m_clientHandler && m_clientHandler->GetBrowser() && m_clientHandler->GetBrowser()->GetHost())
{
HWND handle = m_clientHandler->GetBrowser()->GetHost()->GetWindowHandle();
if(handle)
{
HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, handle, NULL, 0, 0,
size.GetWidth(), size.GetHeight(), SWP_NOZORDER);
EndDeferWindowPos(hdwp);
}
}
#endif
event.Skip();
}
void wxWebViewChromium::SetPageSource(const wxString& pageSource)
{
m_pageSource = pageSource;
}
void wxWebViewChromium::SetPageText(const wxString& pageText)
{
m_pageText = pageText;
}
void* wxWebViewChromium::GetNativeBackend() const
{
return m_clientHandler->GetBrowser();
}
bool wxWebViewChromium::CanGoForward() const
{
if(m_historyEnabled)
return m_historyPosition != static_cast<int>(m_historyList.size()) - 1;
else
return false;
}
bool wxWebViewChromium::CanGoBack() const
{
if(m_historyEnabled)
return m_historyPosition > 0;
else
return false;
}
void wxWebViewChromium::LoadHistoryItem(wxSharedPtr<wxWebViewHistoryItem> item)
{
int pos = -1;
for(unsigned int i = 0; i < m_historyList.size(); i++)
{
//We compare the actual pointers to find the correct item
if(m_historyList[i].get() == item.get())
pos = i;
}
wxASSERT_MSG(pos != static_cast<int>(m_historyList.size()),
"invalid history item");
m_historyLoadingFromList = true;
LoadURL(item->GetUrl());
m_historyPosition = pos;
}
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewChromium::GetBackwardHistory()
{
wxVector<wxSharedPtr<wxWebViewHistoryItem> > backhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand
for(int i = 0; i < m_historyPosition; i++)
{
backhist.push_back(m_historyList[i]);
}
return backhist;
}
wxVector<wxSharedPtr<wxWebViewHistoryItem> > wxWebViewChromium::GetForwardHistory()
{
wxVector<wxSharedPtr<wxWebViewHistoryItem> > forwardhist;
//As we don't have std::copy or an iterator constructor in the wxwidgets
//native vector we construct it by hand
for(int i = m_historyPosition + 1; i < static_cast<int>(m_historyList.size()); i++)
{
forwardhist.push_back(m_historyList[i]);
}
return forwardhist;
}
void wxWebViewChromium::GoBack()
{
LoadHistoryItem(m_historyList[m_historyPosition - 1]);
}
void wxWebViewChromium::GoForward()
{
LoadHistoryItem(m_historyList[m_historyPosition + 1]);
}
void wxWebViewChromium::LoadURL(const wxString& url)
{
m_clientHandler->GetBrowser()->GetMainFrame()->LoadURL(url.ToStdString());
}
void wxWebViewChromium::ClearHistory()
{
m_historyList.clear();
m_historyPosition = -1;
}
void wxWebViewChromium::EnableHistory(bool enable)
{
m_historyEnabled = enable;
}
void wxWebViewChromium::Stop()
{
m_clientHandler->GetBrowser()->StopLoad();
}
void wxWebViewChromium::Reload(wxWebViewReloadFlags flags)
{
if(flags == wxWEBVIEW_RELOAD_NO_CACHE)
{
m_clientHandler->GetBrowser()->ReloadIgnoreCache();
}
else
{
m_clientHandler->GetBrowser()->Reload();
}
}
wxString wxWebViewChromium::GetPageSource() const
{
return m_pageSource;
}
wxString wxWebViewChromium::GetPageText() const
{
return m_pageText;
}
wxString wxWebViewChromium::GetCurrentURL() const
{
return m_clientHandler->GetBrowser()->GetMainFrame()->GetURL().ToString();
}
wxString wxWebViewChromium::GetCurrentTitle() const
{
return m_title;
}
void wxWebViewChromium::Print()
{
//m_browser->GetMainFrame()->Print();
}
void wxWebViewChromium::Cut()
{
m_clientHandler->GetBrowser()->GetMainFrame()->Cut();
}
void wxWebViewChromium::Copy()
{
m_clientHandler->GetBrowser()->GetMainFrame()->Copy();
}
void wxWebViewChromium::Paste()
{
m_clientHandler->GetBrowser()->GetMainFrame()->Paste();
}
void wxWebViewChromium::Undo()
{
m_clientHandler->GetBrowser()->GetMainFrame()->Undo();
}
void wxWebViewChromium::Redo()
{
m_clientHandler->GetBrowser()->GetMainFrame()->Redo();
}
void wxWebViewChromium::SelectAll()
{
m_clientHandler->GetBrowser()->GetMainFrame()->SelectAll();
}
void wxWebViewChromium::DeleteSelection()
{
wxString jsdelete = "if (window.getSelection) { if (window.getSelection().deleteFromDocument) { window.getSelection().deleteFromDocument(); } }";
RunScript(jsdelete);
}
void wxWebViewChromium::ClearSelection()
{
wxString jsclear = "if (window.getSelection) { if (window.getSelection().empty) { window.getSelection().empty(); } }";
RunScript(jsclear);
}
void wxWebViewChromium::RunScript(const wxString& javascript)
{
m_clientHandler->GetBrowser()->GetMainFrame()->ExecuteJavaScript(javascript.ToStdString(),
"", 0);
}
bool wxWebViewChromium::IsBusy() const
{
if(m_clientHandler->GetBrowser())
return m_clientHandler->GetBrowser()->IsLoading();
else
return false;
}
void wxWebViewChromium::SetEditable(bool enable)
{
wxString mode = enable ? "\"on\"" : "\"off\"";
RunScript("document.designMode = " + mode);
}
void wxWebViewChromium::DoSetPage(const wxString& html, const wxString& baseUrl)
{
m_clientHandler->GetBrowser()->GetMainFrame()->LoadString(html.ToStdString(),
baseUrl.ToStdString());
}
wxWebViewZoom wxWebViewChromium::GetZoom() const
{
return m_zoomLevel;
}
void wxWebViewChromium::SetZoom(wxWebViewZoom zoom)
{
m_zoomLevel = zoom;
double mapzoom;
// arbitrary way to map our common zoom enum to float zoom
switch (zoom)
{
case wxWEBVIEW_ZOOM_TINY:
mapzoom = -1.0;
break;
case wxWEBVIEW_ZOOM_SMALL:
mapzoom = -0.5;
break;
case wxWEBVIEW_ZOOM_MEDIUM:
mapzoom = 0.0;
break;
case wxWEBVIEW_ZOOM_LARGE:
mapzoom = 0.5;
break;
case wxWEBVIEW_ZOOM_LARGEST:
mapzoom = 1.0;
break;
default:
wxASSERT(false);
}
m_clientHandler->GetBrowser()->GetHost()->SetZoomLevel(mapzoom);
}
void wxWebViewChromium::SetZoomType(wxWebViewZoomType type)
{
// there is only one supported zoom type at the moment so this setter
// does nothing beyond checking sanity
wxASSERT(type == wxWEBVIEW_ZOOM_TYPE_LAYOUT);
}
wxWebViewZoomType wxWebViewChromium::GetZoomType() const
{
return wxWEBVIEW_ZOOM_TYPE_LAYOUT;
}
bool wxWebViewChromium::CanSetZoomType(wxWebViewZoomType type) const
{
return type == wxWEBVIEW_ZOOM_TYPE_LAYOUT;
}
void wxWebViewChromium::RegisterHandler(wxSharedPtr<wxWebViewHandler> handler)
{
// We currently don't support custom scheme handlers
}
bool wxWebViewChromium::StartUp(int &code, const wxString &path)
{
CefMainArgs args(wxGetInstance());
// If there is no subprocess then we need to execute on this process
if(path == "")
{
code = CefExecuteProcess(args, NULL);
if(code >= 0)
return false;
}
CefSettings settings;
// We use a multithreaded message loop so we don't have to integrate
// with the wx message loop
settings.multi_threaded_message_loop = true;
CefString(&settings.browser_subprocess_path) = path.ToStdString();
return CefInitialize(args, settings, NULL);
}
int wxWebViewChromium::StartUpSubprocess()
{
CefMainArgs args(wxGetInstance());
return CefExecuteProcess(args, NULL);
}
void wxWebViewChromium::Shutdown()
{
CefShutdown();
}
// CefDisplayHandler methods
void ClientHandler::OnLoadingStateChange(CefRefPtr<CefBrowser> browser, bool isLoading,
bool canGoBack, bool canGoForward)
{}
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame,
const CefString& url)
{}
void ClientHandler::OnTitleChange(CefRefPtr<CefBrowser> browser, const CefString& title)
{
m_webview->m_title = title.ToWString();
wxString target = browser->GetMainFrame()->GetName().ToString();
wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_TITLE_CHANGED, m_webview->GetId(), "", target);
event.SetString(title.ToWString());
event.SetEventObject(m_webview);
m_webview->HandleWindowEvent(event);
}
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser, const CefString& message,
const CefString& source, int line)
{
return false;
}
// CefContextMenuHandler methods
void ClientHandler::OnBeforeContextMenu(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
CefRefPtr<CefMenuModel> model)
{
if(!m_webview->IsContextMenuEnabled())
model->Clear();
}
bool ClientHandler::OnContextMenuCommand(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefContextMenuParams> params,
int command_id,
CefContextMenuHandler::EventFlags event_flags)
{
return false;
}
void ClientHandler::OnContextMenuDismissed(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame)
{}
// CefLifeSpanHandler methods
bool ClientHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& target_url,
const CefString& target_frame_name,
const CefPopupFeatures& popupFeatures,
CefWindowInfo& windowInfo,
CefRefPtr<CefClient>& client,
CefBrowserSettings& settings,
bool* no_javascript_access)
{
wxWebViewEvent *event = new wxWebViewEvent(wxEVT_WEBVIEW_NEWWINDOW,
m_webview->GetId(),
target_url.ToString(),
target_frame_name.ToString());
event->SetEventObject(m_webview);
// We use queue event as this function is called on the render thread
m_webview->GetEventHandler()->QueueEvent(event);
return true;
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{
if(!m_browser.get())
{
m_browser = browser;
m_browserId = browser->GetIdentifier();
}
}
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser)
{
return false;
}
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
if(browser->GetIdentifier() == m_browserId)
{
m_browser = NULL;
}
}
// CefLoadHandler methods
void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame)
{
wxString url = frame->GetURL().ToString();
wxString target = frame->GetName().ToString();
wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_NAVIGATING, m_webview->GetId(), url, target);
event.SetEventObject(m_webview);
m_webview->HandleWindowEvent(event);
if (!event.IsAllowed())
{
// We do not yet have support for vetoing pages
}
}
void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode)
{
wxString url = frame->GetURL().ToString();
wxString target = frame->GetName().ToString();
wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_NAVIGATED, m_webview->GetId(), url, target);
event.SetEventObject(m_webview);
m_webview->HandleWindowEvent(event);
if(frame->IsMain())
{
//Get source code when main frame loads ended.
CefRefPtr<CefStringVisitor> source_visitor = new wxStringVisitor(
m_webview, wxStringVisitor::PAGE_SOURCE);
frame->GetSource(source_visitor);
//Get page text when main frame loads ended.
CefRefPtr<CefStringVisitor> text_visitor = new wxStringVisitor(
m_webview, wxStringVisitor::PAGE_TEXT);
frame->GetText(text_visitor);
//As we are complete we also add to the history list, but not if the
//page is not the main page, ie it is a subframe
if(m_webview->m_historyEnabled && !m_webview->m_historyLoadingFromList)
{
//If we are not at the end of the list, then erase everything
//between us and the end before adding the new page
if(m_webview->m_historyPosition != static_cast<int>(m_webview->m_historyList.size()) - 1)
{
m_webview->m_historyList.erase(m_webview->m_historyList.begin() + m_webview->m_historyPosition + 1,
m_webview->m_historyList.end());
}
wxSharedPtr<wxWebViewHistoryItem> item(new wxWebViewHistoryItem(url, m_webview->GetCurrentTitle()));
m_webview->m_historyList.push_back(item);
m_webview->m_historyPosition++;
}
//Reset as we are done now
m_webview->m_historyLoadingFromList = false;
wxWebViewEvent levent(wxEVT_COMMAND_WEBVIEW_LOADED, m_webview->GetId(), url, target);
levent.SetEventObject(m_webview);
m_webview->HandleWindowEvent(levent);
}
}
void ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& errorText,
const CefString& failedUrl)
{
//We define a macro for convenience
#define ERROR_TYPE_CASE(error, wxtype) case(error): \
type = wxtype;\
break
wxWebViewNavigationError type = wxWEBVIEW_NAV_ERR_OTHER;
switch (errorCode)
{
ERROR_TYPE_CASE(ERR_FAILED, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_ABORTED, wxWEBVIEW_NAV_ERR_USER_CANCELLED);
ERROR_TYPE_CASE(ERR_INVALID_ARGUMENT, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_INVALID_HANDLE, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_FILE_NOT_FOUND, wxWEBVIEW_NAV_ERR_NOT_FOUND);
ERROR_TYPE_CASE(ERR_TIMED_OUT, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_FILE_TOO_BIG, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_UNEXPECTED, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_ACCESS_DENIED, wxWEBVIEW_NAV_ERR_AUTH);
ERROR_TYPE_CASE(ERR_NOT_IMPLEMENTED, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_CONNECTION_CLOSED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_CONNECTION_RESET, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_CONNECTION_REFUSED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_CONNECTION_ABORTED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_CONNECTION_FAILED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_NAME_NOT_RESOLVED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_INTERNET_DISCONNECTED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_SSL_PROTOCOL_ERROR, wxWEBVIEW_NAV_ERR_SECURITY);
ERROR_TYPE_CASE(ERR_ADDRESS_INVALID, wxWEBVIEW_NAV_ERR_REQUEST);
ERROR_TYPE_CASE(ERR_ADDRESS_UNREACHABLE, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_SSL_CLIENT_AUTH_CERT_NEEDED, wxWEBVIEW_NAV_ERR_AUTH);
ERROR_TYPE_CASE(ERR_TUNNEL_CONNECTION_FAILED, wxWEBVIEW_NAV_ERR_CONNECTION);
ERROR_TYPE_CASE(ERR_NO_SSL_VERSIONS_ENABLED, wxWEBVIEW_NAV_ERR_SECURITY);
ERROR_TYPE_CASE(ERR_SSL_VERSION_OR_CIPHER_MISMATCH, wxWEBVIEW_NAV_ERR_SECURITY);
ERROR_TYPE_CASE(ERR_SSL_RENEGOTIATION_REQUESTED, wxWEBVIEW_NAV_ERR_REQUEST);
ERROR_TYPE_CASE(ERR_CERT_COMMON_NAME_INVALID, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_DATE_INVALID, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_AUTHORITY_INVALID, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_CONTAINS_ERRORS, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_NO_REVOCATION_MECHANISM, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_UNABLE_TO_CHECK_REVOCATION, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_REVOKED, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_INVALID, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_CERT_END, wxWEBVIEW_NAV_ERR_CERTIFICATE);
ERROR_TYPE_CASE(ERR_INVALID_URL, wxWEBVIEW_NAV_ERR_REQUEST);
ERROR_TYPE_CASE(ERR_DISALLOWED_URL_SCHEME, wxWEBVIEW_NAV_ERR_REQUEST);
ERROR_TYPE_CASE(ERR_UNKNOWN_URL_SCHEME, wxWEBVIEW_NAV_ERR_REQUEST);
ERROR_TYPE_CASE(ERR_TOO_MANY_REDIRECTS, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_UNSAFE_REDIRECT, wxWEBVIEW_NAV_ERR_SECURITY);
ERROR_TYPE_CASE(ERR_UNSAFE_PORT, wxWEBVIEW_NAV_ERR_SECURITY);
ERROR_TYPE_CASE(ERR_INVALID_RESPONSE, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_INVALID_CHUNKED_ENCODING, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_METHOD_NOT_SUPPORTED, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_UNEXPECTED_PROXY_AUTH, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_EMPTY_RESPONSE, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_RESPONSE_HEADERS_TOO_BIG, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_CACHE_MISS, wxWEBVIEW_NAV_ERR_OTHER);
ERROR_TYPE_CASE(ERR_INSECURE_RESPONSE, wxWEBVIEW_NAV_ERR_SECURITY);
}
wxString url = failedUrl.ToString();
wxString target = frame->GetName().ToString();
wxWebViewEvent event(wxEVT_COMMAND_WEBVIEW_ERROR, m_webview->GetId(), url, target);
event.SetEventObject(m_webview);
event.SetInt(type);
event.SetString(errorText.ToString());
m_webview->HandleWindowEvent(event);
}
#endif