Commit b2290f98 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Remove Tab reference from UrlBar.

BUG=800825

Change-Id: I8aaaf6a3e80cf6a0075fab4e73a60e7610d9b60d
Reviewed-on: https://chromium-review.googlesource.com/1145861
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577203}
parent f255f21a
......@@ -20,6 +20,7 @@ import android.os.SystemClock;
import android.provider.Settings;
import android.support.annotation.DrawableRes;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
import android.support.v4.view.MarginLayoutParamsCompat;
import android.support.v7.content.res.AppCompatResources;
import android.text.Editable;
......@@ -1935,12 +1936,20 @@ public class LocationBarLayout extends FrameLayout
updateSecurityIcon();
}
@Override
public Tab getCurrentTab() {
/** @return The current active {@link Tab}. */
@Nullable
private Tab getCurrentTab() {
if (mToolbarDataProvider == null) return null;
return mToolbarDataProvider.getTab();
}
@Override
public View getViewForUrlBackFocus() {
Tab tab = getCurrentTab();
if (tab == null) return null;
return tab.getView();
}
@Override
public boolean allowKeyboardLearning() {
if (mToolbarDataProvider == null) return false;
......
......@@ -40,7 +40,6 @@ import org.chromium.base.ThreadUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.omnibox.OmniboxUrlEmphasizer.UrlEmphasisSpan;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.toolbar.ToolbarManager;
import org.chromium.ui.UiUtils;
......@@ -164,10 +163,10 @@ public class UrlBar extends AutocompleteEditText {
*/
public interface UrlBarDelegate {
/**
* @return The current active {@link Tab}. May be null.
* @return The view to be focused on a backward focus traversal.
*/
@Nullable
Tab getCurrentTab();
View getViewForUrlBackFocus();
/**
* @return Whether the keyboard should be allowed to learn from the user input.
......@@ -396,9 +395,8 @@ public class UrlBar extends AutocompleteEditText {
@Override
public View focusSearch(int direction) {
if (direction == View.FOCUS_BACKWARD && mUrlBarDelegate.getCurrentTab() != null
&& mUrlBarDelegate.getCurrentTab().getView() != null) {
return mUrlBarDelegate.getCurrentTab().getView();
if (direction == View.FOCUS_BACKWARD && mUrlBarDelegate.getViewForUrlBackFocus() != null) {
return mUrlBarDelegate.getViewForUrlBackFocus();
} else {
return super.focusSearch(direction);
}
......
......@@ -19,6 +19,7 @@ import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.support.v4.text.BidiFormatter;
import android.support.v4.view.MarginLayoutParamsCompat;
import android.text.SpannableString;
......@@ -265,11 +266,19 @@ public class CustomTabToolbar extends ToolbarLayout implements LocationBar,
return 0;
}
@Override
public Tab getCurrentTab() {
/** @return The current active {@link Tab}. */
@Nullable
private Tab getCurrentTab() {
return getToolbarDataProvider().getTab();
}
@Override
public View getViewForUrlBackFocus() {
Tab tab = getCurrentTab();
if (tab == null) return null;
return tab.getView();
}
@Override
public boolean allowKeyboardLearning() {
return !super.isIncognito();
......
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