Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit f474fed

Browse files
committed
[[ BrowserWidget ]] Standardize navigate messages.
Send navigate messages alongside non-frame documentLoad messages.
1 parent ef2b04a commit f474fed

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

libbrowser/src/libbrowser_android.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ JNIEXPORT void JNICALL Java_com_runrev_android_libraries_LibBrowserWebView_doSta
361361

362362
MCBrowser *t_browser;
363363
if (MCBrowserFindWithJavaView(env, object, t_browser))
364+
{
365+
((MCAndroidWebViewBrowser*)t_browser)->OnNavigationBegin(false, t_url);
364366
((MCAndroidWebViewBrowser*)t_browser)->OnDocumentLoadBegin(false, t_url);
367+
}
365368

366369
MCCStringFree(t_url);
367370
}
@@ -375,7 +378,10 @@ JNIEXPORT void JNICALL Java_com_runrev_android_libraries_LibBrowserWebView_doFin
375378

376379
MCBrowser *t_browser;
377380
if (MCBrowserFindWithJavaView(env, object, t_browser))
381+
{
378382
((MCAndroidWebViewBrowser*)t_browser)->OnDocumentLoadComplete(false, t_url);
383+
((MCAndroidWebViewBrowser*)t_browser)->OnNavigationComplete(false, t_url);
384+
}
379385

380386
MCCStringFree(t_url);
381387
}
@@ -393,7 +399,10 @@ JNIEXPORT void JNICALL Java_com_runrev_android_libraries_LibBrowserWebView_doLoa
393399

394400
MCBrowser *t_browser;
395401
if (MCBrowserFindWithJavaView(env, object, t_browser))
402+
{
396403
((MCAndroidWebViewBrowser*)t_browser)->OnDocumentLoadFailed(false, t_url, t_error);
404+
((MCAndroidWebViewBrowser*)t_browser)->OnNavigationFailed(false, t_url, t_error);
405+
}
397406

398407
MCCStringFree(t_url);
399408
MCCStringFree(t_error);

libbrowser/src/libbrowser_cef.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,6 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
668668
t_url_str = nil;
669669
/* UNCHECKED */ MCCefStringToUtf8String(t_url, t_url_str);
670670

671-
m_owner->OnNavigationBegin(!p_frame->IsMain(), t_url_str);
672-
673671
if (t_url_str != nil)
674672
MCCStringFree(t_url_str);
675673

@@ -791,7 +789,13 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
791789
t_url_str = nil;
792790
/* UNCHECKED */ MCCefStringToUtf8String(t_url, t_url_str);
793791

794-
m_owner->OnNavigationComplete(!p_frame->IsMain(), t_url_str);
792+
bool t_frame;
793+
t_frame = !p_frame->IsMain();
794+
795+
if (!t_frame)
796+
m_owner->OnNavigationBegin(t_frame, t_url_str);
797+
798+
m_owner->OnDocumentLoadBegin(t_frame, t_url_str);
795799

796800
if (t_url_str != nil)
797801
MCCStringFree(t_url_str);
@@ -808,8 +812,6 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
808812
bool t_is_error;
809813
t_is_error = RemoveLoadErrorFrame(p_frame->GetIdentifier(), t_url, t_error);
810814

811-
/* TODO - Load error handling */
812-
// For now we don't send a browser load error message - instead make sure documentComplete is sent with the correct url
813815
if (!t_is_error)
814816
t_url = p_frame->GetURL();
815817

@@ -820,29 +822,37 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
820822
t_url_str = nil;
821823
/* UNCHECKED */ MCCefStringToUtf8String(t_url, t_url_str);
822824

825+
bool t_frame;
826+
t_frame = !p_frame->IsMain();
827+
823828
if (t_is_error)
824829
{
825830
char *t_err_str;
826831
t_err_str = nil;
827832
/* UNCHECKED */ MCCefStringToUtf8String(t_error, t_err_str);
828833

829-
m_owner->OnDocumentLoadFailed(!p_frame->IsMain(), t_url_str, t_err_str);
834+
m_owner->OnDocumentLoadFailed(t_frame, t_url_str, t_err_str);
835+
836+
if (!t_frame)
837+
m_owner->OnNavigationFailed(t_frame, t_url_str, t_err_str);
830838

831839
if (t_err_str != nil)
832840
MCCStringFree(t_err_str);
833841
}
834842
else
835-
m_owner->OnDocumentLoadComplete(!p_frame->IsMain(), t_url_str);
843+
{
844+
m_owner->OnDocumentLoadComplete(t_frame, t_url_str);
845+
846+
if (!t_frame)
847+
m_owner->OnNavigationComplete(t_frame, t_url_str);
848+
}
836849

837850
if (t_url_str != nil)
838851
MCCStringFree(t_url_str);
839852
}
840853

841854
virtual void OnLoadError(CefRefPtr<CefBrowser> p_browser, CefRefPtr<CefFrame> p_frame, CefLoadHandler::ErrorCode p_error_code, const CefString &p_error_text, const CefString &p_failed_url) OVERRIDE
842855
{
843-
if (IgnoreUrl(p_failed_url))
844-
return;
845-
846856
AddLoadErrorFrame(p_frame->GetIdentifier(), p_failed_url, p_error_text);
847857
}
848858

0 commit comments

Comments
 (0)