Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/util/UrlUtilities.java

Issue 2110543004: Move JNI bindings for url_formatter from chrome to //components/url_formatter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 package org.chromium.chrome.browser.util; 5 package org.chromium.chrome.browser.util;
6 6
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 8
9 import org.chromium.base.CollectionUtil; 9 import org.chromium.base.CollectionUtil;
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 /** 72 /**
73 * @param uri A URI. 73 * @param uri A URI.
74 * 74 *
75 * @return Whether the URI's scheme is for a internal chrome page. 75 * @return Whether the URI's scheme is for a internal chrome page.
76 */ 76 */
77 public static boolean isInternalScheme(URI uri) { 77 public static boolean isInternalScheme(URI uri) {
78 return INTERNAL_SCHEMES.contains(uri.getScheme()); 78 return INTERNAL_SCHEMES.contains(uri.getScheme());
79 } 79 }
80 80
81 /** 81 /**
82 * Refer to url_formatter::FixupURL.
83 *
84 * Given a URL-like string, returns a real URL or null. For example:
85 * - "google.com" -> "http://google.com/"
86 * - "about:" -> "chrome://version/"
87 * - "//mail.google.com:/" -> "file:///mail.google.com:/"
88 * - "..." -> null
89 */
90 public static String fixupUrl(String uri) {
91 if (TextUtils.isEmpty(uri)) return null;
92 return nativeFixupUrl(uri, null);
93 }
94
95 /**
96 * Builds a String that strips down the URL to its scheme, host, and port.
97 * @param uri URI to break down.
98 * @param showScheme Whether or not to show the scheme. If the URL can't be parsed, this value
99 * is ignored.
100 * @return Stripped-down String containing the essential bits of the URL, or the original URL if
101 * it fails to parse it.
102 */
103 public static String formatUrlForSecurityDisplay(URI uri, boolean showScheme ) {
104 return formatUrlForSecurityDisplay(uri.toString(), showScheme);
105 }
106
107 /**
108 * Builds a String that strips down |url| to its scheme, host, and port.
109 * @param uri The URI to break down.
110 * @param showScheme Whether or not to show the scheme. If the URL can't be parsed, this value
111 * is ignored.
112 * @return Stripped-down String containing the essential bits of the URL, or the original URL if
113 * it fails to parse it.
114 */
115 public static String formatUrlForSecurityDisplay(String uri, boolean showSch eme) {
116 if (showScheme) {
117 return nativeFormatUrlForSecurityDisplay(uri);
118 } else {
119 return nativeFormatUrlForSecurityDisplayOmitScheme(uri);
120 }
121 }
122 /**
123 * Determines whether or not the given URLs belong to the same broad domain or host. 82 * Determines whether or not the given URLs belong to the same broad domain or host.
124 * "Broad domain" is defined as the TLD + 1 or the host. 83 * "Broad domain" is defined as the TLD + 1 or the host.
125 * 84 *
126 * For example, the TLD + 1 for http://news.google.com would be "google.com" and would be shared 85 * For example, the TLD + 1 for http://news.google.com would be "google.com" and would be shared
127 * with other Google properties like http://finance.google.com. 86 * with other Google properties like http://finance.google.com.
128 * 87 *
129 * If {@code includePrivateRegistries} is marked as true, then private domai n registries (like 88 * If {@code includePrivateRegistries} is marked as true, then private domai n registries (like
130 * appspot.com) are considered "effective TLDs" -- all subdomains of appspot .com would be 89 * appspot.com) are considered "effective TLDs" -- all subdomains of appspot .com would be
131 * considered distinct (effective TLD = ".appspot.com" + 1). 90 * considered distinct (effective TLD = ".appspot.com" + 1).
132 * This means that http://chromiumreview.appspot.com and http://example.apps pot.com would not 91 * This means that http://chromiumreview.appspot.com and http://example.apps pot.com would not
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 private static native boolean nativeIsDownloadable(String url); 294 private static native boolean nativeIsDownloadable(String url);
336 private static native boolean nativeIsValidForIntentFallbackNavigation(Strin g url); 295 private static native boolean nativeIsValidForIntentFallbackNavigation(Strin g url);
337 private static native boolean nativeIsAcceptedScheme(String url); 296 private static native boolean nativeIsAcceptedScheme(String url);
338 private static native boolean nativeSameDomainOrHost(String primaryUrl, Stri ng secondaryUrl, 297 private static native boolean nativeSameDomainOrHost(String primaryUrl, Stri ng secondaryUrl,
339 boolean includePrivateRegistries); 298 boolean includePrivateRegistries);
340 private static native boolean nativeSameHost(String primaryUrl, String secon daryUrl); 299 private static native boolean nativeSameHost(String primaryUrl, String secon daryUrl);
341 private static native String nativeGetDomainAndRegistry(String url, 300 private static native String nativeGetDomainAndRegistry(String url,
342 boolean includePrivateRegistries); 301 boolean includePrivateRegistries);
343 public static native boolean nativeIsGoogleSearchUrl(String url); 302 public static native boolean nativeIsGoogleSearchUrl(String url);
344 public static native boolean nativeIsGoogleHomePageUrl(String url); 303 public static native boolean nativeIsGoogleHomePageUrl(String url);
345 public static native String nativeFormatUrlForSecurityDisplay(String url);
346 public static native String nativeFormatUrlForSecurityDisplayOmitScheme(Stri ng url);
347 private static native String nativeFixupUrl(String url, String desiredTld);
348 private static native boolean nativeUrlsMatchIgnoringFragments(String url, S tring url2); 304 private static native boolean nativeUrlsMatchIgnoringFragments(String url, S tring url2);
349 private static native boolean nativeUrlsFragmentsDiffer(String url, String u rl2); 305 private static native boolean nativeUrlsFragmentsDiffer(String url, String u rl2);
350 } 306 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698