Avi Drissman | 6459548 | 2022-09-14 20:52:29 | [diff] [blame^] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | d72acb0 | 2012-12-15 22:19:44 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | d72acb0 | 2012-12-15 22:19:44 | [diff] [blame] | 5 | #include "base/android/jni_string.h" |
Mohamed Heikal | 5880044 | 2019-06-22 00:19:48 | [diff] [blame] | 6 | #include "net/net_jni_headers/GURLUtils_jni.h" |
[email protected] | f89276a7 | 2013-07-12 06:41:54 | [diff] [blame] | 7 | #include "url/gurl.h" |
[email protected] | d72acb0 | 2012-12-15 22:19:44 | [diff] [blame] | 8 | |
torne | 8656011 | 2016-08-04 15:59:04 | [diff] [blame] | 9 | using base::android::JavaParamRef; |
10 | using base::android::ScopedJavaLocalRef; | ||||
11 | |||||
[email protected] | d72acb0 | 2012-12-15 22:19:44 | [diff] [blame] | 12 | namespace net { |
13 | |||||
Daniel Bratell | 7aacf95 | 2017-11-21 17:51:25 | [diff] [blame] | 14 | ScopedJavaLocalRef<jstring> JNI_GURLUtils_GetOrigin( |
15 | JNIEnv* env, | ||||
Daniel Bratell | 7aacf95 | 2017-11-21 17:51:25 | [diff] [blame] | 16 | const JavaParamRef<jstring>& url) { |
[email protected] | d72acb0 | 2012-12-15 22:19:44 | [diff] [blame] | 17 | GURL host(base::android::ConvertJavaStringToUTF16(env, url)); |
18 | |||||
Mike West | 800532c | 2021-10-14 09:26:52 | [diff] [blame] | 19 | return base::android::ConvertUTF8ToJavaString( |
20 | env, host.DeprecatedGetOriginAsURL().spec()); | ||||
[email protected] | d72acb0 | 2012-12-15 22:19:44 | [diff] [blame] | 21 | } |
22 | |||||
bnc | d479b3c | 2017-05-24 18:54:53 | [diff] [blame] | 23 | } // namespace net |