Commit ab6e9c1c authored by Patrick Noland's avatar Patrick Noland Committed by Chromium LUCI CQ

[ToolbarMVC] Remove onUrlFocusChange from SALBL

This removal also lets us remove setUrlFocusChangeInProgress. As a
replacement, SearchActivity makes itself a url focus change listener
and uses the new LocationBarCoordinator#setUrlFocusChangeInProgress
method to call setUrlFocusChangeInProgress(false) in the scenarios
where SALBL used to do so.

Change-Id: I25259c2d28e99d6404590ac4e15d158254722ca5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2597221
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarbttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844930}
parent e92998ac
...@@ -423,6 +423,14 @@ public final class LocationBarCoordinator implements LocationBar, NativeInitObse ...@@ -423,6 +423,14 @@ public final class LocationBarCoordinator implements LocationBar, NativeInitObse
mUrlCoordinator.setAllowFocus(focusable); mUrlCoordinator.setAllowFocus(focusable);
} }
/**
* Triggers a url focus change to begin or end, depending on the value of inProgress.
* @param inProgress Whether a focus change is in progress.
*/
public void setUrlFocusChangeInProgress(boolean inProgress) {
mLocationBarMediator.setUrlFocusChangeInProgress(inProgress);
}
public void setVoiceRecognitionHandlerForTesting( public void setVoiceRecognitionHandlerForTesting(
VoiceRecognitionHandler voiceRecognitionHandler) { VoiceRecognitionHandler voiceRecognitionHandler) {
mLocationBarMediator.setVoiceRecognitionHandlerForTesting(voiceRecognitionHandler); mLocationBarMediator.setVoiceRecognitionHandlerForTesting(voiceRecognitionHandler);
......
...@@ -399,6 +399,10 @@ class LocationBarMediator implements LocationBarDataProvider.Observer, FakeboxDe ...@@ -399,6 +399,10 @@ class LocationBarMediator implements LocationBarDataProvider.Observer, FakeboxDe
VoiceRecognitionHandler.VoiceInteractionSource.OMNIBOX); VoiceRecognitionHandler.VoiceInteractionSource.OMNIBOX);
} }
/* package */ void setUrlFocusChangeInProgress(boolean inProgress) {
mLocationBarLayout.setUrlFocusChangeInProgress(inProgress);
}
// Private methods // Private methods
private void setProfile(Profile profile) { private void setProfile(Profile profile) {
......
...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.init.SingleWindowKeyboardVisibilityDelegate; ...@@ -35,6 +35,7 @@ import org.chromium.chrome.browser.init.SingleWindowKeyboardVisibilityDelegate;
import org.chromium.chrome.browser.locale.LocaleManager; import org.chromium.chrome.browser.locale.LocaleManager;
import org.chromium.chrome.browser.omnibox.BackKeyBehaviorDelegate; import org.chromium.chrome.browser.omnibox.BackKeyBehaviorDelegate;
import org.chromium.chrome.browser.omnibox.LocationBarCoordinator; import org.chromium.chrome.browser.omnibox.LocationBarCoordinator;
import org.chromium.chrome.browser.omnibox.UrlFocusChangeListener;
import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler; import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
...@@ -60,8 +61,8 @@ import org.chromium.ui.modaldialog.ModalDialogManager; ...@@ -60,8 +61,8 @@ import org.chromium.ui.modaldialog.ModalDialogManager;
import org.chromium.url.GURL; import org.chromium.url.GURL;
/** Queries the user's default search engine and shows autocomplete suggestions. */ /** Queries the user's default search engine and shows autocomplete suggestions. */
public class SearchActivity public class SearchActivity extends AsyncInitializationActivity
extends AsyncInitializationActivity implements SnackbarManageable, BackKeyBehaviorDelegate { implements SnackbarManageable, BackKeyBehaviorDelegate, UrlFocusChangeListener {
// Shared with other org.chromium.chrome.browser.searchwidget classes. // Shared with other org.chromium.chrome.browser.searchwidget classes.
protected static final String TAG = "searchwidget"; protected static final String TAG = "searchwidget";
...@@ -180,6 +181,7 @@ public class SearchActivity ...@@ -180,6 +181,7 @@ public class SearchActivity
}, },
/*backKeyBehavior=*/this); /*backKeyBehavior=*/this);
mLocationBarCoordinator.setUrlBarFocusable(true); mLocationBarCoordinator.setUrlBarFocusable(true);
mLocationBarCoordinator.getFakeboxDelegate().addUrlFocusChangeListener(this);
// Kick off everything needed for the user to type into the box. // Kick off everything needed for the user to type into the box.
beginQuery(); beginQuery();
...@@ -352,6 +354,10 @@ public class SearchActivity ...@@ -352,6 +354,10 @@ public class SearchActivity
@Override @Override
protected void onDestroy() { protected void onDestroy() {
if (mTab != null && mTab.isInitialized()) mTab.destroy(); if (mTab != null && mTab.isInitialized()) mTab.destroy();
if (mLocationBarCoordinator != null
&& mLocationBarCoordinator.getFakeboxDelegate() != null) {
mLocationBarCoordinator.getFakeboxDelegate().removeUrlFocusChangeListener(this);
}
super.onDestroy(); super.onDestroy();
} }
...@@ -360,6 +366,13 @@ public class SearchActivity ...@@ -360,6 +366,13 @@ public class SearchActivity
return true; return true;
} }
@Override
public void onUrlFocusChange(boolean hasFocus) {
if (hasFocus) {
mLocationBarCoordinator.setUrlFocusChangeInProgress(false);
}
}
/* package */ void loadUrl(String url, @PageTransition int transition, /* package */ void loadUrl(String url, @PageTransition int transition,
@Nullable String postDataType, @Nullable byte[] postData) { @Nullable String postDataType, @Nullable byte[] postData) {
// Wait until native has loaded. // Wait until native has loaded.
......
...@@ -67,7 +67,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout { ...@@ -67,7 +67,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
SearchWidgetProvider.updateCachedVoiceSearchAvailability( SearchWidgetProvider.updateCachedVoiceSearchAvailability(
voiceRecognitionHandler.isVoiceSearchEnabled()); voiceRecognitionHandler.isVoiceSearchEnabled());
if (isVoiceSearchIntent && mUrlBar.isFocused()) onUrlFocusChange(true);
assert !LocaleManager.getInstance().needToCheckForSearchEnginePromo(); assert !LocaleManager.getInstance().needToCheckForSearchEnginePromo();
mPendingSearchPromoDecision = false; mPendingSearchPromoDecision = false;
...@@ -128,12 +127,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout { ...@@ -128,12 +127,6 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
findViewById(R.id.url_action_container).setVisibility(View.VISIBLE); findViewById(R.id.url_action_container).setVisibility(View.VISIBLE);
} }
@Override
public void onUrlFocusChange(boolean hasFocus) {
super.onUrlFocusChange(hasFocus);
if (hasFocus) setUrlFocusChangeInProgress(false);
}
// TODO(tedchoc): Investigate focusing regardless of the search promo state and just ensure // TODO(tedchoc): Investigate focusing regardless of the search promo state and just ensure
// we don't start processing non-cached suggestion requests until that state // we don't start processing non-cached suggestion requests until that state
// is finalized after native has been initialized. // is finalized after native has been initialized.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment