diff options
author | kkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-27 03:47:18 +0000 |
---|---|---|
committer | kkimlabs@chromium.org <kkimlabs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-27 03:47:18 +0000 |
commit | f72879c625e0a38dbc6ae458a7dcc0228eba004a (patch) | |
tree | 30912dec3d2e0fe3edda6f05313cb54d79e049fa | |
parent | 31f567744853cda4af9fbe0c6e253396ec651f8d (diff) | |
download | chromium_src-f72879c625e0a38dbc6ae458a7dcc0228eba004a.zip chromium_src-f72879c625e0a38dbc6ae458a7dcc0228eba004a.tar.gz chromium_src-f72879c625e0a38dbc6ae458a7dcc0228eba004a.tar.bz2 |
[Android] URLFixerUpper::FixupURL(...) JNI binding for homepage url fixup.
BUG=318901
Review URL: https://codereview.chromium.org/75303003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237495 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java | 14 | ||||
-rw-r--r-- | chrome/browser/android/url_utilities.cc | 13 |
2 files changed, 27 insertions, 0 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java b/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java index 6bcb74b..00c6347 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java @@ -110,6 +110,19 @@ public class UrlUtilities { } /** + * Refer to UrlFixerUpper::FixupURL. + * + * Compare to {@link #fixUrl(String)}, This fixes URL more aggressively including Chrome + * specific cases. For example, "about:" becomes "chrome://version/". However, this is not a + * superset of {@link #fixUrl(String)} either. For example, this function doesn't do anything + * with "://mail.google.com:/", while the other one prepends "http". Also, for + * "//mail.google.com:/", this function prepends "file" while the other one prepends "http". + */ + public static String fixupUrl(String uri) { + return nativeFixupUrl(uri, null); + } + + /** * Builds a String that strips down the URL to the its scheme, host, and port. * @param uri URI to break down. * @param showScheme Whether or not to show the scheme. If the URL can't be parsed, this value @@ -190,4 +203,5 @@ public class UrlUtilities { boolean includePrivateRegistries); public static native boolean nativeIsGoogleSearchUrl(String url); public static native boolean nativeIsGoogleHomePageUrl(String url); + public static native String nativeFixupUrl(String url, String desiredTld); } diff --git a/chrome/browser/android/url_utilities.cc b/chrome/browser/android/url_utilities.cc index 5acd960..85c04b9 100644 --- a/chrome/browser/android/url_utilities.cc +++ b/chrome/browser/android/url_utilities.cc @@ -5,6 +5,7 @@ #include "base/android/jni_android.h" #include "base/android/jni_string.h" #include "chrome/browser/google/google_util.h" +#include "chrome/common/net/url_fixer_upper.h" #include "jni/UrlUtilities_jni.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "url/gurl.h" @@ -69,6 +70,18 @@ static jboolean IsGoogleHomePageUrl(JNIEnv* env, jclass clazz, jstring url) { return google_util::IsGoogleHomePageUrl(gurl); } +static jstring FixupUrl(JNIEnv* env, + jclass clazz, + jstring url, + jstring desired_tld) { + GURL fixed_url = URLFixerUpper::FixupURL( + base::android::ConvertJavaStringToUTF8(env, url), + base::android::ConvertJavaStringToUTF8(env, desired_tld)); + + return base::android::ConvertUTF8ToJavaString(env, fixed_url.spec()) + .Release(); +} + // Register native methods bool RegisterUrlUtilities(JNIEnv* env) { return RegisterNativesImpl(env); |