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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java

Issue 1357563002: Expose FormatUrlForSecurityDisplay to Java on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Using a fake scheme in the test makes formatUrlForSecurityDisplay be conservative, breaking the tes… Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java
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 bbd359fdfd80d75dea256ea5aafd5e7c356194ba..27ed1dd7db83ca38abe37651a44f790ccc07194d 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java
@@ -147,30 +147,12 @@ public class UrlUtilities {
* @return Stripped-down String containing the essential bits of the URL, or the original URL if
* it fails to parse it.
*/
- public static String getOriginForDisplay(URI uri, boolean showScheme) {
- String scheme = uri.getScheme();
- String host = uri.getHost();
- int port = uri.getPort();
-
- String displayUrl;
- if (TextUtils.isEmpty(scheme) || TextUtils.isEmpty(host)) {
- displayUrl = uri.toString();
+ public static String formatUrlForSecurityDisplay(URI uri, boolean showScheme) {
+ if (showScheme) {
+ return nativeFormatUrlForSecurityDisplay(uri.toString());
} else {
- if (showScheme) {
- scheme += "://";
- } else {
- scheme = "";
- }
-
- if (port == -1 || (port == 80 && "http".equals(scheme))
- || (port == 443 && "https".equals(scheme))) {
- displayUrl = scheme + host;
- } else {
- displayUrl = scheme + host + ":" + port;
- }
+ return nativeFormatUrlForSecurityDisplayOmitScheme(uri.toString());
}
-
- return displayUrl;
}
/**
@@ -380,5 +362,7 @@ public class UrlUtilities {
boolean includePrivateRegistries);
public static native boolean nativeIsGoogleSearchUrl(String url);
public static native boolean nativeIsGoogleHomePageUrl(String url);
+ public static native String nativeFormatUrlForSecurityDisplay(String url);
+ public static native String nativeFormatUrlForSecurityDisplayOmitScheme(String url);
private static native String nativeFixupUrl(String url, String desiredTld);
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/WebsiteSettingsPopup.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698