Commit 17bcd6db authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski

Drop the AutocompleteCoordinator interface (1/2)

This change is part of topic change.
the change helps eliminate apparent rewrite of the
AutocompleteCoordinator.java file in subsequent patch.

Bug: 966424
Change-Id: Iff92f7c70cd4a7d631abb83bf9c780839dac29ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2508800Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#823350}
parent 8436de62
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.omnibox.suggestions;
import android.view.KeyEvent;
import androidx.annotation.Nullable;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.layouts.LayoutStateProvider;
import org.chromium.chrome.browser.omnibox.LocationBarDataProvider;
import org.chromium.chrome.browser.omnibox.UrlBar.UrlTextChangeListener;
import org.chromium.chrome.browser.omnibox.UrlFocusChangeListener;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteController.OnSuggestionsReceivedListener;
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.ui.base.WindowAndroid;
import org.chromium.ui.modelutil.MVCListAdapter.ModelList;
import java.util.List;
/**
* This component handles the interactions with the autocomplete system.
* TODO(ender): clean up the AutocompleteCoordinatorImpl and drop this interface
* as it is never overloaded or mocked.
*/
public interface AutocompleteCoordinator extends UrlFocusChangeListener, UrlTextChangeListener {
/**
* Clean up resources used by this class.
*/
void destroy();
/**
* Provides data and state for the toolbar component.
* @param locationBarDataProvider The data provider.
*/
void setLocationBarDataProvider(LocationBarDataProvider locationBarDataProvider);
/**
* @param layoutStateProvider A means of accessing the current Layout state and a way to
* listen to state changes.
*/
void setLayoutStateProvider(LayoutStateProvider layoutStateProvider);
/**
* Updates the profile used for generating autocomplete suggestions.
* @param profile The profile to be used.
*/
void setAutocompleteProfile(Profile profile);
/**
* Set the WindowAndroid instance associated with the containing Activity.
*/
void setWindowAndroid(WindowAndroid windowAndroid);
/**
* @param provider A means of accessing the activity's tab.
*/
void setActivityTabProvider(ActivityTabProvider provider);
/**
* @param shareDelegateSupplier A means of accessing the sharing feature.
*/
void setShareDelegateSupplier(Supplier<ShareDelegate> shareDelegateSupplier);
/**
* Whether omnibox autocomplete should currently be prevented from generating suggestions.
*/
void setShouldPreventOmniboxAutocomplete(boolean prevent);
/**
* @return The number of current autocomplete suggestions.
*/
int getSuggestionCount();
/**
* Retrieve the omnibox suggestion at the specified index. The index represents the ordering
* in the underlying model. The index does not represent visibility due to the current scroll
* position of the list.
*
* @param index The index of the suggestion to fetch.
* @return The suggestion at the given index.
*/
OmniboxSuggestion getSuggestionAt(int index);
/**
* Signals that native initialization has completed.
*/
void onNativeInitialized();
/**
* @see AutocompleteController#onVoiceResults(List)
*/
void onVoiceResults(@Nullable List<VoiceRecognitionHandler.VoiceResult> results);
/**
* @return The current native pointer to the autocomplete results.
*/
// TODO(tedchoc): Figure out how to remove this.
long getCurrentNativeAutocompleteResult();
/**
* Update the layout direction of the suggestion list based on the parent layout direction.
*/
void updateSuggestionListLayoutDirection();
/**
* Update the visuals of the autocomplete UI.
* @param useDarkColors Whether dark colors should be applied to the UI.
* @param isIncognito Whether the UI is for incognito mode or not.
*/
void updateVisualsForState(boolean useDarkColors, boolean isIncognito);
/**
* Sets to show cached zero suggest results. This will start both caching zero suggest results
* in shared preferences and also attempt to show them when appropriate without needing native
* initialization.
* @param showCachedZeroSuggestResults Whether cached zero suggest should be shown.
*/
void setShowCachedZeroSuggestResults(boolean showCachedZeroSuggestResults);
/**
* Handle the key events associated with the suggestion list.
*
* @param keyCode The keycode representing what key was interacted with.
* @param event The key event containing all meta-data associated with the event.
* @return Whether the key event was handled.
*/
boolean handleKeyEvent(int keyCode, KeyEvent event);
/**
* Trigger autocomplete for the given query.
*/
void startAutocompleteForQuery(String query);
/**
* Given a search query, this will attempt to see if the query appears to be portion of a
* properly formed URL. If it appears to be a URL, this will return the fully qualified
* version (i.e. including the scheme, etc...). If the query does not appear to be a URL,
* this will return null.
*
* @param query The query to be expanded into a fully qualified URL if appropriate.
* @return The fully qualified URL or null.
*/
String qualifyPartialURLQuery(String query);
/**
* Sends a zero suggest request to the server in order to pre-populate the result cache.
*/
void prefetchZeroSuggestResults();
/** @return Suggestions Dropdown view, showing the list of suggestions. */
OmniboxSuggestionsDropdown getSuggestionsDropdownForTest();
/** @param controller The instance of AutocompleteController to be used. */
void setAutocompleteControllerForTest(AutocompleteController controller);
/** @return The current receiving OnSuggestionsReceived events. */
OnSuggestionsReceivedListener getSuggestionsReceivedListenerForTest();
/** @return The ModelList for the currently shown suggestions. */
ModelList getSuggestionModelListForTest();
}
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