Bug 995347 - Allow domain auto completion when entering "h" in url bar. r=bnicholson
authorAnuj Sahai <sahai.anuj16@gmail.com>
Thu, 17 Apr 2014 01:23:03 +0530
changeset 179821 08928202c32b405d1db5fc64752f5135567851cb
parent 179787 5010b38abf18590cb17cf35e0cfaa933579cd748
child 179822 1c075c91c7bf3dbf523dff4b1d237476d2d55743
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersbnicholson
bugs995347
milestone31.0a1
Bug 995347 - Allow domain auto completion when entering "h" in url bar. r=bnicholson
mobile/android/base/home/BrowserSearch.java
--- a/mobile/android/base/home/BrowserSearch.java
+++ b/mobile/android/base/home/BrowserSearch.java
@@ -74,16 +74,20 @@ public class BrowserSearch extends HomeF
 
     // Maximum number of results returned by the suggestion client
     private static final int SUGGESTION_MAX = 3;
 
     // The maximum number of rows deep in a search we'll dig
     // for an autocomplete result
     private static final int MAX_AUTOCOMPLETE_SEARCH = 20;
 
+    // Length of https:// + 1 required to make autocomplete
+    // fill in the domain, for both http:// and https://
+    private static final int HTTPS_PREFIX_LENGTH = 9;
+
     // Duration for fade-in animation
     private static final int ANIMATION_DURATION = 250;
 
     // Holds the current search term to use in the query
     private volatile String mSearchTerm;
 
     // Adapter for the list of search results
     private SearchAdapter mAdapter;
@@ -413,17 +417,18 @@ public class BrowserSearch extends HomeF
             if (searchCount == 0) {
                 // Prefetch the first item in the list since it's weighted the highest
                 GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Session:Prefetch", url.toString()));
             }
 
             // Does the completion match against the whole URL? This will match
             // about: pages, as well as user input including "http://...".
             if (url.startsWith(searchTerm)) {
-                return uriSubstringUpToMatchedPath(url, 0, searchLength);
+                return uriSubstringUpToMatchedPath(url, 0,
+                        (searchLength > HTTPS_PREFIX_LENGTH) ? searchLength : HTTPS_PREFIX_LENGTH);
             }
 
             final Uri uri = Uri.parse(url);
             final String host = uri.getHost();
 
             // Host may be null for about pages.
             if (host == null) {
                 continue;