LeOSium_webview/LeOS/patches/Remove-voice-recognition-in...

834 lines
44 KiB
Diff
Raw Permalink Normal View History

2023-11-18 11:46:19 +01:00
From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Sun, 19 Jun 2022 12:57:56 +0200
Subject: Remove voice recognition integration
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
.../start_surface/StartSurfaceMediator.java | 15 +----
.../features/tasks/TasksSurfaceMediator.java | 4 --
.../browser/metrics/UmaSessionStats.java | 19 ------
.../chrome/browser/ntp/NewTabPage.java | 41 +-----------
.../browser/ntp/search/SearchBoxMediator.java | 1 -
.../browser/searchwidget/SearchActivity.java | 8 +--
.../SearchActivityLocationBarLayout.java | 42 +------------
.../browser/toolbar/ToolbarManager.java | 5 --
.../chrome/browser/ui/RootUiCoordinator.java | 23 +------
chrome/browser/ui/android/omnibox/BUILD.gn | 1 -
.../chrome/browser/omnibox/LocationBar.java | 6 --
.../omnibox/LocationBarCoordinator.java | 13 ----
.../browser/omnibox/LocationBarMediator.java | 62 +------------------
.../chrome/browser/omnibox/OmniboxStub.java | 8 ---
.../suggestions/AutocompleteController.java | 21 -------
.../suggestions/AutocompleteCoordinator.java | 8 ---
.../suggestions/AutocompleteMediator.java | 9 ---
17 files changed, 11 insertions(+), 275 deletions(-)
diff --git a/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/start_surface/StartSurfaceMediator.java b/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/start_surface/StartSurfaceMediator.java
--- a/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/start_surface/StartSurfaceMediator.java
+++ b/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/start_surface/StartSurfaceMediator.java
@@ -78,7 +78,6 @@ import org.chromium.chrome.browser.ntp.NewTabPageLaunchOrigin;
import org.chromium.chrome.browser.omnibox.OmniboxFocusReason;
import org.chromium.chrome.browser.omnibox.OmniboxStub;
import org.chromium.chrome.browser.omnibox.UrlFocusChangeListener;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
@@ -543,8 +542,7 @@ class StartSurfaceMediator implements TabSwitcher.TabSwitcherViewObserver, View.
// Initialize
// Note that isVoiceSearchEnabled will return false in incognito mode.
- mPropertyModel.set(IS_VOICE_RECOGNITION_BUTTON_VISIBLE,
- mOmniboxStub.getVoiceRecognitionHandler().isVoiceSearchEnabled());
+ mPropertyModel.set(IS_VOICE_RECOGNITION_BUTTON_VISIBLE, false);
updateLensVisibility();
// This is for Instant Start when overview is already visible while the omnibox, Feed
@@ -577,13 +575,6 @@ class StartSurfaceMediator implements TabSwitcher.TabSwitcherViewObserver, View.
}
});
mPropertyModel.set(VOICE_SEARCH_BUTTON_CLICK_LISTENER, v -> {
- FeedReliabilityLogger feedReliabilityLogger = getFeedReliabilityLogger();
- if (feedReliabilityLogger != null) {
- feedReliabilityLogger.onVoiceSearch();
- }
- mOmniboxStub.getVoiceRecognitionHandler().startVoiceRecognition(
- VoiceRecognitionHandler.VoiceInteractionSource.TASKS_SURFACE);
- RecordUserAction.record("TasksSurface.FakeBox.VoiceSearch");
});
mPropertyModel.set(LENS_BUTTON_CLICK_LISTENER, v -> {
@@ -1477,10 +1468,6 @@ class StartSurfaceMediator implements TabSwitcher.TabSwitcherViewObserver, View.
// incorrect state if check synchronously.
ThreadUtils.postOnUiThread(() -> {
if (mOmniboxStub != null) {
- if (mOmniboxStub.getVoiceRecognitionHandler() != null) {
- mPropertyModel.set(IS_VOICE_RECOGNITION_BUTTON_VISIBLE,
- mOmniboxStub.getVoiceRecognitionHandler().isVoiceSearchEnabled());
- }
mPropertyModel.set(IS_LENS_BUTTON_VISIBLE,
mOmniboxStub.isLensEnabled(LensEntryPoint.TASKS_SURFACE));
}
diff --git a/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/tasks/TasksSurfaceMediator.java b/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/tasks/TasksSurfaceMediator.java
--- a/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/tasks/TasksSurfaceMediator.java
+++ b/chrome/android/features/start_surface/java/src/org/chromium/chrome/features/tasks/TasksSurfaceMediator.java
@@ -34,7 +34,6 @@ import org.chromium.chrome.browser.lens.LensMetrics;
import org.chromium.chrome.browser.ntp.IncognitoCookieControlsManager;
import org.chromium.chrome.browser.omnibox.OmniboxFocusReason;
import org.chromium.chrome.browser.omnibox.OmniboxStub;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher.TabSwitcherViewObserver;
import org.chromium.components.content_settings.CookieControlsEnforcement;
import org.chromium.ui.modelutil.PropertyModel;
@@ -107,9 +106,6 @@ class TasksSurfaceMediator implements TabSwitcherViewObserver {
if (feedReliabilityLogger != null) {
feedReliabilityLogger.onVoiceSearch();
}
- mOmniboxStub.getVoiceRecognitionHandler().startVoiceRecognition(
- VoiceRecognitionHandler.VoiceInteractionSource.TASKS_SURFACE);
- RecordUserAction.record("TasksSurface.FakeBox.VoiceSearch");
}
});
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/metrics/UmaSessionStats.java
@@ -15,7 +15,6 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.DefaultBrowserInfo;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler.AudioPermissionState;
import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManagerImpl;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tabmodel.TabModel;
@@ -112,24 +111,6 @@ public class UmaSessionStats {
updatePreferences();
updateMetricsServiceState();
DefaultBrowserInfo.logDefaultBrowserStats();
- if (permissionDelegate != null) {
- recordAudioPermissionState(permissionDelegate);
- }
- }
-
- private void recordAudioPermissionState(AndroidPermissionDelegate permissionDelegate) {
- @AudioPermissionState
- int permissionState;
- if (permissionDelegate.hasPermission(Manifest.permission.RECORD_AUDIO)) {
- permissionState = AudioPermissionState.GRANTED;
- } else if (permissionDelegate.canRequestPermission(Manifest.permission.RECORD_AUDIO)) {
- permissionState = AudioPermissionState.DENIED_CAN_ASK_AGAIN;
- } else {
- permissionState = AudioPermissionState.DENIED_CANNOT_ASK_AGAIN;
- }
- RecordHistogram.recordEnumeratedHistogram(
- "VoiceInteraction.AudioPermissionEvent.SessionStart", permissionState,
- AudioPermissionState.NUM_ENTRIES);
}
private static void ensureNativeInitialized() {
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/NewTabPage.java
@@ -64,7 +64,6 @@ import org.chromium.chrome.browser.native_page.ContextMenuManager;
import org.chromium.chrome.browser.omnibox.OmniboxFocusReason;
import org.chromium.chrome.browser.omnibox.OmniboxStub;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteControllerProvider;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManagerImpl;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.profiles.ProfileKey;
@@ -119,8 +118,7 @@ import java.util.List;
*/
public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvider,
TemplateUrlServiceObserver,
- BrowserControlsStateProvider.Observer, FeedSurfaceDelegate,
- VoiceRecognitionHandler.Observer {
+ BrowserControlsStateProvider.Observer, FeedSurfaceDelegate {
private static final String TAG = "NewTabPage";
// Key for the scroll position data that may be stored in a navigation entry.
@@ -151,7 +149,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
protected boolean mSearchProviderHasLogo;
protected OmniboxStub mOmniboxStub;
- private VoiceRecognitionHandler mVoiceRecognitionHandler;
// The timestamp at which the constructor was called.
protected final long mConstructedTimeNs;
@@ -243,8 +240,7 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
@Override
public boolean isVoiceSearchEnabled() {
- return mVoiceRecognitionHandler != null
- && mVoiceRecognitionHandler.isVoiceSearchEnabled();
+ return false;
}
@Override
@@ -252,21 +248,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
if (mIsDestroyed) return;
FeedReliabilityLogger feedReliabilityLogger =
mFeedSurfaceProvider.getReliabilityLogger();
- if (mVoiceRecognitionHandler != null && beginVoiceSearch) {
- if (feedReliabilityLogger != null) {
- feedReliabilityLogger.onVoiceSearch();
- }
- mVoiceRecognitionHandler.startVoiceRecognition(
- VoiceRecognitionHandler.VoiceInteractionSource.NTP);
- mTracker.notifyEvent(EventConstants.NTP_VOICE_SEARCH_BUTTON_CLICKED);
- } else if (mOmniboxStub != null) {
- if (feedReliabilityLogger != null) {
- feedReliabilityLogger.onOmniboxFocused();
- }
- mOmniboxStub.setUrlBarFocus(true, pastedText,
- pastedText == null ? OmniboxFocusReason.FAKE_BOX_TAP
- : OmniboxFocusReason.FAKE_BOX_LONG_PRESS);
- }
}
@Override
@@ -785,12 +766,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
mOmniboxStub.addUrlFocusChangeListener(feedReliabilityLogger);
}
}
-
- mVoiceRecognitionHandler = mOmniboxStub.getVoiceRecognitionHandler();
- if (mVoiceRecognitionHandler != null) {
- mVoiceRecognitionHandler.addObserver(this);
- mNewTabPageLayout.updateActionButtonVisibility();
- }
}
@Override
@@ -801,11 +776,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
}
}
- @Override
- public void onVoiceAvailabilityImpacted() {
- mNewTabPageLayout.updateActionButtonVisibility();
- }
-
/** Adds an observer to be notified on most visited tile clicks. */
public void addMostVisitedTileClickObserver(MostVisitedTileClickObserver observer) {
mMostVisitedTileClickObservers.addObserver(observer);
@@ -825,9 +795,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
RecordUserAction.record("MobileNTPShown");
mJankTracker.startTrackingScenario(JankScenario.NEW_TAB_PAGE);
SuggestionsMetrics.recordSurfaceVisible();
-
- FeatureNotificationUtils.registerIPHCallback(FeatureType.VOICE_SEARCH,
- mNewTabPageLayout::maybeShowFeatureNotificationVoiceSearchIPH);
}
/** Records UMA for the NTP being hidden and the time spent on it. */
@@ -836,7 +803,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
RecordHistogram.recordMediumTimesHistogram("NewTabPage.TimeSpent",
(System.nanoTime() - mLastShownTimeNs) / TimeUtils.NANOSECONDS_PER_MILLISECOND);
SuggestionsMetrics.recordSurfaceHidden();
- FeatureNotificationUtils.unregisterIPHCallback(FeatureType.VOICE_SEARCH);
}
/**
@@ -934,9 +900,6 @@ public class NewTabPage implements NativePage, InvalidationAwareThumbnailProvide
}
mFeedSurfaceProvider.destroy();
mTab.getWindowAndroid().removeContextMenuCloseListener(mContextMenuManager);
- if (mVoiceRecognitionHandler != null) {
- mVoiceRecognitionHandler.removeObserver(this);
- }
if (mSearchResumptionModuleCoordinator != null) {
mSearchResumptionModuleCoordinator.destroy();
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/search/SearchBoxMediator.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/search/SearchBoxMediator.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/search/SearchBoxMediator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/search/SearchBoxMediator.java
@@ -86,7 +86,6 @@ class SearchBoxMediator implements DestroyObserver, NativeInitObserver {
? AppCompatResources.getColorStateList(mContext,
R.color.default_icon_color_accent1_container_tint_list)
: ThemeUtils.getThemedToolbarIconTint(mContext, BrandedColorScheme.APP_DEFAULT);
- mModel.set(SearchBoxProperties.VOICE_SEARCH_COLOR_STATE_LIST, colorStateList);
}
/** Called to set a click listener for the search box. */
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
--- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivity.java
@@ -54,7 +54,6 @@ import org.chromium.chrome.browser.omnibox.styles.OmniboxResourceProvider;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdownScrollListener;
import org.chromium.chrome.browser.omnibox.suggestions.action.OmniboxActionDelegateImpl;
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.password_manager.ManagePasswordsReferrer;
import org.chromium.chrome.browser.password_manager.PasswordManagerLauncher;
import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManagerImpl;
@@ -404,14 +403,12 @@ public class SearchActivity extends AsyncInitializationActivity
// will navigate to Tabbed mode. Investigate whether this can inflate
// the tabbed mode layout in the background instead of CCTs.
CustomTabsConnection.getInstance().warmup(0);
- VoiceRecognitionHandler voiceRecognitionHandler =
- mLocationBarCoordinator.getVoiceRecognitionHandler();
@SearchType
int searchType = getSearchType(getIntent().getAction());
if (isFromQuickActionSearchWidget()) {
recordQuickActionSearchType(searchType);
}
- mSearchBox.onDeferredStartup(searchType, voiceRecognitionHandler, getWindowAndroid());
+ mSearchBox.onDeferredStartup(searchType, getWindowAndroid());
RecordUserAction.record("SearchWidget.WidgetSelected");
getActivityDelegate().onFinishDeferredInitialization();
@@ -482,8 +479,7 @@ public class SearchActivity extends AsyncInitializationActivity
if (isFromQuickActionSearchWidget()) {
recordQuickActionSearchType(searchType);
}
- mSearchBox.beginQuery(searchType, getOptionalIntentQuery(),
- mLocationBarCoordinator.getVoiceRecognitionHandler(), getWindowAndroid());
+ mSearchBox.beginQuery(searchType, getOptionalIntentQuery(), getWindowAndroid());
}
@Override
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java
@@ -29,7 +29,6 @@ import org.chromium.chrome.browser.omnibox.UrlBarCoordinator.SelectionState;
import org.chromium.chrome.browser.omnibox.UrlBarData;
import org.chromium.chrome.browser.omnibox.status.StatusCoordinator;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.toolbar.top.ToolbarPhone;
import org.chromium.chrome.browser.ui.searchactivityutils.SearchActivityPreferencesManager;
import org.chromium.components.browser_ui.styles.ChromeColors;
@@ -90,7 +89,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
/** Called when the SearchActivity has finished initialization. */
void onDeferredStartup(@SearchType int searchType,
- @NonNull VoiceRecognitionHandler voiceRecognitionHandler,
@NonNull WindowAndroid windowAndroid) {
SearchActivityPreferencesManager.updateFeatureAvailability(getContext(), windowAndroid);
assert !LocaleManager.getInstance().needToCheckForSearchEnginePromo();
@@ -102,7 +100,7 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
mAutocompleteCoordinator.onTextChanged(mUrlCoordinator.getTextWithoutAutocomplete());
if (mPendingBeginQuery) {
- beginQueryInternal(searchType, voiceRecognitionHandler, windowAndroid);
+ beginQueryInternal(searchType, windowAndroid);
mPendingBeginQuery = false;
}
}
@@ -111,12 +109,10 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
* Begins a new query.
* @param searchType The type of search to invoke.
* @param optionalText Prepopulate with a query, this may be null.
- * @param voiceRecognitionHandler Handler responsible for managing voice searches.
* @param windowAndroid WindowAndroid context.
*/
@VisibleForTesting
public void beginQuery(@SearchType int searchType, @Nullable String optionalText,
- @NonNull VoiceRecognitionHandler voiceRecognitionHandler,
@NonNull WindowAndroid windowAndroid) {
// Clear the text regardless of the promo decision. This allows the user to enter text
// before native has been initialized and have it not be cleared one the delayed beginQuery
@@ -130,11 +126,10 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
return;
}
- beginQueryInternal(searchType, voiceRecognitionHandler, windowAndroid);
+ beginQueryInternal(searchType, windowAndroid);
}
private void beginQueryInternal(@SearchType int searchType,
- @NonNull VoiceRecognitionHandler voiceRecognitionHandler,
@NonNull WindowAndroid windowAndroid) {
assert !mPendingSearchPromoDecision;
@@ -144,7 +139,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
}
if (searchType == SearchType.VOICE) {
- runVoiceSearch(voiceRecognitionHandler);
} else if (searchType == SearchType.LENS) {
runGoogleLens(windowAndroid);
} else {
@@ -152,33 +146,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
}
}
- /**
- * Begins a new Voice query.
- *
- * @param voiceRecognitionHandler Handler responsible for managing voice searches.
- */
- @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- void runVoiceSearch(@NonNull VoiceRecognitionHandler voiceRecognitionHandler) {
- assert mNativeInitialized;
- // Run Voice before focusing the Omnibox. Voice search may trigger omnibox focus as part of
- // its own flow in the event where the input is ambiguous. Focusing the Omnibox early may
- // affect this flow.
- //
- // Note that the Voice search will call us back in the event of any failure via
- // notifyVoiceRecognitionCanceled() call, giving us the opportunity to focus the Omnibox.
- if (voiceRecognitionHandler.isVoiceSearchEnabled()) {
- voiceRecognitionHandler.startVoiceRecognition(
- VoiceRecognitionHandler.VoiceInteractionSource.SEARCH_WIDGET);
- return;
- }
-
- // Voice recognition is not available. Fall back to regular text search.
- Toast.makeText(getContext(), R.string.quick_action_search_widget_message_no_voice_search,
- Toast.LENGTH_LONG)
- .show();
- focusTextBox();
- }
-
/**
* Begins a new Lens query.
*
@@ -232,9 +199,4 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
mAutocompleteCoordinator.startCachedZeroSuggest();
});
}
-
- @Override
- public void notifyVoiceRecognitionCanceled() {
- focusTextBox();
- }
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarManager.java
@@ -92,7 +92,6 @@ import org.chromium.chrome.browser.omnibox.SearchEngineLogoUtils;
import org.chromium.chrome.browser.omnibox.UrlFocusChangeListener;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdownScrollListener;
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.page_info.ChromePageInfo;
import org.chromium.chrome.browser.partnercustomizations.PartnerBrowserCustomizations;
import org.chromium.chrome.browser.price_tracking.PriceTrackingFeatures;
@@ -2207,10 +2206,6 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
return mLocationBar.getOmniboxStub();
}
- public @Nullable VoiceRecognitionHandler getVoiceRecognitionHandler() {
- return mLocationBar.getVoiceRecognitionHandler();
- }
-
/**
* Called whenever the NTP could have been entered or exited (e.g. tab content changed, tab
* navigated to from the tab strip/tab switcher, etc.). If the user is on a tablet and indeed
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ui/RootUiCoordinator.java
@@ -96,8 +96,6 @@ import org.chromium.chrome.browser.omnibox.OmniboxFocusReason;
import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader;
import org.chromium.chrome.browser.omnibox.suggestions.action.OmniboxActionDelegateImpl;
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler.VoiceInteractionSource;
import org.chromium.chrome.browser.paint_preview.DemoPaintPreview;
import org.chromium.chrome.browser.password_manager.ManagePasswordsReferrer;
import org.chromium.chrome.browser.password_manager.PasswordManagerLauncher;
@@ -295,7 +293,6 @@ public class RootUiCoordinator
protected OneshotSupplierImpl<Boolean> mPromoShownOneshotSupplier = new OneshotSupplierImpl<>();
protected Supplier<Tab> mStartSurfaceParentTabSupplier;
@Nullable
- private VoiceRecognitionHandler.Observer mMicStateObserver;
private MediaCaptureOverlayController mCaptureController;
private @Nullable ScrollCaptureManager mScrollCaptureManager;
protected final ActivityLifecycleDispatcher mActivityLifecycleDispatcher;
@@ -594,9 +591,6 @@ public class RootUiCoordinator
}
if (mToolbarManager != null) {
- if (mMicStateObserver != null && mToolbarManager.getVoiceRecognitionHandler() != null) {
- mToolbarManager.getVoiceRecognitionHandler().removeObserver(mMicStateObserver);
- }
mToolbarManager.destroy();
mToolbarManager = null;
}
@@ -1194,19 +1188,11 @@ public class RootUiCoordinator
new VoiceToolbarButtonController.VoiceSearchDelegate() {
@Override
public boolean isVoiceSearchEnabled() {
- VoiceRecognitionHandler voiceRecognitionHandler =
- mToolbarManager.getVoiceRecognitionHandler();
- if (voiceRecognitionHandler == null) return false;
- return voiceRecognitionHandler.isVoiceSearchEnabled();
+ return false;
}
@Override
public void startVoiceRecognition() {
- VoiceRecognitionHandler voiceRecognitionHandler =
- mToolbarManager.getVoiceRecognitionHandler();
- if (voiceRecognitionHandler == null) return;
- voiceRecognitionHandler.startVoiceRecognition(
- VoiceInteractionSource.TOOLBAR);
}
};
TranslateToolbarButtonController translateToolbarButtonController =
@@ -1316,13 +1302,6 @@ public class RootUiCoordinator
if (!mSupportsAppMenuSupplier.getAsBoolean()) {
mToolbarManager.getToolbar().disableMenuButton();
}
-
- VoiceRecognitionHandler voiceRecognitionHandler =
- mToolbarManager.getVoiceRecognitionHandler();
- if (voiceRecognitionHandler != null) {
- mMicStateObserver = voiceToolbarButtonController::updateMicButtonState;
- voiceRecognitionHandler.addObserver(mMicStateObserver);
- }
mToolbarManagerOneshotSupplier.set(mToolbarManager);
}
}
diff --git a/chrome/browser/ui/android/omnibox/BUILD.gn b/chrome/browser/ui/android/omnibox/BUILD.gn
--- a/chrome/browser/ui/android/omnibox/BUILD.gn
+++ b/chrome/browser/ui/android/omnibox/BUILD.gn
@@ -139,7 +139,6 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/omnibox/suggestions/tail/TailSuggestionView.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/tail/TailSuggestionViewBinder.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/tail/TailSuggestionViewProperties.java",
- "java/src/org/chromium/chrome/browser/omnibox/voice/VoiceRecognitionHandler.java",
]
public_deps = [
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBar.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBar.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBar.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBar.java
@@ -9,7 +9,6 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.tab.Tab;
/**
@@ -74,11 +73,6 @@ public interface LocationBar {
*/
View getSecurityIconView();
-
- /** Returns the {@link VoiceRecognitionHandler} associated with this LocationBar. */
- default @Nullable VoiceRecognitionHandler getVoiceRecognitionHandler() {
- return null;
- }
/**
* Returns a (@link OmniboxStub}.
*
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarCoordinator.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarCoordinator.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarCoordinator.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarCoordinator.java
@@ -40,7 +40,6 @@ import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteDelegate;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdownScrollListener;
import org.chromium.chrome.browser.omnibox.suggestions.basic.BasicSuggestionProcessor.BookmarkState;
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
@@ -390,13 +389,6 @@ public class LocationBarCoordinator
return mLocationBarLayout.getSecurityIconView();
}
- /** Returns the {@link VoiceRecognitionHandler} associated with this LocationBar. */
- @Nullable
- @Override
- public VoiceRecognitionHandler getVoiceRecognitionHandler() {
- return mLocationBarMediator.getVoiceRecognitionHandler();
- }
-
@Nullable
@Override
public OmniboxStub getOmniboxStub() {
@@ -682,11 +674,6 @@ public class LocationBarCoordinator
// End tablet-specific methods.
- public void setVoiceRecognitionHandlerForTesting(
- VoiceRecognitionHandler voiceRecognitionHandler) {
- mLocationBarMediator.setVoiceRecognitionHandlerForTesting(voiceRecognitionHandler);
- }
-
public void onUrlChangedForTesting() {
mLocationBarMediator.onUrlChanged();
}
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarMediator.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarMediator.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarMediator.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/LocationBarMediator.java
@@ -52,7 +52,6 @@ import org.chromium.chrome.browser.omnibox.geo.GeolocationHeader;
import org.chromium.chrome.browser.omnibox.status.StatusCoordinator;
import org.chromium.chrome.browser.omnibox.styles.OmniboxResourceProvider;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.prefetch.settings.PreloadPagesSettingsBridge;
import org.chromium.chrome.browser.prefetch.settings.PreloadPagesState;
import org.chromium.chrome.browser.privacy.settings.PrivacyPreferencesManager;
@@ -88,8 +87,8 @@ import java.util.function.BooleanSupplier;
* currently, migration of this logic out of LocationBarLayout is in progress.
*/
class LocationBarMediator
- implements LocationBarDataProvider.Observer, OmniboxStub, VoiceRecognitionHandler.Delegate,
- VoiceRecognitionHandler.Observer, UrlBarDelegate, OnKeyListener,
+ implements LocationBarDataProvider.Observer, OmniboxStub,
+ UrlBarDelegate, OnKeyListener,
ComponentCallbacks, TemplateUrlService.TemplateUrlServiceObserver,
BackPressHandler {
private static final int ICON_FADE_ANIMATION_DURATION_MS = 150;
@@ -149,7 +148,6 @@ class LocationBarMediator
};
private final LocationBarLayout mLocationBarLayout;
- private VoiceRecognitionHandler mVoiceRecognitionHandler;
private final LocationBarDataProvider mLocationBarDataProvider;
private StatusCoordinator mStatusCoordinator;
private AutocompleteCoordinator mAutocompleteCoordinator;
@@ -219,8 +217,6 @@ class LocationBarMediator
mLocationBarDataProvider.addObserver(this);
mOverrideUrlLoadingDelegate = overrideUrlLoadingDelegate;
mLocaleManager = localeManager;
- mVoiceRecognitionHandler = new VoiceRecognitionHandler(this, profileSupplier);
- mVoiceRecognitionHandler.addObserver(this);
mProfileSupplier = profileSupplier;
mProfileSupplier.addObserver(mCallbackController.makeCancelable(this::setProfile));
mPrivacyPreferencesManager = privacyPreferencesManager;
@@ -264,8 +260,6 @@ class LocationBarMediator
mAutocompleteCoordinator = null;
mUrlCoordinator = null;
mPrivacyPreferencesManager = null;
- mVoiceRecognitionHandler.removeObserver(this);
- mVoiceRecognitionHandler = null;
mLocationBarDataProvider.removeObserver(this);
mDeferredNativeRunnables.clear();
mUrlFocusChangeListeners.clear();
@@ -372,11 +366,6 @@ class LocationBarMediator
mLocationBarLayout.setUnfocusedWidth(unfocusedWidth);
}
- /* package */ void setVoiceRecognitionHandlerForTesting(
- VoiceRecognitionHandler voiceRecognitionHandler) {
- mVoiceRecognitionHandler = voiceRecognitionHandler;
- }
-
/* package */ void setLensControllerForTesting(LensController lensController) {
mLensController = lensController;
}
@@ -594,8 +583,6 @@ class LocationBarMediator
mUrlCoordinator.setKeyboardVisibility(false, false);
RecordUserAction.record("MobileOmniboxVoiceSearch");
- mVoiceRecognitionHandler.startVoiceRecognition(
- VoiceRecognitionHandler.VoiceInteractionSource.OMNIBOX);
}
/** package */ void lensButtonClicked(View view) {
@@ -1042,8 +1029,7 @@ class LocationBarMediator
private boolean shouldShowMicButton() {
if (shouldShowDeleteButton()) return false;
- if (!mNativeInitialized || mVoiceRecognitionHandler == null
- || !mVoiceRecognitionHandler.isVoiceSearchEnabled()) {
+ if ((true)) {
return false;
}
boolean isToolbarMicEnabled = mIsToolbarMicEnabledSupplier.getAsBoolean();
@@ -1202,7 +1188,6 @@ class LocationBarMediator
// This method needs to be called first as it computes |mBrandedColorScheme|.
updateBrandedColorScheme();
- updateAssistantVoiceSearchDrawableAndColors();
updateLensButtonColors();
}
@@ -1289,16 +1274,6 @@ class LocationBarMediator
}
}
- @Override
- public @Nullable VoiceRecognitionHandler getVoiceRecognitionHandler() {
- // TODO(crbug.com/1140333): StartSurfaceMediator can call this method after destroy().
- if (mLocationBarLayout == null) {
- return null;
- }
-
- return mVoiceRecognitionHandler;
- }
-
@Override
public void addUrlFocusChangeListener(UrlFocusChangeListener listener) {
mUrlFocusChangeListeners.addObserver(listener);
@@ -1314,29 +1289,10 @@ class LocationBarMediator
return mUrlHasFocus;
}
- @Override
public void clearOmniboxFocus() {
setUrlBarFocus(/*shouldBeFocused=*/false, /*pastedText=*/null, OmniboxFocusReason.UNFOCUS);
}
- @Override
- public void notifyVoiceRecognitionCanceled() {
- mLocationBarLayout.notifyVoiceRecognitionCanceled();
- }
-
- // VoiceRecognitionHandler.Delegate implementation.
-
- @Override
- public void loadUrlFromVoice(String url) {
- loadUrl(url, PageTransition.TYPED, 0, /*openInNewTab=*/false);
- }
-
- @Override
- public void onVoiceAvailabilityImpacted() {
- updateButtonVisibility();
- }
-
- @Override
public void setSearchQuery(String query) {
if (TextUtils.isEmpty(query)) return;
@@ -1355,21 +1311,9 @@ class LocationBarMediator
mUrlCoordinator.setKeyboardVisibility(true, false);
}
- @Override
public LocationBarDataProvider getLocationBarDataProvider() {
return mLocationBarDataProvider;
}
-
- @Override
- public AutocompleteCoordinator getAutocompleteCoordinator() {
- return mAutocompleteCoordinator;
- }
-
- @Override
- public WindowAndroid getWindowAndroid() {
- return mWindowAndroid;
- }
-
// UrlBarDelegate implementation.
@Nullable
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/OmniboxStub.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/OmniboxStub.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/OmniboxStub.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/OmniboxStub.java
@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.omnibox;
import androidx.annotation.Nullable;
import org.chromium.chrome.browser.lens.LensEntryPoint;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import java.util.List;
@@ -40,13 +39,6 @@ public interface OmniboxStub {
*/
boolean isUrlBarFocused();
- /**
- * Get the {@link VoiceRecognitionHandler}.
- * @return the {@link VoiceRecognitionHandler}
- */
- @Nullable
- VoiceRecognitionHandler getVoiceRecognitionHandler();
-
/**
* Adds a URL focus change listener that will be notified when the URL gains or loses focus.
* @param listener The listener to be registered.
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteController.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteController.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteController.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteController.java
@@ -12,7 +12,6 @@ import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.base.lifetime.Destroyable;
import org.chromium.chrome.browser.omnibox.OmniboxMetrics;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler.VoiceResult;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.components.omnibox.AutocompleteMatch;
@@ -286,24 +285,6 @@ public class AutocompleteController implements Destroyable {
mNativeController, match.getNativeObjectRef(), matchIndex, webContents);
}
- /**
- * Pass the voice provider a list representing the results of a voice recognition.
- * @param results A list containing the results of a voice recognition.
- */
- void onVoiceResults(@Nullable List<VoiceResult> results) {
- if (mNativeController == 0) return;
- if (results == null || results.size() == 0) return;
- final int count = Math.min(results.size(), MAX_VOICE_SUGGESTION_COUNT);
- String[] voiceMatches = new String[count];
- float[] confidenceScores = new float[count];
- for (int i = 0; i < count; i++) {
- voiceMatches[i] = results.get(i).getMatch();
- confidenceScores[i] = results.get(i).getConfidence();
- }
- AutocompleteControllerJni.get().setVoiceMatches(
- mNativeController, voiceMatches, confidenceScores);
- }
-
/**
* Updates AQS/SBS parameters on the selected match that we will navigate to and returns the
* updated URL.
@@ -398,8 +379,6 @@ public class AutocompleteController implements Destroyable {
long elapsedTimeSinceInputChange, String newQueryText, String[] newQueryParams);
Tab getMatchingTabForSuggestion(
long nativeAutocompleteControllerAndroid, long nativeAutocompleteMatch);
- void setVoiceMatches(long nativeAutocompleteControllerAndroid, String[] matches,
- float[] confidenceScores);
// Destroy supplied instance of the AutocompleteControllerAndroid.
// The instance cannot be used after this call completes.
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteCoordinator.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteCoordinator.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteCoordinator.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteCoordinator.java
@@ -46,7 +46,6 @@ import org.chromium.chrome.browser.omnibox.suggestions.header.HeaderViewBinder;
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
import org.chromium.chrome.browser.omnibox.suggestions.tail.TailSuggestionView;
import org.chromium.chrome.browser.omnibox.suggestions.tail.TailSuggestionViewBinder;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.share.ShareDelegate;
import org.chromium.chrome.browser.tab.Tab;
@@ -319,13 +318,6 @@ public class AutocompleteCoordinator implements UrlFocusChangeListener, UrlTextC
mRecycledViewPool.onNativeInitialized();
}
- /**
- * @see AutocompleteController#onVoiceResults(List)
- */
- public void onVoiceResults(@Nullable List<VoiceRecognitionHandler.VoiceResult> results) {
- mMediator.onVoiceResults(results);
- }
-
/**
* @return The current native pointer to the autocomplete results.
* TODO(ender): Figure out how to remove this.
diff --git a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteMediator.java b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteMediator.java
--- a/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteMediator.java
+++ b/chrome/browser/ui/android/omnibox/java/src/org/chromium/chrome/browser/omnibox/suggestions/AutocompleteMediator.java
@@ -37,7 +37,6 @@ import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteController.On
import org.chromium.chrome.browser.omnibox.suggestions.action.OmniboxActionFactoryImpl;
import org.chromium.chrome.browser.omnibox.suggestions.basic.BasicSuggestionProcessor.BookmarkState;
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
-import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
import org.chromium.chrome.browser.share.ShareDelegate;
@@ -415,14 +414,6 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener,
mShouldPreventOmniboxAutocomplete = prevent;
}
- /**
- * @see AutocompleteController#onVoiceResults(List)
- */
- void onVoiceResults(@Nullable List<VoiceRecognitionHandler.VoiceResult> results) {
- if (!mNativeInitialized || mAutocomplete == null) return;
- mAutocomplete.onVoiceResults(results);
- }
-
/**
* @return The current native pointer to the autocomplete results.
* TODO(crbug.com/1138587): Figure out how to remove this.
--
2.25.1