Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java |
| index d73eca445f83090e79e0ed682b2c6f695dca7395..69e8164c87b72223048076c50a3ad15d2ebd1a40 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java |
| @@ -19,6 +19,7 @@ import org.chromium.chrome.browser.WebContentsFactory; |
| import org.chromium.chrome.browser.WindowDelegate; |
| import org.chromium.chrome.browser.customtabs.CustomTabsConnection; |
| import org.chromium.chrome.browser.init.AsyncInitializationActivity; |
| +import org.chromium.chrome.browser.locale.LocaleManager; |
| import org.chromium.chrome.browser.omnibox.AutocompleteController; |
| import org.chromium.chrome.browser.snackbar.SnackbarManager; |
| import org.chromium.chrome.browser.snackbar.SnackbarManager.SnackbarManageable; |
| @@ -37,6 +38,16 @@ public class SearchActivity extends AsyncInitializationActivity |
| /** Setting this field causes the Activity to finish itself immediately for tests. */ |
| private static boolean sIsDisabledForTest; |
| + /** Run when the SearchActivity knows what info it needs to display to the user. */ |
| + private final Runnable mSearchEngineAvailableRunnable = new Runnable() { |
| + @Override |
| + public void run() { |
| + AutocompleteController.nativePrefetchZeroSuggestResults(); |
| + CustomTabsConnection.getInstance(getApplication()).warmup(0); |
|
Ted C
2017/04/26 20:21:52
wha?
gone
2017/04/26 21:45:15
/me shrugs. It was already there. It's been push
|
| + mSearchBox.onDeferredStartup(isVoiceSearchIntent()); |
| + } |
| + }; |
| + |
| /** Main content view. */ |
| private ViewGroup mContentView; |
| @@ -89,6 +100,10 @@ public class SearchActivity extends AsyncInitializationActivity |
| setContentView(mContentView); |
| // Kick off everything needed for the user to type into the box. |
| + // TODO(dfalcantara): We should prevent the user from doing anything while we're running the |
| + // logic to determine if they need to see a search engine promo. Given |
| + // that the logic requires native to be loaded, we'll have to make some |
| + // easy Java-only first-pass checks. |
| beginQuery(); |
| mSearchBox.showCachedZeroSuggestResultsIfAvailable(); |
| @@ -130,9 +145,11 @@ public class SearchActivity extends AsyncInitializationActivity |
| public void onDeferredStartup() { |
| super.onDeferredStartup(); |
| - AutocompleteController.nativePrefetchZeroSuggestResults(); |
| - CustomTabsConnection.getInstance(getApplication()).warmup(0); |
| - mSearchBox.onDeferredStartup(isVoiceSearchIntent()); |
| + // Force the user to choose a search engine if they have to. |
| + if (!LocaleManager.getInstance().showSearchEnginePromoIfNeeded( |
| + this, mSearchEngineAvailableRunnable)) { |
| + mSearchEngineAvailableRunnable.run(); |
| + } |
| } |
| @Override |