Commit c2c0e6fd authored by Patrick Noland's avatar Patrick Noland Committed by Commit Bot

[ToolbarMVC] Use LocationBarCoordinator in SearchActivity

This will allow it to continue to function as logic migrates out of
LocationBarLayout. SearchActivity-specific logic remains in
SearchActivityLocationBarLayout for now.

Change-Id: I1a32a6fbfd584590b982ecb4c8639664e752819d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2495785
Commit-Queue: Patrick Noland <pnoland@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarbttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823210}
parent 12012781
...@@ -54,11 +54,12 @@ public final class LocationBarCoordinator implements LocationBar, FakeboxDelegat ...@@ -54,11 +54,12 @@ public final class LocationBarCoordinator implements LocationBar, FakeboxDelegat
/** /**
* Creates {@link LocationBarCoordinator} and its subcoordinator: {@link * Creates {@link LocationBarCoordinator} and its subcoordinator: {@link
* LocationBarCoordinatorPhone} or {@link LocationBarCoordinatorTablet}, depending on the type * LocationBarCoordinatorPhone} or {@link LocationBarCoordinatorTablet}, depending on the type
* of {@code locationBarLayout}. * of {@code locationBarLayout}; no sub-coordinator is created for other LocationBarLayout
* subclasses.
* {@code LocationBarCoordinator} owns the subcoordinator. Destroying the former destroys the * {@code LocationBarCoordinator} owns the subcoordinator. Destroying the former destroys the
* latter. * latter.
* *
* @param locationBarLayout Inflated {@link LocationBarPhone} or {@link LocationBarTablet}. * @param locationBarLayout Inflated {@link LocationBarLayout}.
* {@code LocationBarCoordinator} takes ownership and will destroy this object. * {@code LocationBarCoordinator} takes ownership and will destroy this object.
* @param profileObservableSupplier The supplier of the active profile. * @param profileObservableSupplier The supplier of the active profile.
* @param locationBarDataProvider {@link LocationBarDataProvider} to be used for accessing * @param locationBarDataProvider {@link LocationBarDataProvider} to be used for accessing
...@@ -73,8 +74,6 @@ public final class LocationBarCoordinator implements LocationBar, FakeboxDelegat ...@@ -73,8 +74,6 @@ public final class LocationBarCoordinator implements LocationBar, FakeboxDelegat
* @param incognitoStateProvider An {@link IncognitoStateProvider} to access the current * @param incognitoStateProvider An {@link IncognitoStateProvider} to access the current
* incognito state. * incognito state.
* @param activityLifecycleDispatcher Allows observation of the activity state. * @param activityLifecycleDispatcher Allows observation of the activity state.
* @throws IllegalArgumentException if the view is neither {@link LocationBarPhone} nor {@link
* LocationBarTablet}.
*/ */
public LocationBarCoordinator(View locationBarLayout, public LocationBarCoordinator(View locationBarLayout,
ObservableSupplier<Profile> profileObservableSupplier, ObservableSupplier<Profile> profileObservableSupplier,
...@@ -92,10 +91,6 @@ public final class LocationBarCoordinator implements LocationBar, FakeboxDelegat ...@@ -92,10 +91,6 @@ public final class LocationBarCoordinator implements LocationBar, FakeboxDelegat
} else if (locationBarLayout instanceof LocationBarTablet) { } else if (locationBarLayout instanceof LocationBarTablet) {
mSubCoordinator = mSubCoordinator =
new LocationBarCoordinatorTablet((LocationBarTablet) locationBarLayout); new LocationBarCoordinatorTablet((LocationBarTablet) locationBarLayout);
} else {
assert false : "Expected LocationBarPhone or LocationBarTablet, got "
+ locationBarLayout.getClass();
throw new IllegalArgumentException(locationBarLayout.getClass().toString());
} }
mLocationbarDataProvider = locationBarDataProvider; mLocationbarDataProvider = locationBarDataProvider;
......
...@@ -33,6 +33,7 @@ import org.chromium.chrome.browser.document.ChromeLauncherActivity; ...@@ -33,6 +33,7 @@ import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.init.AsyncInitializationActivity; import org.chromium.chrome.browser.init.AsyncInitializationActivity;
import org.chromium.chrome.browser.init.SingleWindowKeyboardVisibilityDelegate; 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.LocationBarCoordinator;
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;
import org.chromium.chrome.browser.tab.TabBuilder; import org.chromium.chrome.browser.tab.TabBuilder;
...@@ -110,6 +111,7 @@ public class SearchActivity extends AsyncInitializationActivity ...@@ -110,6 +111,7 @@ public class SearchActivity extends AsyncInitializationActivity
/** The View that represents the search box. */ /** The View that represents the search box. */
private SearchActivityLocationBarLayout mSearchBox; private SearchActivityLocationBarLayout mSearchBox;
private LocationBarCoordinator mLocationBarCoordinator;
private SnackbarManager mSnackbarManager; private SnackbarManager mSnackbarManager;
private SearchBoxDataProvider mSearchBoxDataProvider; private SearchBoxDataProvider mSearchBoxDataProvider;
...@@ -164,10 +166,11 @@ public class SearchActivity extends AsyncInitializationActivity ...@@ -164,10 +166,11 @@ public class SearchActivity extends AsyncInitializationActivity
mSearchBox = (SearchActivityLocationBarLayout) mContentView.findViewById( mSearchBox = (SearchActivityLocationBarLayout) mContentView.findViewById(
R.id.search_location_bar); R.id.search_location_bar);
mSearchBox.setDelegate(this); mSearchBox.setDelegate(this);
mSearchBox.setLocationBarDataProvider(mSearchBoxDataProvider); mLocationBarCoordinator = new LocationBarCoordinator(mSearchBox, mProfileSupplier,
mSearchBox.initializeControls( mSearchBoxDataProvider, null, new WindowDelegate(getWindow()), getWindowAndroid(),
new WindowDelegate(getWindow()), getWindowAndroid(), null, null, null, null); /*activityTabProvider=*/null, /*modalDialogManagerSupplier=*/null,
mSearchBox.setProfileSupplier(mProfileSupplier); /*shareDelegateSupplier=*/null, /*incognitoStateProvider=*/null,
getLifecycleDispatcher());
// 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();
...@@ -252,7 +255,6 @@ public class SearchActivity extends AsyncInitializationActivity ...@@ -252,7 +255,6 @@ public class SearchActivity extends AsyncInitializationActivity
mTab.loadUrl(new LoadUrlParams(ContentUrlConstants.ABOUT_BLANK_DISPLAY_URL)); mTab.loadUrl(new LoadUrlParams(ContentUrlConstants.ABOUT_BLANK_DISPLAY_URL));
mSearchBoxDataProvider.onNativeLibraryReady(mTab); mSearchBoxDataProvider.onNativeLibraryReady(mTab);
mSearchBox.onFinishNativeInitialization();
mProfileSupplier.set(Profile.fromWebContents(webContents)); mProfileSupplier.set(Profile.fromWebContents(webContents));
// Force the user to choose a search engine if they have to. // Force the user to choose a search engine if they have to.
......
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