<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[42864] trunk/WebKit/gtk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/42864">42864</a></dd>
<dt>Author</dt> <dd>jmalonzo@webkit.org</dd>
<dt>Date</dt> <dd>2009-04-25 02:19:03 -0700 (Sat, 25 Apr 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>2009-04-25  Jan Michael Alonzo  &lt;jmalonzo@webkit.org&gt;

         Reviewed by Xan Lopez.

         [GTK] Error reporting
         https://bugs.webkit.org/show_bug.cgi?id=18344

         Add a WebKitWebFrame API to load alternate content for unreachable URLs.
         Also add a new signal &quot;load-error&quot; for handling load errors.

         * WebCoreSupport/FrameLoaderClientGtk.cpp:
         (WebKit::FrameLoaderClient::postProgressFinishedNotification):
         (WebKit::FrameLoaderClient::dispatchDidFailLoading):
         (WebKit::FrameLoaderClient::dispatchDidFailProvisionalLoad):
         (WebKit::FrameLoaderClient::dispatchDidFailLoad):
         * webkit/webkitwebframe.cpp:
         * webkit/webkitwebframe.h:
         * webkit/webkitwebview.cpp:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebKitgtkChangeLog">trunk/WebKit/gtk/ChangeLog</a></li>
<li><a href="#trunkWebKitgtkWebCoreSupportFrameLoaderClientGtkcpp">trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp</a></li>
<li><a href="#trunkWebKitgtkwebkitwebkitwebframecpp">trunk/WebKit/gtk/webkit/webkitwebframe.cpp</a></li>
<li><a href="#trunkWebKitgtkwebkitwebkitwebframeh">trunk/WebKit/gtk/webkit/webkitwebframe.h</a></li>
<li><a href="#trunkWebKitgtkwebkitwebkitwebviewcpp">trunk/WebKit/gtk/webkit/webkitwebview.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebKitgtkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/ChangeLog (42863 => 42864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/ChangeLog        2009-04-25 09:04:23 UTC (rev 42863)
+++ trunk/WebKit/gtk/ChangeLog        2009-04-25 09:19:03 UTC (rev 42864)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2009-04-25  Jan Michael Alonzo  &lt;jmalonzo@webkit.org&gt;
+
+         Reviewed by Xan Lopez.
+
+         [GTK] Error reporting
+         https://bugs.webkit.org/show_bug.cgi?id=18344
+
+         Add a WebKitWebFrame API to load alternate content for unreachable URLs.
+         Also add a new signal &quot;load-error&quot; for handling load errors.
+
+         * WebCoreSupport/FrameLoaderClientGtk.cpp:
+         (WebKit::FrameLoaderClient::postProgressFinishedNotification):
+         (WebKit::FrameLoaderClient::dispatchDidFailLoading):
+         (WebKit::FrameLoaderClient::dispatchDidFailProvisionalLoad):
+         (WebKit::FrameLoaderClient::dispatchDidFailLoad):
+         * webkit/webkitwebframe.cpp:
+         * webkit/webkitwebframe.h:
+         * webkit/webkitwebview.cpp:
+
</ins><span class="cx"> 2009-04-24  Jan Michael Alonzo  &lt;jmalonzo@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Rubber-stamped by Gustavo Noronha.
</span></span></pre></div>
<a id="trunkWebKitgtkWebCoreSupportFrameLoaderClientGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp (42863 => 42864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp        2009-04-25 09:04:23 UTC (rev 42863)
+++ trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp        2009-04-25 09:19:03 UTC (rev 42864)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> #include &quot;webkitprivate.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &lt;JavaScriptCore/APICast.h&gt;
</span><ins>+#include &lt;glib.h&gt;
</ins><span class="cx"> #include &lt;stdio.h&gt;
</span><span class="cx"> #if PLATFORM(UNIX)
</span><span class="cx"> #include &lt;sys/utsname.h&gt;
</span><span class="lines">@@ -811,8 +812,9 @@
</span><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&amp;)
</del><ins>+void FrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long identifier, const ResourceError&amp; error)
</ins><span class="cx"> {
</span><ins>+    // FIXME: when does this occur and what should happen?
</ins><span class="cx">     notImplemented();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -822,13 +824,35 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&amp;)
</del><ins>+void FrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError&amp; error)
</ins><span class="cx"> {
</span><ins>+    dispatchDidFailLoad(error);
+
+    // FIXME: load-done is deprecated. Please remove when signal's been removed.
</ins><span class="cx">     g_signal_emit_by_name(m_frame, &quot;load-done&quot;, false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void FrameLoaderClient::dispatchDidFailLoad(const ResourceError&amp;)
</del><ins>+void FrameLoaderClient::dispatchDidFailLoad(const ResourceError&amp; error)
</ins><span class="cx"> {
</span><ins>+    WebKitWebView* webView = getViewFromFrame(m_frame);
+    GError* webError = g_error_new_literal(g_quark_from_string(error.domain().utf8().data()),
+                                           error.errorCode(),
+                                           error.localizedDescription().utf8().data());
+    gboolean isHandled = false;
+    g_signal_emit_by_name(webView, &quot;load-error&quot;, m_frame, error.failingURL().utf8().data(), webError, &amp;isHandled);
+
+    if (isHandled) {
+        g_error_free(webError);
+        return;
+    }
+
+    String content = String::format(&quot;&lt;html&gt;&lt;head&gt;&lt;title&gt;%d&lt;/title&gt;&lt;/head&gt;&lt;body&gt;%s&lt;/body&gt;&lt;/html&gt;&quot;,
+                                    error.errorCode(), webError-&gt;message);
+    webkit_web_frame_load_alternate_string(m_frame, content.utf8().data(),
+                                           NULL, error.failingURL().utf8().data());
+    g_error_free(webError);
+
+    // FIXME: load-done is deprecated. Please remove when signal's been removed.
</ins><span class="cx">     g_signal_emit_by_name(m_frame, &quot;load-done&quot;, false);
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebKitgtkwebkitwebkitwebframecpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/webkit/webkitwebframe.cpp (42863 => 42864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/webkit/webkitwebframe.cpp        2009-04-25 09:04:23 UTC (rev 42863)
+++ trunk/WebKit/gtk/webkit/webkitwebframe.cpp        2009-04-25 09:19:03 UTC (rev 42864)
</span><span class="lines">@@ -167,6 +167,15 @@
</span><span class="cx">             g_cclosure_marshal_VOID__VOID,
</span><span class="cx">             G_TYPE_NONE, 0);
</span><span class="cx"> 
</span><ins>+    /**
+     * WebKitWebFrame::load-done
+     * @web_frame: the object on which the signal is emitted
+     *
+     * Emitted when frame loading is done.
+     *
+     * Deprecated: Use WebKitWebView::load-finished instead, and/or
+     * WebKitWebView::load-error to be notified of load errors
+     */
</ins><span class="cx">     webkit_web_frame_signals[LOAD_DONE] = g_signal_new(&quot;load-done&quot;,
</span><span class="cx">             G_TYPE_FROM_CLASS(frameClass),
</span><span class="cx">             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
</span><span class="lines">@@ -398,6 +407,25 @@
</span><span class="cx">     coreFrame-&gt;loader()-&gt;load(ResourceRequest(KURL(KURL(), String::fromUTF8(uri))), false);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void webkit_web_frame_load_data(WebKitWebFrame* frame, const gchar* content, const gchar* mimeType, const gchar* encoding, const gchar* baseURL, const gchar* unreachableURL)
+{
+    Frame* coreFrame = core(frame);
+    ASSERT(coreFrame);
+
+    KURL baseKURL = baseURL ? KURL(KURL(), String::fromUTF8(baseURL)) : blankURL();
+
+    ResourceRequest request(baseKURL);
+
+    RefPtr&lt;SharedBuffer&gt; sharedBuffer = SharedBuffer::create(content, g_utf8_strlen(content, -1));
+    SubstituteData substituteData(sharedBuffer.release(),
+                                  mimeType ? String::fromUTF8(mimeType) : String::fromUTF8(&quot;text/html&quot;),
+                                  encoding ? String::fromUTF8(encoding) : String::fromUTF8(&quot;UTF-8&quot;),
+                                  baseKURL,
+                                  KURL(KURL(), String::fromUTF8(unreachableURL)));
+
+    coreFrame-&gt;loader()-&gt;load(request, substituteData, false);
+}
+
</ins><span class="cx"> /**
</span><span class="cx">  * webkit_web_frame_load_string:
</span><span class="cx">  * @frame: a #WebKitWebFrame
</span><span class="lines">@@ -420,15 +448,28 @@
</span><span class="cx">     g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));
</span><span class="cx">     g_return_if_fail(content);
</span><span class="cx"> 
</span><del>-    Frame* coreFrame = core(frame);
-    if (!coreFrame)
-        return;
</del><ins>+    webkit_web_frame_load_data(frame, content, contentMimeType, contentEncoding, baseUri, NULL);
+}
</ins><span class="cx"> 
</span><del>-    KURL url(KURL(), baseUri ? String::fromUTF8(baseUri) : &quot;&quot;);
-    RefPtr&lt;SharedBuffer&gt; sharedBuffer = SharedBuffer::create(content, strlen(content));
-    SubstituteData substituteData(sharedBuffer.release(), contentMimeType ? String(contentMimeType) : &quot;text/html&quot;, contentEncoding ? String(contentEncoding) : &quot;UTF-8&quot;, blankURL(), url);
</del><ins>+/**
+ * webkit_web_frame_load_alternate_string:
+ * @frame: a #WebKitWebFrame
+ * @content: the alternate content to display as the main page of the @frame
+ * @base_url: the base URI for relative locations
+ * @unreachable_url: the URL for the alternate page content
+ *
+ * Request loading of an alternate content for a URL that is unreachable.
+ * Using this method will preserve the back-forward list. The URI passed in
+ * @base_url has to be an absolute URI.
+ *
+ * Since: 1.1.6
+ */
+void webkit_web_frame_load_alternate_string(WebKitWebFrame* frame, const gchar* content, const gchar* baseURL, const gchar* unreachableURL)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));
+    g_return_if_fail(content);
</ins><span class="cx"> 
</span><del>-    coreFrame-&gt;loader()-&gt;load(ResourceRequest(url), substituteData, false);
</del><ins>+    webkit_web_frame_load_data(frame, content, NULL, NULL, baseURL, unreachableURL);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre></div>
<a id="trunkWebKitgtkwebkitwebkitwebframeh"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/webkit/webkitwebframe.h (42863 => 42864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/webkit/webkitwebframe.h        2009-04-25 09:04:23 UTC (rev 42863)
+++ trunk/WebKit/gtk/webkit/webkitwebframe.h        2009-04-25 09:19:03 UTC (rev 42864)
</span><span class="lines">@@ -94,6 +94,12 @@
</span><span class="cx">                                      const gchar          *base_uri);
</span><span class="cx"> 
</span><span class="cx"> WEBKIT_API void
</span><ins>+webkit_web_frame_load_alternate_string (WebKitWebFrame    *frame,
+                                        const gchar       *content,
+                                        const gchar       *base_url,
+                                        const gchar       *unreachable_url);
+
+WEBKIT_API void
</ins><span class="cx"> webkit_web_frame_load_request       (WebKitWebFrame       *frame,
</span><span class="cx">                                      WebKitNetworkRequest *request);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebKitgtkwebkitwebkitwebviewcpp"></a>
<div class="modfile"><h4>Modified: trunk/WebKit/gtk/webkit/webkitwebview.cpp (42863 => 42864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebKit/gtk/webkit/webkitwebview.cpp        2009-04-25 09:04:23 UTC (rev 42863)
+++ trunk/WebKit/gtk/webkit/webkitwebview.cpp        2009-04-25 09:19:03 UTC (rev 42864)
</span><span class="lines">@@ -122,6 +122,7 @@
</span><span class="cx">     LOAD_STARTED,
</span><span class="cx">     LOAD_COMMITTED,
</span><span class="cx">     LOAD_PROGRESS_CHANGED,
</span><ins>+    LOAD_ERROR,
</ins><span class="cx">     LOAD_FINISHED,
</span><span class="cx">     TITLE_CHANGED,
</span><span class="cx">     HOVERING_OVER_LINK,
</span><span class="lines">@@ -1300,6 +1301,31 @@
</span><span class="cx">             G_TYPE_NONE, 1,
</span><span class="cx">             G_TYPE_INT);
</span><span class="cx"> 
</span><ins>+    /**
+     * WebKitWebView::load-error
+     * @web_view: the object on which the signal is emitted
+     * @web_frame: the #WebKitWebFrame
+     * @uri: the URI that triggered the error
+     * @web_error: the #GError that was triggered
+     *
+     * An error occurred while loading. By default, if the signal is not
+     * handled, the @web_view will display a stock error page. You need to
+     * handle the signal if you want to provide your own error page.
+     *
+     * Since: 1.1.6
+     */
+    webkit_web_view_signals[LOAD_ERROR] = g_signal_new(&quot;load-error&quot;,
+            G_TYPE_FROM_CLASS(webViewClass),
+            (GSignalFlags)(G_SIGNAL_RUN_LAST),
+            0,
+            g_signal_accumulator_true_handled,
+            NULL,
+            webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
+            G_TYPE_BOOLEAN, 3,
+            WEBKIT_TYPE_WEB_FRAME,
+            G_TYPE_STRING,
+            G_TYPE_POINTER);
+
</ins><span class="cx">     webkit_web_view_signals[LOAD_FINISHED] = g_signal_new(&quot;load-finished&quot;,
</span><span class="cx">             G_TYPE_FROM_CLASS(webViewClass),
</span><span class="cx">             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
</span></span></pre>
</div>
</div>

</body>
</html>