| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.omnibox; | 5 package org.chromium.chrome.browser.omnibox; |
| 6 | 6 |
| 7 import android.os.Bundle; | 7 import android.os.Bundle; |
| 8 import android.text.TextUtils; | 8 import android.text.TextUtils; |
| 9 | 9 |
| 10 import org.chromium.base.VisibleForTesting; | 10 import org.chromium.base.VisibleForTesting; |
| 11 import org.chromium.base.annotations.CalledByNative; | 11 import org.chromium.base.annotations.CalledByNative; |
| 12 import org.chromium.chrome.browser.WarmupManager; |
| 13 import org.chromium.chrome.browser.ntp.NewTabPage; |
| 12 import org.chromium.chrome.browser.omnibox.OmniboxSuggestion.MatchClassification
; | 14 import org.chromium.chrome.browser.omnibox.OmniboxSuggestion.MatchClassification
; |
| 13 import org.chromium.chrome.browser.omnibox.VoiceSuggestionProvider.VoiceResult; | 15 import org.chromium.chrome.browser.omnibox.VoiceSuggestionProvider.VoiceResult; |
| 14 import org.chromium.chrome.browser.profiles.Profile; | 16 import org.chromium.chrome.browser.profiles.Profile; |
| 15 import org.chromium.content_public.browser.WebContents; | 17 import org.chromium.content_public.browser.WebContents; |
| 16 | 18 |
| 17 import java.util.ArrayList; | 19 import java.util.ArrayList; |
| 18 import java.util.List; | 20 import java.util.List; |
| 19 | 21 |
| 20 /** | 22 /** |
| 21 * Bridge to the native AutocompleteControllerAndroid. | 23 * Bridge to the native AutocompleteControllerAndroid. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 * | 154 * |
| 153 * @param profile The profile to use for starting the AutocompleteController
. | 155 * @param profile The profile to use for starting the AutocompleteController
. |
| 154 * @param omniboxText The text displayed in the omnibox. | 156 * @param omniboxText The text displayed in the omnibox. |
| 155 * @param url The url of the currently loaded web page. | 157 * @param url The url of the currently loaded web page. |
| 156 * @param focusedFromFakebox Whether the user entered the omnibox by tapping
the fakebox on the | 158 * @param focusedFromFakebox Whether the user entered the omnibox by tapping
the fakebox on the |
| 157 * native NTP. This should be false on all other p
ages. | 159 * native NTP. This should be false on all other p
ages. |
| 158 */ | 160 */ |
| 159 public void startZeroSuggest(Profile profile, String omniboxText, String url
, | 161 public void startZeroSuggest(Profile profile, String omniboxText, String url
, |
| 160 boolean focusedFromFakebox) { | 162 boolean focusedFromFakebox) { |
| 161 if (profile == null || TextUtils.isEmpty(url)) return; | 163 if (profile == null || TextUtils.isEmpty(url)) return; |
| 164 |
| 165 if (!NewTabPage.isNTPUrl(url)) { |
| 166 // Proactively start up a renderer, to reduce the time to display se
arch results, |
| 167 // especially if a Service Worker is used. |
| 168 WarmupManager.getInstance().createSpareRenderProcessHost(profile); |
| 169 } |
| 162 mNativeAutocompleteControllerAndroid = nativeInit(profile); | 170 mNativeAutocompleteControllerAndroid = nativeInit(profile); |
| 163 if (mNativeAutocompleteControllerAndroid != 0) { | 171 if (mNativeAutocompleteControllerAndroid != 0) { |
| 164 if (mUseCachedZeroSuggestResults) mWaitingForSuggestionsToCache = tr
ue; | 172 if (mUseCachedZeroSuggestResults) mWaitingForSuggestionsToCache = tr
ue; |
| 165 nativeOnOmniboxFocused( | 173 nativeOnOmniboxFocused( |
| 166 mNativeAutocompleteControllerAndroid, omniboxText, url, focu
sedFromFakebox); | 174 mNativeAutocompleteControllerAndroid, omniboxText, url, focu
sedFromFakebox); |
| 167 } | 175 } |
| 168 } | 176 } |
| 169 | 177 |
| 170 /** | 178 /** |
| 171 * Stops generating autocomplete suggestions for the currently specified tex
t from | 179 * Stops generating autocomplete suggestions for the currently specified tex
t from |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 * @param query The query to be expanded into a fully qualified URL if appro
priate. | 378 * @param query The query to be expanded into a fully qualified URL if appro
priate. |
| 371 * @return The fully qualified URL or null. | 379 * @return The fully qualified URL or null. |
| 372 */ | 380 */ |
| 373 public static native String nativeQualifyPartialURLQuery(String query); | 381 public static native String nativeQualifyPartialURLQuery(String query); |
| 374 | 382 |
| 375 /** | 383 /** |
| 376 * Sends a zero suggest request to the server in order to pre-populate the r
esult cache. | 384 * Sends a zero suggest request to the server in order to pre-populate the r
esult cache. |
| 377 */ | 385 */ |
| 378 public static native void nativePrefetchZeroSuggestResults(); | 386 public static native void nativePrefetchZeroSuggestResults(); |
| 379 } | 387 } |
| OLD | NEW |