Skip to content

Commit f765d7e

Browse files
Merge branch 'develop-6.7' into develop-7.0
2 parents 013b9ea + 7ab6749 commit f765d7e

6 files changed

Lines changed: 162 additions & 14 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<doc>
2+
<legacy_id></legacy_id>
3+
<name>browserDocumentFailed</name>
4+
<type>message</type>
5+
<syntax>
6+
<example>browserDocumentFailed <i>instanceId, url, errorMessage</i></example>
7+
</syntax>
8+
<library>Browser Library</library>
9+
<objects>
10+
<card/>
11+
</objects>
12+
<synonyms>
13+
</synonyms>
14+
<classification>
15+
</classification>
16+
<references>
17+
<message tag="browserDownloadRequest">browserDownloadRequest Message</message>
18+
<function tag="revBrowserOpenCef">revBrowserOpenCef Function</function>
19+
</references>
20+
<history>
21+
<introduced version="6.7.3">Added.</introduced>
22+
</history>
23+
<platforms>
24+
<mac/>
25+
<windows/>
26+
</platforms>
27+
<classes>
28+
<desktop/>
29+
</classes>
30+
<security>
31+
<network/>
32+
</security>
33+
<summary>Sent when a browser object has encountered an error when loading a url</summary>
34+
<examples>
35+
<example>on browserDocumentFailed pInstanceId, pUrl, pErrorMessage</p><p> answer "Failed to load URL" && quote & pUrl & quote & return & "Error message: " && pErrorMessage</p><p>end browserDocumentFailed</example>
36+
</examples>
37+
<description>
38+
<p>The <b>browserDocumentFailed</b> message is sent to the current card of a stack containing a browser object when the browser object has encountered an error while loading a url and all its dependent resources.</p><p/><p>If the target is the main frame of the browser (e.g. the html page with the "FRAMESET" declaration), then the <b>browserDocumentFailed</b> message is sent. Otherwise the <message tag="browserDocumentFailedFrame">browserDocumentFailedFrame message</message> is sent instead.</p><p/><p><b>Parameters:</b></p><p>The <i>url</i> is the url that has failed to load</p><p>The <i>instanceId</i> is the integer identifer of the browser object</p><p>The <i>errorMessage</i> is a message explaining why the url failed to load</p><p/><p><b>Note:</b> For general information on using the browser library, see the notes in the <function tag="revBrowserOpen">revBrowserOpen function</function> reference.</p>
39+
</description>
40+
</doc>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<doc>
2+
<legacy_id></legacy_id>
3+
<name>browserDocumentFailedFrame</name>
4+
<type>message</type>
5+
<syntax>
6+
<example>browserDocumentFailedFrame <i>instanceId, url, errorMessage</i></example>
7+
</syntax>
8+
<library>Browser Library</library>
9+
<objects>
10+
<card/>
11+
</objects>
12+
<synonyms>
13+
</synonyms>
14+
<classification>
15+
</classification>
16+
<references>
17+
<message tag="browserDownloadRequest">browserDownloadRequest Message</message>
18+
<function tag="revBrowserOpenCef">revBrowserOpenCef Function</function>
19+
</references>
20+
<history>
21+
<introduced version="6.7.3">Added.</introduced>
22+
</history>
23+
<platforms>
24+
<mac/>
25+
<windows/>
26+
</platforms>
27+
<classes>
28+
<desktop/>
29+
</classes>
30+
<security>
31+
<network/>
32+
</security>
33+
<summary>Sent when a browser object has encountered an error when loading a url in a frame</summary>
34+
<examples>
35+
<example>on browserDocumentFailedFrame pInstanceId, pUrl, pErrorMessage</p><p> answer "Failed to load frame URL" && quote & pUrl & quote & return & "Error message: " && pErrorMessage</p><p>end browserDocumentFailedFrame</example>
36+
</examples>
37+
<description>
38+
<p>The <b>browserDocumentFailedFrame</b> message is sent to the current card of a stack containing a browser object when the browser object has encountered an error while loading a url and all its dependent resources in a frame.</p><p/><p>If the target is the main frame of the browser then the <message tag="browserDocumentFailed">browserDocumentFailed message</message> message is sent instead.</p><p/><p><b>Parameters:</b></p><p>The <i>url</i> is the url that has failed to load in a frame</p><p>The <i>instanceId</i> is the integer identifer of the browser object</p><p>The <i>errorMessage</i> is a message explaining why the url failed to load in the frame</p><p/><p><b>Note:</b> For general information on using the browser library, see the notes in the <function tag="revBrowserOpen">revBrowserOpen function</function> reference.</p>
39+
</description>
40+
</doc>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Add revBrowser error callback messages.
2+
3+
Added two new callbacks sent by revBrowser.
4+
Note that these messages are only sent from browsers opened with revBrowserOpenCEF.
5+
6+
## Callback messages:
7+
* browserDocumentFailed
8+
* sent to the current card when the browser has encountered an error while loading a URL.
9+
* browserDocumentFailedFrame
10+
* sent to the current card when the browser has encountered an error while loading a URL into a frame.

revbrowser/src/cefbrowser.cpp

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@ class MCCefMessageResult
373373
////////////////////////////////////////////////////////////////////////////////
374374
// Browser client - receives callback messages from the browser
375375

376+
struct MCCefErrorInfo
377+
{
378+
CefString url;
379+
CefString error_message;
380+
};
381+
376382
class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandler, CefDownloadHandler, CefLoadHandler, CefContextMenuHandler
377383
{
378384
private:
@@ -381,7 +387,7 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
381387
MCCefBrowserBase *m_owner;
382388

383389
MCCefMessageResult m_message_result;
384-
std::map<int64_t, CefString> m_load_error_frames;
390+
std::map<int64_t, MCCefErrorInfo> m_load_error_frames;
385391

386392
// IM-2014-05-06: [[ Bug 12384 ]] Set of URLs for which callback messages will not be sent
387393
std::set<CefString> m_ignore_urls;
@@ -390,20 +396,22 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
390396

391397
// Error handling - we need to keep track of url that failed to load in a
392398
// frame so we can send the correct url in onLoadEnd()
393-
void AddLoadErrorFrame(int64_t p_id, const CefString &p_url)
399+
void AddLoadErrorFrame(int64_t p_id, const CefString &p_url, const CefString &p_error_msg)
394400
{
395-
m_load_error_frames[p_id] = p_url;
401+
m_load_error_frames[p_id].url = p_url;
402+
m_load_error_frames[p_id].error_message = p_error_msg;
396403
}
397404

398-
bool RemoveLoadErrorFrame(int64_t p_id, CefString &r_error_url)
405+
bool RemoveLoadErrorFrame(int64_t p_id, CefString &r_error_url, CefString &r_error_msg)
399406
{
400-
std::map<int64_t, CefString>::iterator t_iter;
407+
std::map<int64_t, MCCefErrorInfo>::iterator t_iter;
401408
t_iter = m_load_error_frames.find(p_id);
402409

403410
if (t_iter == m_load_error_frames.end())
404411
return false;
405412

406-
r_error_url = t_iter->second;
413+
r_error_url = t_iter->second.url;
414+
r_error_msg = t_iter->second.error_message;
407415
m_load_error_frames.erase(t_iter);
408416

409417
return true;
@@ -760,10 +768,10 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
760768
if (nil == m_owner)
761769
return;
762770

763-
CefString t_url;
771+
CefString t_url, t_error;
764772

765773
bool t_is_error;
766-
t_is_error = RemoveLoadErrorFrame(p_frame->GetIdentifier(), t_url);
774+
t_is_error = RemoveLoadErrorFrame(p_frame->GetIdentifier(), t_url, t_error);
767775

768776
/* TODO - Load error handling */
769777
// For now we don't send a browser load error message - instead make sure documentComplete is sent with the correct url
@@ -777,11 +785,28 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
777785
t_url_str = nil;
778786
/* UNCHECKED */ MCCefStringToCString(t_url, t_url_str);
779787

780-
if (p_frame->IsMain())
781-
CB_DocumentComplete(m_owner->GetInst(), t_url_str);
788+
if (t_is_error)
789+
{
790+
char *t_err_str;
791+
t_err_str = nil;
792+
/* UNCHECKED */ MCCefStringToCString(t_error, t_err_str);
793+
794+
if (p_frame->IsMain())
795+
CB_DocumentFailed(m_owner->GetInst(), t_url_str, t_err_str);
796+
else
797+
CB_DocumentFrameFailed(m_owner->GetInst(), t_url_str, t_err_str);
798+
799+
if (t_err_str != nil)
800+
MCCStringFree(t_err_str);
801+
}
782802
else
783-
CB_DocumentFrameComplete(m_owner->GetInst(), t_url_str);
784-
803+
{
804+
if (p_frame->IsMain())
805+
CB_DocumentComplete(m_owner->GetInst(), t_url_str);
806+
else
807+
CB_DocumentFrameComplete(m_owner->GetInst(), t_url_str);
808+
}
809+
785810
if (t_url_str != nil)
786811
MCCStringFree(t_url_str);
787812
}
@@ -791,7 +816,7 @@ class MCCefBrowserClient : public CefClient, CefLifeSpanHandler, CefRequestHandl
791816
if (IgnoreUrl(p_failed_url))
792817
return;
793818

794-
AddLoadErrorFrame(p_frame->GetIdentifier(), p_failed_url);
819+
AddLoadErrorFrame(p_frame->GetIdentifier(), p_failed_url, p_error_text);
795820
}
796821

797822
// ContextMenuHandler interface

revbrowser/src/revbrowser.cpp

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ bool is_escape_char(char p_char)
285285
bool MCCStringQuote(const char *p_string, char *&r_quoted)
286286
{
287287
if (p_string == nil || p_string[0] == '\0')
288-
return MCCStringClone("", r_quoted);
288+
return MCCStringClone("\"\"", r_quoted);
289289

290290
bool t_success;
291291
t_success = true;
@@ -770,6 +770,21 @@ void CB_DocumentComplete(int p_instance_id, const char *p_url)
770770
s_browsers . Callback(p_instance_id, "DocumentComplete", p_url);
771771
}
772772

773+
// Callback:
774+
// browserDocumentFailed pInstanceId, pURL, pErrorMessage
775+
// Description:
776+
// The browser sends this message when a given URL has failed to load.
777+
//
778+
void CB_DocumentFailed(int p_instance_id, const char *p_url, const char *p_error)
779+
{
780+
const char *t_params[2];
781+
t_params[0] = p_url;
782+
t_params[1] = p_error;
783+
784+
bool t_pass;
785+
s_browsers . Callback(p_instance_id, "browserDocumentFailed", (char**)t_params, 2, t_pass);
786+
}
787+
773788
// Callback:
774789
// XBrowser_DocumentCompleteFrame pURL, pInstanceId
775790
// Description:
@@ -781,6 +796,21 @@ void CB_DocumentFrameComplete(int p_instance_id, const char *p_url)
781796
s_browsers . Callback(p_instance_id, "DocumentCompleteFrame", p_url);
782797
}
783798

799+
// Callback:
800+
// browserDocumentFailedFrame pInstanceId, pURL, pErrorMessage
801+
// Description:
802+
// The browser sends this message when a given URL has failed to load into a frame.
803+
//
804+
void CB_DocumentFrameFailed(int p_instance_id, const char *p_url, const char *p_error)
805+
{
806+
const char *t_params[2];
807+
t_params[0] = p_url;
808+
t_params[1] = p_error;
809+
810+
bool t_pass;
811+
s_browsers . Callback(p_instance_id, "browserDocumentFailedFrame", (char**)t_params, 2, t_pass);
812+
}
813+
784814
// Callback:
785815
// XBrowser_NewURLWindow pURL, pInstanceId
786816
// Description:

revbrowser/src/revbrowser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ void CB_NavigateFrameComplete(int p_instance_id, const char *p_url);
107107
void CB_DocumentComplete(int p_instance_id, const char *p_url);
108108
void CB_DocumentFrameComplete(int p_instance_id, const char *p_url);
109109

110+
void CB_DocumentFailed(int p_instance_id, const char *p_url, const char *p_error);
111+
void CB_DocumentFrameFailed(int p_instance_id, const char *p_url, const char *p_error);
112+
110113
void CB_CreateInstance(int p_instance_id);
111114
void CB_DestroyInstance(int p_instance_id);
112115

0 commit comments

Comments
 (0)