https://bugs.webkit.org/show_bug.cgi?id=90540
Patch by Christophe Dumez <christophe.dumez@intel.com> on 2012-07-05
Reviewed by Kenneth Rohde Christiansen.
Source/WebKit2:
Add method to Ewk_View to load provided HTML data.
This is used for e.g. when an URL cannot be reached
and we need to display an error page.
* UIProcess/API/efl/ewk_view.cpp:
(ewk_view_html_load):
* UIProcess/API/efl/ewk_view.h:
Tools:
Update EFL MiniBrowser to catch the "load,error" signal
on the view and display an error page.
* MiniBrowser/efl/main.c:
(on_error):
(browserCreate):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121890
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2012-07-05 Christophe Dumez <christophe.dumez@intel.com>
+ [WK2][EFL] Ewk_View needs API to load HTML data
+ https://bugs.webkit.org/show_bug.cgi?id=90540
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Add method to Ewk_View to load provided HTML data.
+ This is used for e.g. when an URL cannot be reached
+ and we need to display an error page.
+
+ * UIProcess/API/efl/ewk_view.cpp:
+ (ewk_view_html_load):
+ * UIProcess/API/efl/ewk_view.h:
+
+2012-07-05 Christophe Dumez <christophe.dumez@intel.com>
+
[WK2][EFL] Ewk_View needs to report new resource requests
https://bugs.webkit.org/show_bug.cgi?id=90577
evas_object_smart_callback_call(ewkView, "load,error", const_cast<Ewk_Web_Error*>(error));
}
+Eina_Bool ewk_view_html_string_load(Evas_Object* ewkView, const char* html, const char* baseUrl, const char* unreachableUrl)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false);
+ EINA_SAFETY_ON_NULL_RETURN_VAL(html, false);
+
+ if (unreachableUrl && *unreachableUrl)
+ priv->pageClient->page()->loadAlternateHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "", String::fromUTF8(unreachableUrl));
+ else
+ priv->pageClient->page()->loadHTMLString(String::fromUTF8(html), baseUrl ? String::fromUTF8(baseUrl) : "");
+
+ return true;
+}
#if ENABLE(WEB_INTENTS_TAG)
/**
*/
EAPI double ewk_view_load_progress_get(const Evas_Object *o);
+/**
+ * Loads the specified @a html string as the content of the view.
+ *
+ * External objects such as stylesheets or images referenced in the HTML
+ * document are located relative to @a baseUrl.
+ *
+ * If an @a unreachableUrl is passed it is used as the url for the loaded
+ * content. This is typically used to display error pages for a failed
+ * load.
+ *
+ * @param o view object to load the HTML into
+ * @param html HTML data to load
+ * @param baseUrl Base URL used for relative paths to external objects (optional)
+ * @param unreachableUrl URL that could not be reached (optional)
+ *
+ * @return @c EINA_TRUE if it the HTML was successfully loaded, @c EINA_FALSE otherwise
+ */
+EAPI Eina_Bool ewk_view_html_string_load(Evas_Object *o, const char *html, const char *baseUrl, const char *unreachableUrl);
+
#ifdef __cplusplus
}
#endif
+2012-07-05 Christophe Dumez <christophe.dumez@intel.com>
+
+ [WK2][EFL] Ewk_View needs API to load HTML data
+ https://bugs.webkit.org/show_bug.cgi?id=90540
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Update EFL MiniBrowser to catch the "load,error" signal
+ on the view and display an error page.
+
+ * MiniBrowser/efl/main.c:
+ (on_error):
+ (browserCreate):
+
2012-07-05 Sergio Villar Senin <svillar@igalia.com>
Hidden dirs are not copied when creating the built product archive
title_set(app->ee, ewk_view_title_get(app->browser), progress * 100);
}
+static void
+on_error(void *user_data, Evas_Object *webview, void *event_info)
+{
+ Eina_Strbuf* buffer;
+ const Ewk_Web_Error *error = (const Ewk_Web_Error *)event_info;
+
+ buffer = eina_strbuf_new();
+ eina_strbuf_append_printf(buffer, "<html><body><div style=\"color:#ff0000\">ERROR!</div><br><div>Code: %d<br>Description: %s<br>URL: %s</div></body</html>",
+ ewk_web_error_code_get(error), ewk_web_error_description_get(error), ewk_web_error_url_get(error));
+
+ ewk_view_html_string_load(webview, eina_strbuf_string_get(buffer), 0, ewk_web_error_url_get(error));
+ eina_strbuf_free(buffer);
+}
+
static MiniBrowser *browserCreate(const char *url)
{
MiniBrowser *app = malloc(sizeof(MiniBrowser));
app->browser = ewk_view_add(app->evas);
evas_object_name_set(app->browser, "browser");
+ evas_object_smart_callback_add(app->browser, "load,error", on_error, app);
evas_object_smart_callback_add(app->browser, "load,progress", on_progress, app);
evas_object_smart_callback_add(app->browser, "title,changed", on_title_changed, app);