OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/android/gurl_utils.h" | 5 #include "net/android/gurl_utils.h" |
6 | 6 |
7 #include "base/android/jni_string.h" | 7 #include "base/android/jni_string.h" |
8 #include "jni/GURLUtils_jni.h" | 8 #include "jni/GURLUtils_jni.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
| 11 using base::android::JavaParamRef; |
| 12 using base::android::ScopedJavaLocalRef; |
| 13 |
11 namespace net { | 14 namespace net { |
12 | 15 |
13 ScopedJavaLocalRef<jstring> GetOrigin(JNIEnv* env, | 16 ScopedJavaLocalRef<jstring> GetOrigin(JNIEnv* env, |
14 const JavaParamRef<jclass>& clazz, | 17 const JavaParamRef<jclass>& clazz, |
15 const JavaParamRef<jstring>& url) { | 18 const JavaParamRef<jstring>& url) { |
16 GURL host(base::android::ConvertJavaStringToUTF16(env, url)); | 19 GURL host(base::android::ConvertJavaStringToUTF16(env, url)); |
17 | 20 |
18 return base::android::ConvertUTF8ToJavaString(env, host.GetOrigin().spec()); | 21 return base::android::ConvertUTF8ToJavaString(env, host.GetOrigin().spec()); |
19 } | 22 } |
20 | 23 |
21 ScopedJavaLocalRef<jstring> GetScheme(JNIEnv* env, | 24 ScopedJavaLocalRef<jstring> GetScheme(JNIEnv* env, |
22 const JavaParamRef<jclass>& clazz, | 25 const JavaParamRef<jclass>& clazz, |
23 const JavaParamRef<jstring>& url) { | 26 const JavaParamRef<jstring>& url) { |
24 GURL host(base::android::ConvertJavaStringToUTF16(env, url)); | 27 GURL host(base::android::ConvertJavaStringToUTF16(env, url)); |
25 | 28 |
26 return base::android::ConvertUTF8ToJavaString(env, host.scheme()); | 29 return base::android::ConvertUTF8ToJavaString(env, host.scheme()); |
27 } | 30 } |
28 | 31 |
29 bool RegisterGURLUtils(JNIEnv* env) { | 32 bool RegisterGURLUtils(JNIEnv* env) { |
30 return RegisterNativesImpl(env); | 33 return RegisterNativesImpl(env); |
31 } | 34 } |
32 | 35 |
33 } // net namespace | 36 } // net namespace |
OLD | NEW |