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