summaryrefslogtreecommitdiffstats
path: root/url/android
diff options
context:
space:
mode:
Diffstat (limited to 'url/android')
-rw-r--r--url/android/java/src/org/chromium/url/IDNStringUtil.java33
-rw-r--r--url/android/url_jni_registrar.cc24
-rw-r--r--url/android/url_jni_registrar.h21
3 files changed, 78 insertions, 0 deletions
diff --git a/url/android/java/src/org/chromium/url/IDNStringUtil.java b/url/android/java/src/org/chromium/url/IDNStringUtil.java
new file mode 100644
index 0000000..32000fd
--- /dev/null
+++ b/url/android/java/src/org/chromium/url/IDNStringUtil.java
@@ -0,0 +1,33 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.url;
+
+import org.chromium.base.CalledByNative;
+import org.chromium.base.JNINamespace;
+
+import java.net.IDN;
+
+/**
+ * This class is used to convert unicode IDN domain names to ASCII, when not
+ * building with ICU.
+ */
+@JNINamespace("url::android")
+public class IDNStringUtil {
+ /**
+ * Attempts to convert a Unicode string to an ASCII string using IDN rules.
+ * As of May 2014, the underlying Java function IDNA2003.
+ * @param src String to convert.
+ * @return: String containing only ASCII characters on success, null on
+ * failure.
+ */
+ @CalledByNative
+ private static String idnToASCII(String src) {
+ try {
+ return IDN.toASCII(src, IDN.USE_STD3_ASCII_RULES);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+} \ No newline at end of file
diff --git a/url/android/url_jni_registrar.cc b/url/android/url_jni_registrar.cc
new file mode 100644
index 0000000..82a6e1b
--- /dev/null
+++ b/url/android/url_jni_registrar.cc
@@ -0,0 +1,24 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "url/android/url_jni_registrar.h"
+
+#ifdef USE_ICU_ALTERNATIVES_ON_ANDROID
+#include "url/url_canon_icu_alternatives_android.h"
+#endif
+
+namespace url {
+namespace android {
+
+bool RegisterJni(JNIEnv* env) {
+#ifdef USE_ICU_ALTERNATIVES_ON_ANDROID
+ return RegisterIcuAlternativesJni(env);
+#endif
+
+ // Do nothing if USE_ICU_ALTERNATIVES_ON_ANDROID is not defined.
+ return true;
+}
+
+} // namespace android
+} // namespace url
diff --git a/url/android/url_jni_registrar.h b/url/android/url_jni_registrar.h
new file mode 100644
index 0000000..8fe7ded
--- /dev/null
+++ b/url/android/url_jni_registrar.h
@@ -0,0 +1,21 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef URL_ANDROID_URL_JNI_REGISTRAR_H_
+#define URL_ANDROID_URL_JNI_REGISTRAR_H_
+
+#include <jni.h>
+
+#include "url/url_export.h"
+
+namespace url {
+namespace android {
+
+// Register all JNI bindings necessary for url.
+URL_EXPORT bool RegisterJni(JNIEnv* env);
+
+} // namespace android
+} // namespace url
+
+#endif // URL_ANDROID_URL_JNI_REGISTRAR_H_