diff options
author | apiccion@chromium.org <apiccion@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-09 03:49:48 +0000 |
---|---|---|
committer | apiccion@chromium.org <apiccion@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-09 03:49:48 +0000 |
commit | 411cc3aed3f08577e297c590ffba4ab31ded31a7 (patch) | |
tree | b8f8e968401f2020a2b1a808dd1c29893b6eea1f /net/android | |
parent | e882d2cdf5ed5337d68f2b32ba0f885725ca8b3f (diff) | |
download | chromium_src-411cc3aed3f08577e297c590ffba4ab31ded31a7.zip chromium_src-411cc3aed3f08577e297c590ffba4ab31ded31a7.tar.gz chromium_src-411cc3aed3f08577e297c590ffba4ab31ded31a7.tar.bz2 |
Added JNI method to allow java code parse the scheme from a url string using GURL.
BUG=223930
Review URL: https://chromiumcodereview.appspot.com/14614005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/android')
-rw-r--r-- | net/android/gurl_utils.cc | 7 | ||||
-rw-r--r-- | net/android/java/src/org/chromium/net/GURLUtils.java | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/net/android/gurl_utils.cc b/net/android/gurl_utils.cc index 94d8e78..d6442d2 100644 --- a/net/android/gurl_utils.cc +++ b/net/android/gurl_utils.cc @@ -17,6 +17,13 @@ jstring GetOrigin(JNIEnv* env, jclass clazz, jstring url) { host.GetOrigin().spec()).Release(); } +jstring GetScheme(JNIEnv* env, jclass clazz, jstring url) { + GURL host(base::android::ConvertJavaStringToUTF16(env, url)); + + return base::android::ConvertUTF8ToJavaString(env, + host.scheme()).Release(); +} + bool RegisterGURLUtils(JNIEnv* env) { return RegisterNativesImpl(env); } diff --git a/net/android/java/src/org/chromium/net/GURLUtils.java b/net/android/java/src/org/chromium/net/GURLUtils.java index 8047ad3..719ddea 100644 --- a/net/android/java/src/org/chromium/net/GURLUtils.java +++ b/net/android/java/src/org/chromium/net/GURLUtils.java @@ -23,5 +23,16 @@ public final class GURLUtils { return nativeGetOrigin(url); } + /** + * Get the scheme of the url (e.g. http, https, file). The returned string + * contains everything before the "://". + * + * @return The scheme of the url. + */ + public static String getScheme(String url) { + return nativeGetScheme(url); + } + private static native String nativeGetOrigin(String url); + private static native String nativeGetScheme(String url); } |