diff options
author | newt <newt@chromium.org> | 2015-03-31 17:01:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-01 00:02:37 +0000 |
commit | c8f0aa553ef5e7b329131a68f4896ad93149f37b (patch) | |
tree | 1904dd878130ca6f4f7717f1b3acd0fa227c4cf6 | |
parent | 5557a417ceec6573401493c0760ff914e75795a8 (diff) | |
download | chromium_src-c8f0aa553ef5e7b329131a68f4896ad93149f37b.zip chromium_src-c8f0aa553ef5e7b329131a68f4896ad93149f37b.tar.gz chromium_src-c8f0aa553ef5e7b329131a68f4896ad93149f37b.tar.bz2 |
Delete fixUrl() and replace calls with fixupUrl().
These methods are almost identical, so fixUrl() is being removed. The
only important difference is that fixupUrl() requires native to be
loaded.
BUG=471931
Review URL: https://codereview.chromium.org/1042163004
Cr-Commit-Position: refs/heads/master@{#323147}
3 files changed, 8 insertions, 68 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 ce2ad72..1eca2c9 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/UrlUtilities.java @@ -118,51 +118,16 @@ public class UrlUtilities { } /** - * @param uri A URI to repair. + * Refer to url_fixer::FixupURL. * - * @return A String representation of a URI that will be valid for loading in a ContentView. - */ - public static String fixUrl(String uri) { - if (uri == null) return null; - - try { - String fixedUri = uri.trim(); - if (fixedUri.indexOf("://") == 0) { - return "http" + fixedUri; - } - if (fixedUri.indexOf(":") == -1) { - return "http://" + fixedUri; - } - - URI parsed = new URI(fixedUri); - if (parsed.getScheme() == null) { - parsed = new URI( - "http", - null, // userInfo - parsed.getHost(), - parsed.getPort(), - parsed.getRawPath(), - parsed.getRawQuery(), - parsed.getRawFragment()); - } - return parsed.toString(); - } catch (URISyntaxException e) { - // Can't do anything. - return uri; - } - } - - /** - * 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". + * Given a URL-like string, returns a real URL or null. For example: + * - "google.com" -> "http://google.com/" + * - "about:" -> "chrome://version/" + * - "//mail.google.com:/" -> "file:///mail.google.com:/" + * - "..." -> null */ public static String fixupUrl(String uri) { - if (TextUtils.isEmpty(uri)) return uri; + if (TextUtils.isEmpty(uri)) return null; return nativeFixupUrl(uri, null); } diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/HomepagePreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/HomepagePreferences.java index 0802c33..310f78d 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/HomepagePreferences.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/HomepagePreferences.java @@ -144,8 +144,7 @@ public class HomepagePreferences extends Fragment { @Override public void onStop() { super.onStop(); - mHomepageManager.setPrefHomepageCustomUri( - UrlUtilities.fixUrl(UrlUtilities.fixupUrl(mCustomUriCache))); + mHomepageManager.setPrefHomepageCustomUri(UrlUtilities.fixupUrl(mCustomUriCache)); } } diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java index 5995cc2..d40403d 100644 --- a/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java @@ -10,7 +10,6 @@ import android.test.suitebuilder.annotation.SmallTest; import org.chromium.base.test.util.Feature; import java.net.URI; -import java.net.URISyntaxException; public class UrlUtilitiesTest extends InstrumentationTestCase { @SmallTest @@ -72,29 +71,6 @@ public class UrlUtilitiesTest extends InstrumentationTestCase { } @SmallTest - public void testFixUrl() throws URISyntaxException { - try { - URI uri; - uri = new URI(UrlUtilities.fixUrl("google.com")); - assertTrue("http".equals(uri.getScheme())); - uri = new URI(UrlUtilities.fixUrl("\n://user:pass@example.com:80/")); - assertTrue("http".equals(uri.getScheme())); - uri = new URI(UrlUtilities.fixUrl("inline:google.com")); - assertTrue("inline".equals(uri.getScheme())); - uri = new URI(UrlUtilities.fixUrl("chrome:user:pass@google:443/leg:foot")); - assertTrue("chrome".equals(uri.getScheme())); - uri = new URI(UrlUtilities.fixUrl("https://mail.google.com:/")); - assertTrue("https".equals(uri.getScheme())); - uri = new URI(UrlUtilities.fixUrl("://mail.google.com:/")); - assertTrue("http".equals(uri.getScheme())); - uri = new URI(UrlUtilities.fixUrl("//mail.google.com:/")); - assertTrue("http".equals(uri.getScheme())); - } catch (URISyntaxException e) { - assertFalse(true); - } - } - - @SmallTest @Feature({"Webapps"}) public void testGetOriginForDisplay() { URI uri; |