Title: [97624] trunk/Source/WebKit2
- Revision
- 97624
- Author
- carlo...@webkit.org
- Date
- 2011-10-17 09:23:51 -0700 (Mon, 17 Oct 2011)
Log Message
[GTK] Add methods to get/set a custom text enconding to WebKit2 GTK+ API
https://bugs.webkit.org/show_bug.cgi?id=69524
Reviewed by Martin Robinson.
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkit_web_view_get_custom_charset):
(webkit_web_view_set_custom_charset):
* UIProcess/API/gtk/WebKitWebView.h:
* UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
(testWebViewCustomCharset):
(beforeAll):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (97623 => 97624)
--- trunk/Source/WebKit2/ChangeLog 2011-10-17 15:28:56 UTC (rev 97623)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-17 16:23:51 UTC (rev 97624)
@@ -1,3 +1,18 @@
+2011-10-17 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Add methods to get/set a custom text enconding to WebKit2 GTK+ API
+ https://bugs.webkit.org/show_bug.cgi?id=69524
+
+ Reviewed by Martin Robinson.
+
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkit_web_view_get_custom_charset):
+ (webkit_web_view_set_custom_charset):
+ * UIProcess/API/gtk/WebKitWebView.h:
+ * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
+ (testWebViewCustomCharset):
+ (beforeAll):
+
2011-10-14 Jesus Sanchez-Palencia <jesus.palen...@openbossa.org>
[Qt][WK2] Implement decidePolicyForResponse in our PolicyClient
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (97623 => 97624)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2011-10-17 15:28:56 UTC (rev 97623)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2011-10-17 16:23:51 UTC (rev 97624)
@@ -43,6 +43,7 @@
struct _WebKitWebViewPrivate {
WebKitWebContext* context;
+ CString customTextEncoding;
GRefPtr<WebKitWebLoaderClient> loaderClient;
};
@@ -310,3 +311,45 @@
WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
WKPageGoForward(toAPI(page));
}
+
+/**
+ * webkit_web_view_get_custom_charset:
+ * @web_view: a #WebKitWebView
+ *
+ * Returns the current custom character encoding name of @web_view.
+ *
+ * Returns: the current custom character encoding name or %NULL if no
+ * custom character encoding has been set.
+ */
+const gchar* webkit_web_view_get_custom_charset(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKStringRef> wkCustomEncoding(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(page)));
+ if (WKStringIsEmpty(wkCustomEncoding.get()))
+ return 0;
+
+ webView->priv->customTextEncoding = toImpl(wkCustomEncoding.get())->string().utf8();
+ return webView->priv->customTextEncoding.data();
+}
+
+/**
+ * webkit_web_view_set_custom_charset:
+ * @web_view: a #WebKitWebView
+ * @charset: (allow-none): a character encoding name or %NULL
+ *
+ * Sets the current custom character encoding override of @web_view. The custom
+ * character encoding will override any text encoding detected via HTTP headers or
+ * META tags. Calling this method will stop any current load operation and reload the
+ * current page. Setting the custom character encoding to %NULL removes the character
+ * encoding override.
+ */
+void webkit_web_view_set_custom_charset(WebKitWebView* webView, const gchar* charset)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKStringRef> wkEncodingName = charset ? adoptWK(WKStringCreateWithUTF8CString(charset)) : 0;
+ WKPageSetCustomTextEncodingName(toAPI(page), wkEncodingName.get());
+}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (97623 => 97624)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2011-10-17 15:28:56 UTC (rev 97623)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2011-10-17 16:23:51 UTC (rev 97624)
@@ -107,6 +107,13 @@
WEBKIT_API void
webkit_web_view_go_forward (WebKitWebView *web_view);
+WEBKIT_API const gchar *
+webkit_web_view_get_custom_charset (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_set_custom_charset (WebKitWebView *web_view,
+ const gchar *charset);
+
G_END_DECLS
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp (97623 => 97624)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp 2011-10-17 15:28:56 UTC (rev 97623)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp 2011-10-17 16:23:51 UTC (rev 97624)
@@ -26,9 +26,21 @@
g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default());
}
+static void testWebViewCustomCharset(WebViewTest* test, gconstpointer)
+{
+ g_assert(!webkit_web_view_get_custom_charset(test->m_webView));
+ webkit_web_view_set_custom_charset(test->m_webView, "utf8");
+ g_assert_cmpstr(webkit_web_view_get_custom_charset(test->m_webView), ==, "utf8");
+ // Go back to the default charset.
+ webkit_web_view_set_custom_charset(test->m_webView, 0);
+ g_assert(!webkit_web_view_get_custom_charset(test->m_webView));
+}
+
+
void beforeAll()
{
WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
+ WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
}
void afterAll()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes