Commit 80268974 authored by Filip Gorski's avatar Filip Gorski Committed by Commit Bot

[OSL-RV] Extract the Embedder interface to a separate file

Moves the Embedder interface from OmniboxSuggestionsDropdown to a
separate file with the name: OmniboxSuggestionsDropdownEmbedder.

This interface used to be a standalone thing to begin with and we moved
it inside for the period of refactoring. It makes sense to have it
standalone, because that is the only part that embedder needs to
implement/know of to effectively integrate with the dropdown.

Bug: 1075602
Change-Id: Iee75626462b88b343790dbebc31477b9ae33e54d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530894Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Reviewed-by: default avatarTomasz Wiszkowski <ender@google.com>
Commit-Queue: Filip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826318}
parent d8f7927c
......@@ -1127,6 +1127,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionsDropdown.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionsDropdownAdapter.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionsDropdownDelegate.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/OmniboxSuggestionsDropdownEmbedder.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/SuggestionCommonProperties.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/SuggestionHost.java",
"java/src/org/chromium/chrome/browser/omnibox/suggestions/SuggestionListProperties.java",
......
......@@ -58,7 +58,7 @@ import org.chromium.chrome.browser.omnibox.status.StatusCoordinator;
import org.chromium.chrome.browser.omnibox.status.StatusView;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteDelegate;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdown;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdownEmbedder;
import org.chromium.chrome.browser.omnibox.voice.AssistantVoiceSearchService;
import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
......@@ -209,7 +209,7 @@ public class LocationBarLayout
mUrlCoordinator = new UrlBarCoordinator((UrlBar) mUrlBar);
mUrlCoordinator.setDelegate(this);
OmniboxSuggestionsDropdown.Embedder embedder = new OmniboxSuggestionsDropdown.Embedder() {
OmniboxSuggestionsDropdownEmbedder embedder = new OmniboxSuggestionsDropdownEmbedder() {
@Override
public boolean isTablet() {
return mIsTablet;
......
......@@ -64,7 +64,7 @@ public class AutocompleteCoordinator implements UrlFocusChangeListener, UrlTextC
private OmniboxSuggestionsDropdown mDropdown;
public AutocompleteCoordinator(ViewGroup parent, AutocompleteDelegate delegate,
OmniboxSuggestionsDropdown.Embedder dropdownEmbedder,
OmniboxSuggestionsDropdownEmbedder dropdownEmbedder,
UrlBarEditingTextStateProvider urlBarEditingTextProvider) {
mParent = parent;
Context context = parent.getContext();
......
......@@ -20,7 +20,6 @@ import androidx.recyclerview.widget.RecyclerView;
import org.chromium.base.TraceEvent;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.util.KeyNavigationUtil;
/**
......@@ -34,26 +33,6 @@ public class OmniboxSuggestionsDropdown extends RecyclerView {
private final int[] mTempMeasureSpecs = new int[2];
/** Provides the capabilities required to embed the omnibox suggestion list into the UI. */
public interface Embedder {
/** Return the anchor view the suggestion list should be drawn below. */
View getAnchorView();
/**
* Return the view that the omnibox suggestions should be aligned horizontally to. The
* view must be a descendant of {@link #getAnchorView()}. If null, the suggestions will
* be aligned to the start of {@link #getAnchorView()}.
*/
@Nullable
View getAlignmentView();
/** Return the delegate used to interact with the Window. */
WindowDelegate getWindowDelegate();
/** Return whether the suggestions are being rendered in the tablet UI. */
boolean isTablet();
}
/** Interface that will receive notifications and callbacks from OmniboxSuggestionList. */
public interface Observer {
/**
......@@ -173,7 +152,7 @@ public class OmniboxSuggestionsDropdown extends RecyclerView {
* Sets the embedder for the list view.
* @param embedder the embedder of this list.
*/
public void setEmbedder(OmniboxSuggestionsDropdown.Embedder embedder) {
public void setEmbedder(OmniboxSuggestionsDropdownEmbedder embedder) {
mDropdownDelegate.setEmbedder(embedder);
}
......
......@@ -30,7 +30,7 @@ import org.chromium.ui.base.ViewUtils;
/** Common functionality of the Omnibox suggestions dropdown. */
class OmniboxSuggestionsDropdownDelegate implements View.OnAttachStateChangeListener {
private ViewGroup mSuggestionsDropdown;
private OmniboxSuggestionsDropdown.Embedder mEmbedder;
private OmniboxSuggestionsDropdownEmbedder mEmbedder;
private OmniboxSuggestionsDropdown.Observer mObserver;
private View mAnchorView;
private View mAlignmentView;
......@@ -60,7 +60,7 @@ class OmniboxSuggestionsDropdownDelegate implements View.OnAttachStateChangeList
}
/** Sets the embedder of the dropdown and creates necessary listeners. */
public void setEmbedder(OmniboxSuggestionsDropdown.Embedder embedder) {
public void setEmbedder(OmniboxSuggestionsDropdownEmbedder embedder) {
assert mEmbedder == null;
mEmbedder = embedder;
mAnchorView = mEmbedder.getAnchorView();
......
// Copyright 2020 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.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.chromium.chrome.browser.WindowDelegate;
/** Provider of capabilities required to embed the omnibox suggestion list into the UI. */
public interface OmniboxSuggestionsDropdownEmbedder {
/** Return the anchor view the suggestion list should be drawn below. */
@NonNull
View getAnchorView();
/**
* Return the view that the omnibox suggestions should be aligned horizontally to. The
* view must be a descendant of {@link #getAnchorView()}. If null, the suggestions will
* be aligned to the start of {@link #getAnchorView()}.
*/
@Nullable
View getAlignmentView();
/** Return the delegate used to interact with the Window. */
@NonNull
WindowDelegate getWindowDelegate();
/** Return whether the suggestions are being rendered in the tablet UI. */
boolean isTablet();
}
......@@ -17,7 +17,7 @@ public class SuggestionListProperties {
public static final WritableBooleanPropertyKey VISIBLE = new WritableBooleanPropertyKey();
/** The embedder for the suggestion list. */
public static final WritableObjectPropertyKey<OmniboxSuggestionsDropdown.Embedder> EMBEDDER =
public static final WritableObjectPropertyKey<OmniboxSuggestionsDropdownEmbedder> EMBEDDER =
new WritableObjectPropertyKey<>();
/**
......
......@@ -40,7 +40,7 @@ import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteController.On
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteDelegate;
import org.chromium.chrome.browser.omnibox.suggestions.AutocompleteResult;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdown;
import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdownEmbedder;
import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler.VoiceInteractionSource;
import org.chromium.chrome.browser.omnibox.voice.VoiceRecognitionHandler.VoiceResult;
import org.chromium.chrome.browser.profiles.Profile;
......@@ -302,7 +302,7 @@ public class VoiceRecognitionHandlerTest {
*/
private class TestAutocompleteCoordinator extends AutocompleteCoordinator {
public TestAutocompleteCoordinator(ViewGroup parent, AutocompleteDelegate delegate,
OmniboxSuggestionsDropdown.Embedder dropdownEmbedder,
OmniboxSuggestionsDropdownEmbedder dropdownEmbedder,
UrlBarEditingTextStateProvider urlBarEditingTextProvider) {
super(parent, delegate, dropdownEmbedder, urlBarEditingTextProvider);
}
......
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