summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h2
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.cpp26
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.h6
-rw-r--r--Source/WebKit/android/jni/WebHistory.cpp4
4 files changed, 32 insertions, 6 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h
index dac555f..9728aad 100644
--- a/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h
+++ b/Source/WebKit/android/WebCoreSupport/ChromiumIncludes.h
@@ -57,6 +57,7 @@
#include <base/threading/thread.h>
#include <base/time.h>
#include <base/tuple.h>
+#include <base/utf_string_conversions.h>
#include <chrome/browser/net/sqlite_persistent_cookie_store.h>
#include <net/base/auth.h>
#include <net/base/cert_verifier.h>
@@ -68,6 +69,7 @@
#include <net/base/load_flags.h>
#include <net/base/net_errors.h>
#include <net/base/mime_util.h>
+#include <net/base/net_util.h>
#include <net/base/openssl_private_key_store.h>
#include <net/base/ssl_cert_request_info.h>
#include <net/base/ssl_config_service.h>
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
index 5ec4468..c08e629 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -550,6 +550,26 @@ WebFrame::reportError(int errorCode, const WTF::String& description,
env->DeleteLocalRef(failUrl);
}
+WTF::String
+WebFrame::convertIDNToUnicode(const WebCore::KURL& url) {
+ WTF::String converted = url.string();
+#if USE(CHROME_NETWORK_STACK)
+ const WTF::String host = url.host();
+ if (host.find("xn--") == notFound) // no punycode IDN found.
+ return converted;
+ std::wstring languages;
+ const WTF::CString cHost = host.utf8();
+ std::wstring result = net::IDNToUnicode(cHost.data(), cHost.length(), languages, 0);
+ const WTF::String convertedHost = String::fromUTF8(WideToUTF8(result).c_str());
+ if (convertedHost.length() && convertedHost.length() != host.length()) {
+ WebCore::KURL newUrl = url;
+ newUrl.setHost(convertedHost);
+ converted = newUrl.string();
+ }
+#endif
+ return converted;
+}
+
void
WebFrame::loadStarted(WebCore::Frame* frame)
{
@@ -579,7 +599,7 @@ WebFrame::loadStarted(WebCore::Frame* frame)
!isMainFrame))
return;
- const WTF::String& urlString = url.string();
+ const WTF::String urlString = convertIDNToUnicode(url);
// If this is the main frame and we already have a favicon in the database,
// send it along with the page started notification.
jobject favicon = NULL;
@@ -651,7 +671,7 @@ WebFrame::didFinishLoad(WebCore::Frame* frame)
bool isMainFrame = (!frame->tree() || !frame->tree()->parent());
WebCore::FrameLoadType loadType = loader->loadType();
- const WTF::String& urlString = url.string();
+ const WTF::String urlString = convertIDNToUnicode(url);
jstring urlStr = wtfStringToJstring(env, urlString);
env->CallVoidMethod(javaFrame.get(), mJavaFrame->mLoadFinished, urlStr, static_cast<int>(loadType), isMainFrame);
checkException(env);
@@ -800,7 +820,7 @@ WebFrame::updateVisitedHistory(const WebCore::KURL& url, bool reload)
if (!javaFrame.get())
return;
- const WTF::String& urlStr = url.string();
+ const WTF::String urlStr = convertIDNToUnicode(url);
jstring jUrlStr = wtfStringToJstring(env, urlStr);
env->CallVoidMethod(javaFrame.get(), mJavaFrame->mUpdateVisitedHistory, jUrlStr, reload);
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.h b/Source/WebKit/android/jni/WebCoreFrameBridge.h
index acf4eb4..0a8fe8b 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.h
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.h
@@ -160,7 +160,11 @@ class WebFrame : public WebCoreRefObject {
void saveFormData(WebCore::HTMLFormElement*);
const WebCore::RenderSkinAndroid* renderSkins() const { return m_renderSkins; }
void setRenderSkins(const WebCore::RenderSkinAndroid* skins) { m_renderSkins = skins; }
-private:
+
+ // Convert a URL from potential punycode I18nDomainName to safe to-be-displayed Unicode.
+ static WTF::String convertIDNToUnicode(const WebCore::KURL& kurl);
+
+ private:
struct JavaBrowserFrame;
JavaBrowserFrame* mJavaFrame;
WebCore::Page* mPage;
diff --git a/Source/WebKit/android/jni/WebHistory.cpp b/Source/WebKit/android/jni/WebHistory.cpp
index c0a0906..7ec73a3 100644
--- a/Source/WebKit/android/jni/WebHistory.cpp
+++ b/Source/WebKit/android/jni/WebHistory.cpp
@@ -269,11 +269,11 @@ void WebHistoryItem::updateHistoryItem(WebCore::HistoryItem* item) {
if (!realItem.get())
return;
- const WTF::String& urlString = item->urlString();
+ const WTF::String urlString = WebFrame::convertIDNToUnicode(item->url());
jstring urlStr = NULL;
if (!urlString.isNull())
urlStr = wtfStringToJstring(env, urlString);
- const WTF::String& originalUrlString = item->originalURLString();
+ const WTF::String originalUrlString = WebFrame::convertIDNToUnicode(item->originalURL());
jstring originalUrlStr = NULL;
if (!originalUrlString.isNull())
originalUrlStr = wtfStringToJstring(env, originalUrlString);