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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; 5 package org.chromium.chrome.browser;
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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 /** 142 /**
143 * Builds a String that strips down the URL to the its scheme, host, and por t. 143 * Builds a String that strips down the URL to the its scheme, host, and por t.
144 * @param uri URI to break down. 144 * @param uri URI to break down.
145 * @param showScheme Whether or not to show the scheme. If the URL can't be parsed, this value 145 * @param showScheme Whether or not to show the scheme. If the URL can't be parsed, this value
146 * is ignored. 146 * is ignored.
147 * @return Stripped-down String containing the essential bits of the URL, or the original URL if 147 * @return Stripped-down String containing the essential bits of the URL, or the original URL if
148 * it fails to parse it. 148 * it fails to parse it.
149 */ 149 */
150 public static String getOriginForDisplay(URI uri, boolean showScheme) { 150 public static String formatUrlForSecurityDisplay(URI uri, boolean showScheme ) {
151 String scheme = uri.getScheme(); 151 if (showScheme) {
152 String host = uri.getHost(); 152 return nativeFormatUrlForSecurityDisplay(uri.toString());
153 int port = uri.getPort();
154
155 String displayUrl;
156 if (TextUtils.isEmpty(scheme) || TextUtils.isEmpty(host)) {
157 displayUrl = uri.toString();
158 } else { 153 } else {
159 if (showScheme) { 154 return nativeFormatUrlForSecurityDisplayOmitScheme(uri.toString());
160 scheme += "://";
161 } else {
162 scheme = "";
163 }
164
165 if (port == -1 || (port == 80 && "http".equals(scheme))
166 || (port == 443 && "https".equals(scheme))) {
167 displayUrl = scheme + host;
168 } else {
169 displayUrl = scheme + host + ":" + port;
170 }
171 } 155 }
172
173 return displayUrl;
174 } 156 }
175 157
176 /** 158 /**
177 * Determines whether or not the given URLs belong to the same broad domain or host. 159 * Determines whether or not the given URLs belong to the same broad domain or host.
178 * "Broad domain" is defined as the TLD + 1 or the host. 160 * "Broad domain" is defined as the TLD + 1 or the host.
179 * 161 *
180 * For example, the TLD + 1 for http://news.google.com would be "google.com" and would be shared 162 * For example, the TLD + 1 for http://news.google.com would be "google.com" and would be shared
181 * with other Google properties like http://finance.google.com. 163 * with other Google properties like http://finance.google.com.
182 * 164 *
183 * If {@code includePrivateRegistries} is marked as true, then private domai n registries (like 165 * If {@code includePrivateRegistries} is marked as true, then private domai n registries (like
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 355
374 return true; 356 return true;
375 } 357 }
376 358
377 private static native boolean nativeSameDomainOrHost(String primaryUrl, Stri ng secondaryUrl, 359 private static native boolean nativeSameDomainOrHost(String primaryUrl, Stri ng secondaryUrl,
378 boolean includePrivateRegistries); 360 boolean includePrivateRegistries);
379 private static native String nativeGetDomainAndRegistry(String url, 361 private static native String nativeGetDomainAndRegistry(String url,
380 boolean includePrivateRegistries); 362 boolean includePrivateRegistries);
381 public static native boolean nativeIsGoogleSearchUrl(String url); 363 public static native boolean nativeIsGoogleSearchUrl(String url);
382 public static native boolean nativeIsGoogleHomePageUrl(String url); 364 public static native boolean nativeIsGoogleHomePageUrl(String url);
365 public static native String nativeFormatUrlForSecurityDisplay(String url);
366 public static native String nativeFormatUrlForSecurityDisplayOmitScheme(Stri ng url);
383 private static native String nativeFixupUrl(String url, String desiredTld); 367 private static native String nativeFixupUrl(String url, String desiredTld);
384 } 368 }
OLDNEW
« 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