Commit 7503ea1c authored by aruslan@chromium.org's avatar aruslan@chromium.org

[Android] Expose more GoogleUtils to Java.

BUG=382309
NOTRY=True

Review URL: https://codereview.chromium.org/346753004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278863 0039d316-1c4b-4281-b951-d872f2087c98
parent 5466a08b
...@@ -197,6 +197,15 @@ public class UrlUtilities { ...@@ -197,6 +197,15 @@ public class UrlUtilities {
return nativeGetDomainAndRegistry(uri, includePrivateRegistries); return nativeGetDomainAndRegistry(uri, includePrivateRegistries);
} }
/**
* @param url A URL.
* @return Whether a given URL is one of [...]google.TLD or [...]youtube.TLD URLs.
*/
public static boolean isGooglePropertyUrl(String url) {
if (TextUtils.isEmpty(url)) return false;
return nativeIsGooglePropertyUrl(url);
}
private static native boolean nativeSameDomainOrHost(String primaryUrl, String secondaryUrl, private static native boolean nativeSameDomainOrHost(String primaryUrl, String secondaryUrl,
boolean includePrivateRegistries); boolean includePrivateRegistries);
private static native String nativeGetDomainAndRegistry(String url, private static native String nativeGetDomainAndRegistry(String url,
...@@ -204,4 +213,5 @@ public class UrlUtilities { ...@@ -204,4 +213,5 @@ public class UrlUtilities {
public static native boolean nativeIsGoogleSearchUrl(String url); public static native boolean nativeIsGoogleSearchUrl(String url);
public static native boolean nativeIsGoogleHomePageUrl(String url); public static native boolean nativeIsGoogleHomePageUrl(String url);
public static native String nativeFixupUrl(String url, String desiredTld); public static native String nativeFixupUrl(String url, String desiredTld);
private static native boolean nativeIsGooglePropertyUrl(String url);
} }
...@@ -83,6 +83,21 @@ static jstring FixupUrl(JNIEnv* env, ...@@ -83,6 +83,21 @@ static jstring FixupUrl(JNIEnv* env,
NULL; NULL;
} }
static jboolean IsGooglePropertyUrl(JNIEnv* env, jclass clazz, jstring url) {
const GURL gurl = GURL(ConvertJavaStringToUTF8(env, url));
if (gurl.is_empty() || !gurl.is_valid())
return false;
return
google_util::IsGoogleDomainUrl(
gurl,
google_util::ALLOW_SUBDOMAIN,
google_util::DISALLOW_NON_STANDARD_PORTS) ||
google_util::IsYoutubeDomainUrl(
gurl,
google_util::ALLOW_SUBDOMAIN,
google_util::DISALLOW_NON_STANDARD_PORTS);
}
// Register native methods // Register native methods
bool RegisterUrlUtilities(JNIEnv* env) { bool RegisterUrlUtilities(JNIEnv* env) {
return RegisterNativesImpl(env); return RegisterNativesImpl(env);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment