Commit 7915ff17 authored by bttk's avatar bttk Committed by Commit Bot

[ToolbarMVC] Remove unnecessary LocationBar methods

These methods are only called on LocationBarCoordinator and have no
effect on CustomTabToolbar.

Change-Id: I4af4c32d8aadfdade5d5c4c04faa31c90abe63dd
Bug: 1133482
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464085Reviewed-by: default avatarPeter Conn <peconn@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: who/bttk <bttk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817520}
parent facc74dc
......@@ -49,9 +49,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.native_page.NativePageFactory;
import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.omnibox.LocationBar;
import org.chromium.chrome.browser.omnibox.UrlBar;
......@@ -864,18 +862,9 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
@Override
public void updateMicButtonState() {}
@Override
public void onTabLoadingNTP(NewTabPage ntp) {}
@Override
public void setProfileSupplier(ObservableSupplier<Profile> profileSupplier) {}
@Override
public void setUnfocusedWidth(int unfocusedWidth) {}
@Override
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {}
// Implements FakeBoxDelegate.
@Override
public boolean isUrlBarFocused() {
......@@ -889,9 +878,6 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
public void setUrlBarFocus(boolean shouldBeFocused, @Nullable String pastedText,
@LocationBar.OmniboxFocusReason int reason) {}
@Override
public void setUrlFocusChangeFraction(float fraction) {}
@Override
public boolean isCurrentPage(NativePage nativePage) {
return false;
......
......@@ -15,7 +15,6 @@ import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.lifecycle.Destroyable;
import org.chromium.chrome.browser.ntp.FakeboxDelegate;
import org.chromium.chrome.browser.ntp.NewTabPage;
......@@ -66,20 +65,14 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
int NUM_ENTRIES = 14;
}
/**
* Handle all necessary tasks that can be delayed until initialization completes.
*/
/** Handle all necessary tasks that can be delayed until initialization completes. */
default void onDeferredStartup() {}
/**
* Handles native dependent initialization for this class.
*/
/** Handles native dependent initialization for this class. */
void onNativeLibraryReady();
/**
* Triggered when the current tab has changed to a {@link NewTabPage}.
*/
void onTabLoadingNTP(NewTabPage ntp);
/** Triggered when the current tab has changed to a {@link NewTabPage}. */
default void onTabLoadingNTP(NewTabPage ntp){};
/**
* Call to force the UI to update the state of various buttons based on whether or not the
......@@ -87,13 +80,6 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/
void updateVisualsForState();
/**
* Updates progress of current the URL focus change animation.
*
* @param fraction 1.0 is 100% focused, 0 is completely unfocused.
*/
void setUrlFocusChangeFraction(float fraction);
/**
* Sets the displayed URL to be the URL of the page currently showing.
*
......@@ -103,40 +89,32 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/
void setUrlToPageUrl();
/**
* Sets the displayed title to the page title.
*/
/** Sets the displayed title to the page title. */
void setTitleToPageTitle();
/**
* Sets whether the location bar should have a layout showing a title.
*
* @param showTitle Whether the title should be shown.
*/
void setShowTitle(boolean showTitle);
/**
* Update the visuals based on a loading state change.
*
* @param updateUrl Whether to update the URL as a result of the this call.
*/
void updateLoadingState(boolean updateUrl);
/**
* Sets the {@link ToolbarDataProvider} to be used for accessing {@link Toolbar} state.
*/
/** Sets the {@link ToolbarDataProvider} to be used for accessing {@link Toolbar} state. */
void setToolbarDataProvider(ToolbarDataProvider model);
/**
* Sets the {@link OverviewModeBehavior}.
*/
void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior);
/**
* Gets the {@link ToolbarDataProvider} to be used for accessing {@link Toolbar} state.
*/
/** Gets the {@link ToolbarDataProvider} to be used for accessing {@link Toolbar} state. */
ToolbarDataProvider getToolbarDataProvider();
/**
* Initialize controls that will act as hooks to various functions.
*
* @param windowDelegate {@link WindowDelegate} that will provide {@link Window} related info.
* @param windowAndroid {@link WindowAndroid} that is used by the owning {@link Activity}.
* @param activityTabProvider An {@link ActivityTabProvider} to access the activity's current
......@@ -155,14 +133,12 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
/**
* Triggers the cursor to be visible in the UrlBar without triggering any of the focus animation
* logic.
* <p>
* Only applies to devices with a hardware keyboard attached.
*
* <p>Only applies to devices with a hardware keyboard attached.
*/
void showUrlBarCursorWithoutFocusAnimations();
/**
* Selects all of the editable text in the UrlBar.
*/
/** Selects all of the editable text in the {@link UrlBar}. */
void selectAll();
/**
......@@ -171,14 +147,10 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/
void revertChanges();
/**
* Updates the security icon displayed in the LocationBar.
*/
/** Updates the security icon displayed in the LocationBar. */
void updateStatusIcon();
/**
* @return The {@link ViewGroup} that this container holds.
*/
/** Returns {@link ViewGroup} that this container holds. */
View getContainerView();
/**
......@@ -189,34 +161,16 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/
View getSecurityIconView();
/**
* Updates the state of the mic button if there is one.
*/
/** Updates the state of the mic button if there is one. */
void updateMicButtonState();
/**
* Sets the callback to be used by default for text editing action bar.
* @param callback The callback to use.
*/
/** Sets the callback to be used by default for text editing action bar. */
void setDefaultTextEditActionModeCallback(ToolbarActionModeCallback callback);
/**
* Called to set the width of the location bar when the url bar is not focused.
*
* Immediately after the animation to transition the URL bar from focused to unfocused finishes,
* the layout width returned from #getMeasuredWidth() can differ from the final unfocused width
* (e.g. this value) until the next layout pass is complete.
*
* This value may be used to determine whether optional child views should be visible in the
* unfocused location bar.
*
* @param unfocusedWidth The unfocused location bar width.
*/
void setUnfocusedWidth(int unfocusedWidth);
/**
* Sets the (observable) supplier of the active profile. This supplier will notify observers of
* changes to the active profile, e.g. when selecting an incognito tab model.
*
* @param profileSupplier The supplier of the active profile.
*/
void setProfileSupplier(ObservableSupplier<Profile> profileSupplier);
......
......@@ -73,30 +73,6 @@ public final class LocationBarCoordinator implements LocationBar {
}
}
/**
* Returns the {@link LocationBarCoordinatorPhone} for this coordinator.
*
* @throws ClassCastException if this coordinator holds a {@link SubCoordinator} of a different
* type.
*/
@NonNull
public LocationBarCoordinatorPhone getPhoneCoordinator() {
assert mSubCoordinator != null;
return (LocationBarCoordinatorPhone) mSubCoordinator;
}
/**
* Returns the {@link LocationBarCoordinatorTablet} for this coordinator.
*
* @throws ClassCastException if this coordinator holds a {@link SubCoordinator} of a different
* type.
*/
@NonNull
public LocationBarCoordinatorTablet getTabletCoordinator() {
assert mSubCoordinator != null;
return (LocationBarCoordinatorTablet) mSubCoordinator;
}
@Override
public void destroy() {
if (mSubCoordinator != null) {
......@@ -129,11 +105,6 @@ public final class LocationBarCoordinator implements LocationBar {
mLocationBarLayout.updateVisualsForState();
}
@Override
public void setUrlFocusChangeFraction(float fraction) {
mLocationBarLayout.setUrlFocusChangeFraction(fraction);
}
@Override
public void setUrlToPageUrl() {
mLocationBarLayout.setUrlToPageUrl();
......@@ -159,11 +130,6 @@ public final class LocationBarCoordinator implements LocationBar {
mLocationBarLayout.setToolbarDataProvider(dataProvider);
}
@Override
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {
mLocationBarLayout.setOverviewModeBehavior(overviewModeBehavior);
}
@Override
public ToolbarDataProvider getToolbarDataProvider() {
return mLocationBarLayout.getToolbarDataProvider();
......@@ -219,11 +185,6 @@ public final class LocationBarCoordinator implements LocationBar {
mLocationBarLayout.setDefaultTextEditActionModeCallback(callback);
}
@Override
public void setUnfocusedWidth(int unfocusedWidth) {
mLocationBarLayout.setUnfocusedWidth(unfocusedWidth);
}
@Override
public void setProfileSupplier(ObservableSupplier<Profile> profileSupplier) {
mLocationBarLayout.setProfileSupplier(profileSupplier);
......@@ -294,4 +255,58 @@ public final class LocationBarCoordinator implements LocationBar {
public void removeUrlFocusChangeListener(UrlFocusChangeListener listener) {
mLocationBarLayout.removeUrlFocusChangeListener(listener);
}
/**
* Returns the {@link LocationBarCoordinatorPhone} for this coordinator.
*
* @throws ClassCastException if this coordinator holds a {@link SubCoordinator} of a different
* type.
*/
@NonNull
public LocationBarCoordinatorPhone getPhoneCoordinator() {
assert mSubCoordinator != null;
return (LocationBarCoordinatorPhone) mSubCoordinator;
}
/**
* Returns the {@link LocationBarCoordinatorTablet} for this coordinator.
*
* @throws ClassCastException if this coordinator holds a {@link SubCoordinator} of a different
* type.
*/
@NonNull
public LocationBarCoordinatorTablet getTabletCoordinator() {
assert mSubCoordinator != null;
return (LocationBarCoordinatorTablet) mSubCoordinator;
}
/** Sets the {@link OverviewModeBehavior}. */
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {
mLocationBarLayout.setOverviewModeBehavior(overviewModeBehavior);
}
/**
* Updates progress of current the URL focus change animation.
*
* @param fraction 1.0 is 100% focused, 0 is completely unfocused.
*/
public void setUrlFocusChangeFraction(float fraction) {
mLocationBarLayout.setUrlFocusChangeFraction(fraction);
}
/**
* Called to set the width of the location bar when the url bar is not focused.
*
* <p>Immediately after the animation to transition the URL bar from focused to unfocused
* finishes, the layout width returned from #getMeasuredWidth() can differ from the final
* unfocused width (e.g. this value) until the next layout pass is complete.
*
* <p>This value may be used to determine whether optional child views should be visible in the
* unfocused location bar.
*
* @param unfocusedWidth The unfocused location bar width.
*/
public void setUnfocusedWidth(int unfocusedWidth) {
mLocationBarLayout.setUnfocusedWidth(unfocusedWidth);
}
}
......@@ -141,11 +141,6 @@ class LocationBarTablet extends LocationBarLayout {
return selectedTarget.onTouchEvent(event);
}
// Returns amount by which to adjust to move value inside the given range.
private static float distanceToRange(float min, float max, float value) {
return value < min ? (min - value) : value > max ? (max - value) : 0;
}
@Override
public void handleUrlFocusAnimation(final boolean hasFocus) {
super.handleUrlFocusAnimation(hasFocus);
......@@ -183,15 +178,6 @@ class LocationBarTablet extends LocationBarLayout {
mUrlFocusChangeAnimator.start();
}
/**
* @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not
* focused.
*/
public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) {
mShouldShowButtonsWhenUnfocused = shouldShowButtons;
updateButtonVisibility();
}
/**
* Updates progress of current the URL focus change animation.
*
......@@ -262,6 +248,15 @@ class LocationBarTablet extends LocationBarLayout {
}
}
/**
* @param shouldShowButtons Whether buttons should be displayed in the URL bar when it's not
* focused.
*/
public void setShouldShowButtonsWhenUnfocused(boolean shouldShowButtons) {
mShouldShowButtonsWhenUnfocused = shouldShowButtons;
updateButtonVisibility();
}
/**
* @param button The {@link View} of the button to show.
* @return An animator to run for the given view when showing buttons in the unfocused location
......@@ -403,6 +398,11 @@ class LocationBarTablet extends LocationBarLayout {
return animators;
}
/** Returns amount by which to adjust to move value inside the given range. */
private static float distanceToRange(float min, float max, float value) {
return value < min ? (min - value) : value > max ? (max - value) : 0;
}
/**
* Resets the alpha and translation X for all views affected by the animations for showing or
* hiding buttons.
......
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