| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/android/jni_android.h" | 5 #include "base/android/jni_android.h" |
| 6 #include "base/android/jni_string.h" | 6 #include "base/android/jni_string.h" |
| 7 #include "chrome/browser/google/google_util.h" | 7 #include "chrome/browser/google/google_util.h" |
| 8 #include "components/url_fixer/url_fixer.h" | 8 #include "components/url_fixer/url_fixer.h" |
| 9 #include "jni/UrlUtilities_jni.h" | 9 #include "jni/UrlUtilities_jni.h" |
| 10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 10 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 jstring desired_tld) { | 76 jstring desired_tld) { |
| 77 GURL fixed_url = url_fixer::FixupURL( | 77 GURL fixed_url = url_fixer::FixupURL( |
| 78 base::android::ConvertJavaStringToUTF8(env, url), | 78 base::android::ConvertJavaStringToUTF8(env, url), |
| 79 base::android::ConvertJavaStringToUTF8(env, desired_tld)); | 79 base::android::ConvertJavaStringToUTF8(env, desired_tld)); |
| 80 | 80 |
| 81 return fixed_url.is_valid() ? | 81 return fixed_url.is_valid() ? |
| 82 base::android::ConvertUTF8ToJavaString(env, fixed_url.spec()).Release() : | 82 base::android::ConvertUTF8ToJavaString(env, fixed_url.spec()).Release() : |
| 83 NULL; | 83 NULL; |
| 84 } | 84 } |
| 85 | 85 |
| 86 static jboolean IsGooglePropertyUrl(JNIEnv* env, jclass clazz, jstring url) { |
| 87 const GURL gurl = GURL(ConvertJavaStringToUTF8(env, url)); |
| 88 if (gurl.is_empty() || !gurl.is_valid()) |
| 89 return false; |
| 90 return |
| 91 google_util::IsGoogleDomainUrl( |
| 92 gurl, |
| 93 google_util::ALLOW_SUBDOMAIN, |
| 94 google_util::DISALLOW_NON_STANDARD_PORTS) || |
| 95 google_util::IsYoutubeDomainUrl( |
| 96 gurl, |
| 97 google_util::ALLOW_SUBDOMAIN, |
| 98 google_util::DISALLOW_NON_STANDARD_PORTS); |
| 99 } |
| 100 |
| 86 // Register native methods | 101 // Register native methods |
| 87 bool RegisterUrlUtilities(JNIEnv* env) { | 102 bool RegisterUrlUtilities(JNIEnv* env) { |
| 88 return RegisterNativesImpl(env); | 103 return RegisterNativesImpl(env); |
| 89 } | 104 } |
| OLD | NEW |