diff options
author | John Reck <jreck@google.com> | 2011-07-01 16:49:28 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2011-07-01 16:49:28 -0700 |
commit | 71e5142e4237a0f9d51a93504da36b778e8b79e4 (patch) | |
tree | a44fb774ffa3f78d520627c3f5ef4cf9cfefe72c | |
parent | 2bc8042224be51966d748b870768ec1b376a1621 (diff) | |
download | packages_apps_Browser-71e5142e4237a0f9d51a93504da36b778e8b79e4.zip packages_apps_Browser-71e5142e4237a0f9d51a93504da36b778e8b79e4.tar.gz packages_apps_Browser-71e5142e4237a0f9d51a93504da36b778e8b79e4.tar.bz2 |
Shortcut the TYPED url case
Bug: 4985289
Don't go through the handleIntent route if the user typed
something into the omnibox if we don't need to.
Change-Id: I4de8e18c1ca734a0c6bfbca43c9448417cec2057
-rw-r--r-- | src/com/android/browser/Controller.java | 3 | ||||
-rw-r--r-- | src/com/android/browser/TitleBarBase.java | 10 | ||||
-rw-r--r-- | src/com/android/browser/UiController.java | 2 | ||||
-rw-r--r-- | src/com/android/browser/UrlUtils.java | 28 |
4 files changed, 34 insertions, 9 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 88fcbd6..3398af0 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -2348,7 +2348,8 @@ public class Controller * @param view The WebView used to load url. * @param url The URL to load. */ - protected void loadUrl(Tab tab, String url) { + @Override + public void loadUrl(Tab tab, String url) { loadUrl(tab, url, null); } diff --git a/src/com/android/browser/TitleBarBase.java b/src/com/android/browser/TitleBarBase.java index c7fb9c6..ae11038 100644 --- a/src/com/android/browser/TitleBarBase.java +++ b/src/com/android/browser/TitleBarBase.java @@ -554,7 +554,15 @@ public class TitleBarBase extends RelativeLayout @Override public void onAction(String text, String extra, String source) { mUiController.getCurrentTopWebView().requestFocus(); - mBaseUi.hideTitleBar(); + if (UrlInputView.TYPED.equals(source)) { + String url = UrlUtils.smartUrlFilter(text, false); + Tab t = mBaseUi.getActiveTab(); + if (url != null && t != null) { + mUiController.loadUrl(t, url); + setDisplayTitle(text); + return; + } + } Intent i = new Intent(); String action = null; if (UrlInputView.VOICE.equals(source)) { diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java index 4550a8a..6045d86 100644 --- a/src/com/android/browser/UiController.java +++ b/src/com/android/browser/UiController.java @@ -99,4 +99,6 @@ public interface UiController extends BookmarksHistoryCallbacks { SnapshotTab createNewSnapshotTab(long snapshotId, boolean setActive); + void loadUrl(Tab tab, String url); + } diff --git a/src/com/android/browser/UrlUtils.java b/src/com/android/browser/UrlUtils.java index 26f8e0e..c922e55 100644 --- a/src/com/android/browser/UrlUtils.java +++ b/src/com/android/browser/UrlUtils.java @@ -85,7 +85,22 @@ public class UrlUtils { * */ public static String smartUrlFilter(String url) { + return smartUrlFilter(url, true); + } + /** + * Attempts to determine whether user input is a URL or search + * terms. Anything with a space is passed to search if canBeSearch is true. + * + * Converts to lowercase any mistakenly uppercased schema (i.e., + * "Http://" converts to "http://" + * + * @param canBeSearch If true, will return a search url if it isn't a valid + * URL. If false, invalid URLs will return null + * @return Original or modified URL + * + */ + public static String smartUrlFilter(String url, boolean canBeSearch) { String inUrl = url.trim(); boolean hasSpace = inUrl.indexOf(' ') != -1; @@ -97,7 +112,7 @@ public class UrlUtils { if (!lcScheme.equals(scheme)) { inUrl = lcScheme + matcher.group(2); } - if (hasSpace) { + if (hasSpace && Patterns.WEB_URL.matcher(inUrl).matches()) { inUrl = inUrl.replace(" ", "%20"); } return inUrl; @@ -107,12 +122,11 @@ public class UrlUtils { return URLUtil.guessUrl(inUrl); } } - - // FIXME: Is this the correct place to add to searches? - // what if someone else calls this function? - -// Browser.addSearchUrl(mBrowser.getContentResolver(), inUrl); - return URLUtil.composeSearchUrl(inUrl, QUICKSEARCH_G, QUERY_PLACE_HOLDER); + if (canBeSearch) { + return URLUtil.composeSearchUrl(inUrl, + QUICKSEARCH_G, QUERY_PLACE_HOLDER); + } + return null; } /* package */ static String fixUrl(String inUrl) { |