Commit cd2237d3 authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski Committed by Commit Bot

Do not initialize QueryProcessor by default

This change allows most tests to operate without having the QueryTile
Processor initialized if these don't care about its presence.

Bug: 982818
Change-Id: I6fe6c0bba9fb83d99bcad9e93c84a831df2da8bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219149
Commit-Queue: Ender <ender@google.com>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772480}
parent 4cc8875a
......@@ -78,9 +78,8 @@ public class AutocompleteCoordinatorImpl implements AutocompleteCoordinator {
MVCListAdapter.ModelList listItems = new MVCListAdapter.ModelList();
mQueryTileCoordinator = new OmniboxQueryTileCoordinator(context, this::onTileSelected);
mMediator = new AutocompleteMediator(context, delegate, urlBarEditingTextProvider,
new AutocompleteController(), mQueryTileCoordinator::setTiles, listModel,
new Handler());
mMediator.initDefaultProcessors();
new AutocompleteController(), listModel, new Handler());
mMediator.initDefaultProcessors(mQueryTileCoordinator::setTiles);
listModel.set(SuggestionListProperties.EMBEDDER, dropdownEmbedder);
listModel.set(SuggestionListProperties.VISIBLE, false);
......
......@@ -135,7 +135,6 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
// it in the mSuggestionProcessors list. The processor currently cannot be combined with
// other processors because of its unique requirements.
private @Nullable EditUrlSuggestionProcessor mEditUrlProcessor;
private final TileSuggestionProcessor mTileSuggestionProcessor;
private HeaderProcessor mHeaderProcessor;
private final List<SuggestionProcessor> mSuggestionProcessors;
private final List<DropdownItemViewInfo> mViewInfoList;
......@@ -200,8 +199,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
public AutocompleteMediator(Context context, AutocompleteDelegate delegate,
UrlBarEditingTextStateProvider textProvider,
AutocompleteController autocompleteController,
Callback<List<QueryTile>> queryTileSuggestionCallback, PropertyModel listPropertyModel,
AutocompleteController autocompleteController, PropertyModel listPropertyModel,
Handler handler) {
mContext = context;
mDelegate = delegate;
......@@ -210,13 +208,10 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
mAutocomplete = autocompleteController;
mAutocomplete.setOnSuggestionsReceivedListener(this);
mHandler = handler;
mTileSuggestionProcessor =
new TileSuggestionProcessor(mContext, queryTileSuggestionCallback);
mHeaderProcessor = new HeaderProcessor(mContext, this, mDelegate);
mSuggestionProcessors = new ArrayList<>();
mViewInfoList = new ArrayList<>();
mAutocompleteResult = new AutocompleteResult(null, null);
mOverviewModeObserver = new EmptyOverviewModeObserver() {
@Override
public void onOverviewModeStartedShowing(boolean showToolbar) {
......@@ -230,7 +225,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
/**
* Initialize the Mediator with default set of suggestions processors.
*/
void initDefaultProcessors() {
void initDefaultProcessors(Callback<List<QueryTile>> queryTileSuggestionCallback) {
final Supplier<ImageFetcher> imageFetcherSupplier = createImageFetcherSupplier();
final Supplier<LargeIconBridge> iconBridgeSupplier = createIconBridgeSupplier();
......@@ -243,7 +238,8 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
registerSuggestionProcessor(
new EntitySuggestionProcessor(mContext, this, imageFetcherSupplier));
registerSuggestionProcessor(new TailSuggestionProcessor(mContext, this));
registerSuggestionProcessor(mTileSuggestionProcessor);
registerSuggestionProcessor(
new TileSuggestionProcessor(mContext, queryTileSuggestionCallback));
registerSuggestionProcessor(new BasicSuggestionProcessor(
mContext, this, mUrlBarEditingTextProvider, iconBridgeSupplier));
}
......
......@@ -87,8 +87,8 @@ public class AutocompleteMediatorUnitTest {
mListModel.set(SuggestionListProperties.SUGGESTION_MODELS, mSuggestionModels);
mMediator = new AutocompleteMediator(ContextUtils.getApplicationContext(),
mAutocompleteDelegate, mTextStateProvider, mAutocompleteController, null,
mListModel, mHandler);
mAutocompleteDelegate, mTextStateProvider, mAutocompleteController, mListModel,
mHandler);
mMediator.setToolbarDataProvider(mToolbarDataProvider);
mMediator.registerSuggestionProcessor(mMockProcessor);
mMediator.setSuggestionVisibilityState(
......
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