summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/browser/Controller.java3
-rw-r--r--src/com/android/browser/TitleBarBase.java10
-rw-r--r--src/com/android/browser/UiController.java2
-rw-r--r--src/com/android/browser/UrlUtils.java28
4 files changed, 34 insertions, 9 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index fa1a02b..2e66c84 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -2349,7 +2349,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) {