| Index: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
|
| index d66b67a895749d92f06cd713b45aa8d089e18ff1..cc0b913baf95757e5c0d350c388a019a8c3e7aaa 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProvider.java
|
| @@ -95,7 +95,14 @@
|
| }
|
|
|
| private void updateCachedEngineName() {
|
| - SearchWidgetProvider.updateCachedEngineName();
|
| + assert LibraryLoader.isInitialized();
|
| +
|
| + // Getting an instance of the TemplateUrlService requires that the native library be
|
| + // loaded, but the TemplateUrlService also itself needs to be initialized.
|
| + TemplateUrlService service = TemplateUrlService.getInstance();
|
| + assert service.isLoaded();
|
| + SearchWidgetProvider.updateCachedEngineName(
|
| + service.getDefaultSearchEngineTemplateUrl().getShortName());
|
| }
|
| }
|
|
|
| @@ -113,7 +120,7 @@
|
| "org.chromium.chrome.browser.searchwidget.IS_VOICE_SEARCH_AVAILABLE";
|
| private static final String PREF_NUM_CONSECUTIVE_CRASHES =
|
| "org.chromium.chrome.browser.searchwidget.NUM_CONSECUTIVE_CRASHES";
|
| - static final String PREF_SEARCH_ENGINE_SHORTNAME =
|
| + private static final String PREF_SEARCH_ENGINE_SHORTNAME =
|
| "org.chromium.chrome.browser.searchwidget.SEARCH_ENGINE_SHORTNAME";
|
|
|
| /** Number of consecutive crashes this widget will absorb before giving up. */
|
| @@ -256,7 +263,7 @@
|
| }
|
|
|
| // Update what string is displayed by the widget.
|
| - String text = TextUtils.isEmpty(engineName) || !shouldShowFullString()
|
| + String text = TextUtils.isEmpty(engineName)
|
| ? context.getString(R.string.search_widget_default)
|
| : context.getString(R.string.search_with_product, engineName);
|
| views.setTextViewText(R.id.title, text);
|
| @@ -279,19 +286,6 @@
|
| prefs.edit().putBoolean(PREF_IS_VOICE_SEARCH_AVAILABLE, isVoiceSearchAvailable).apply();
|
| performUpdate(null);
|
| }
|
| - }
|
| -
|
| - /** Attempts to update the cached search engine name. */
|
| - public static void updateCachedEngineName() {
|
| - ThreadUtils.assertOnUiThread();
|
| - if (!LibraryLoader.isInitialized()) return;
|
| -
|
| - // Getting an instance of the TemplateUrlService requires that the native library be
|
| - // loaded, but the TemplateUrlService also itself needs to be initialized.
|
| - TemplateUrlService service = TemplateUrlService.getInstance();
|
| - if (!service.isLoaded()) return;
|
| -
|
| - updateCachedEngineName(service.getDefaultSearchEngineTemplateUrl().getShortName());
|
| }
|
|
|
| /**
|
| @@ -301,9 +295,6 @@
|
| */
|
| static void updateCachedEngineName(String engineName) {
|
| SharedPreferences prefs = getDelegate().getSharedPreferences();
|
| -
|
| - if (!shouldShowFullString()) engineName = null;
|
| -
|
| if (!TextUtils.equals(getCachedEngineName(prefs), engineName)) {
|
| prefs.edit().putString(PREF_SEARCH_ENGINE_SHORTNAME, engineName).apply();
|
| performUpdate(null);
|
| @@ -371,12 +362,6 @@
|
| }
|
| }
|
|
|
| - static boolean shouldShowFullString() {
|
| - Intent freIntent = FirstRunFlowSequencer.checkIfFirstRunIsNecessary(
|
| - getDelegate().getContext(), null, false);
|
| - return freIntent == null;
|
| - }
|
| -
|
| /** Sets an {@link SearchWidgetProviderDelegate} to interact with. */
|
| @VisibleForTesting
|
| static void setDelegateForTest(SearchWidgetProviderDelegate delegate) {
|
|
|