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; ...@@ -49,9 +49,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.WindowDelegate; import org.chromium.chrome.browser.WindowDelegate;
import org.chromium.chrome.browser.app.ChromeActivity; 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.native_page.NativePageFactory;
import org.chromium.chrome.browser.ntp.NewTabPage;
import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; import org.chromium.chrome.browser.offlinepages.OfflinePageUtils;
import org.chromium.chrome.browser.omnibox.LocationBar; import org.chromium.chrome.browser.omnibox.LocationBar;
import org.chromium.chrome.browser.omnibox.UrlBar; import org.chromium.chrome.browser.omnibox.UrlBar;
...@@ -864,18 +862,9 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL ...@@ -864,18 +862,9 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
@Override @Override
public void updateMicButtonState() {} public void updateMicButtonState() {}
@Override
public void onTabLoadingNTP(NewTabPage ntp) {}
@Override @Override
public void setProfileSupplier(ObservableSupplier<Profile> profileSupplier) {} public void setProfileSupplier(ObservableSupplier<Profile> profileSupplier) {}
@Override
public void setUnfocusedWidth(int unfocusedWidth) {}
@Override
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {}
// Implements FakeBoxDelegate. // Implements FakeBoxDelegate.
@Override @Override
public boolean isUrlBarFocused() { public boolean isUrlBarFocused() {
...@@ -889,9 +878,6 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL ...@@ -889,9 +878,6 @@ public class CustomTabToolbar extends ToolbarLayout implements View.OnLongClickL
public void setUrlBarFocus(boolean shouldBeFocused, @Nullable String pastedText, public void setUrlBarFocus(boolean shouldBeFocused, @Nullable String pastedText,
@LocationBar.OmniboxFocusReason int reason) {} @LocationBar.OmniboxFocusReason int reason) {}
@Override
public void setUrlFocusChangeFraction(float fraction) {}
@Override @Override
public boolean isCurrentPage(NativePage nativePage) { public boolean isCurrentPage(NativePage nativePage) {
return false; return false;
......
...@@ -15,7 +15,6 @@ import org.chromium.base.supplier.ObservableSupplier; ...@@ -15,7 +15,6 @@ import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.Supplier; import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.ActivityTabProvider; import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.WindowDelegate; 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.lifecycle.Destroyable;
import org.chromium.chrome.browser.ntp.FakeboxDelegate; import org.chromium.chrome.browser.ntp.FakeboxDelegate;
import org.chromium.chrome.browser.ntp.NewTabPage; import org.chromium.chrome.browser.ntp.NewTabPage;
...@@ -66,20 +65,14 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl ...@@ -66,20 +65,14 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
int NUM_ENTRIES = 14; 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() {} default void onDeferredStartup() {}
/** /** Handles native dependent initialization for this class. */
* Handles native dependent initialization for this class.
*/
void onNativeLibraryReady(); void onNativeLibraryReady();
/** /** Triggered when the current tab has changed to a {@link NewTabPage}. */
* Triggered when the current tab has changed to a {@link NewTabPage}. default void onTabLoadingNTP(NewTabPage ntp){};
*/
void onTabLoadingNTP(NewTabPage ntp);
/** /**
* Call to force the UI to update the state of various buttons based on whether or not the * 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 ...@@ -87,13 +80,6 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/ */
void updateVisualsForState(); 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. * Sets the displayed URL to be the URL of the page currently showing.
* *
...@@ -103,40 +89,32 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl ...@@ -103,40 +89,32 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/ */
void setUrlToPageUrl(); void setUrlToPageUrl();
/** /** Sets the displayed title to the page title. */
* Sets the displayed title to the page title.
*/
void setTitleToPageTitle(); void setTitleToPageTitle();
/** /**
* Sets whether the location bar should have a layout showing a title. * Sets whether the location bar should have a layout showing a title.
*
* @param showTitle Whether the title should be shown. * @param showTitle Whether the title should be shown.
*/ */
void setShowTitle(boolean showTitle); void setShowTitle(boolean showTitle);
/** /**
* Update the visuals based on a loading state change. * Update the visuals based on a loading state change.
*
* @param updateUrl Whether to update the URL as a result of the this call. * @param updateUrl Whether to update the URL as a result of the this call.
*/ */
void updateLoadingState(boolean updateUrl); 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); void setToolbarDataProvider(ToolbarDataProvider model);
/** /** Gets the {@link ToolbarDataProvider} to be used for accessing {@link Toolbar} state. */
* Sets the {@link OverviewModeBehavior}.
*/
void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior);
/**
* Gets the {@link ToolbarDataProvider} to be used for accessing {@link Toolbar} state.
*/
ToolbarDataProvider getToolbarDataProvider(); ToolbarDataProvider getToolbarDataProvider();
/** /**
* Initialize controls that will act as hooks to various functions. * Initialize controls that will act as hooks to various functions.
*
* @param windowDelegate {@link WindowDelegate} that will provide {@link Window} related info. * @param windowDelegate {@link WindowDelegate} that will provide {@link Window} related info.
* @param windowAndroid {@link WindowAndroid} that is used by the owning {@link Activity}. * @param windowAndroid {@link WindowAndroid} that is used by the owning {@link Activity}.
* @param activityTabProvider An {@link ActivityTabProvider} to access the activity's current * @param activityTabProvider An {@link ActivityTabProvider} to access the activity's current
...@@ -155,14 +133,12 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl ...@@ -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 * Triggers the cursor to be visible in the UrlBar without triggering any of the focus animation
* logic. * logic.
* <p> *
* Only applies to devices with a hardware keyboard attached. * <p>Only applies to devices with a hardware keyboard attached.
*/ */
void showUrlBarCursorWithoutFocusAnimations(); void showUrlBarCursorWithoutFocusAnimations();
/** /** Selects all of the editable text in the {@link UrlBar}. */
* Selects all of the editable text in the UrlBar.
*/
void selectAll(); void selectAll();
/** /**
...@@ -171,14 +147,10 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl ...@@ -171,14 +147,10 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/ */
void revertChanges(); void revertChanges();
/** /** Updates the security icon displayed in the LocationBar. */
* Updates the security icon displayed in the LocationBar.
*/
void updateStatusIcon(); void updateStatusIcon();
/** /** Returns {@link ViewGroup} that this container holds. */
* @return The {@link ViewGroup} that this container holds.
*/
View getContainerView(); View getContainerView();
/** /**
...@@ -189,34 +161,16 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl ...@@ -189,34 +161,16 @@ public interface LocationBar extends UrlBarDelegate, FakeboxDelegate, Destroyabl
*/ */
View getSecurityIconView(); 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(); void updateMicButtonState();
/** /** Sets the callback to be used by default for text editing action bar. */
* Sets the callback to be used by default for text editing action bar.
* @param callback The callback to use.
*/
void setDefaultTextEditActionModeCallback(ToolbarActionModeCallback callback); 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 * 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. * changes to the active profile, e.g. when selecting an incognito tab model.
*
* @param profileSupplier The supplier of the active profile. * @param profileSupplier The supplier of the active profile.
*/ */
void setProfileSupplier(ObservableSupplier<Profile> profileSupplier); void setProfileSupplier(ObservableSupplier<Profile> profileSupplier);
......
...@@ -73,30 +73,6 @@ public final class LocationBarCoordinator implements LocationBar { ...@@ -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 @Override
public void destroy() { public void destroy() {
if (mSubCoordinator != null) { if (mSubCoordinator != null) {
...@@ -129,11 +105,6 @@ public final class LocationBarCoordinator implements LocationBar { ...@@ -129,11 +105,6 @@ public final class LocationBarCoordinator implements LocationBar {
mLocationBarLayout.updateVisualsForState(); mLocationBarLayout.updateVisualsForState();
} }
@Override
public void setUrlFocusChangeFraction(float fraction) {
mLocationBarLayout.setUrlFocusChangeFraction(fraction);
}
@Override @Override
public void setUrlToPageUrl() { public void setUrlToPageUrl() {
mLocationBarLayout.setUrlToPageUrl(); mLocationBarLayout.setUrlToPageUrl();
...@@ -159,11 +130,6 @@ public final class LocationBarCoordinator implements LocationBar { ...@@ -159,11 +130,6 @@ public final class LocationBarCoordinator implements LocationBar {
mLocationBarLayout.setToolbarDataProvider(dataProvider); mLocationBarLayout.setToolbarDataProvider(dataProvider);
} }
@Override
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {
mLocationBarLayout.setOverviewModeBehavior(overviewModeBehavior);
}
@Override @Override
public ToolbarDataProvider getToolbarDataProvider() { public ToolbarDataProvider getToolbarDataProvider() {
return mLocationBarLayout.getToolbarDataProvider(); return mLocationBarLayout.getToolbarDataProvider();
...@@ -219,11 +185,6 @@ public final class LocationBarCoordinator implements LocationBar { ...@@ -219,11 +185,6 @@ public final class LocationBarCoordinator implements LocationBar {
mLocationBarLayout.setDefaultTextEditActionModeCallback(callback); mLocationBarLayout.setDefaultTextEditActionModeCallback(callback);
} }
@Override
public void setUnfocusedWidth(int unfocusedWidth) {
mLocationBarLayout.setUnfocusedWidth(unfocusedWidth);
}
@Override @Override
public void setProfileSupplier(ObservableSupplier<Profile> profileSupplier) { public void setProfileSupplier(ObservableSupplier<Profile> profileSupplier) {
mLocationBarLayout.setProfileSupplier(profileSupplier); mLocationBarLayout.setProfileSupplier(profileSupplier);
...@@ -294,4 +255,58 @@ public final class LocationBarCoordinator implements LocationBar { ...@@ -294,4 +255,58 @@ public final class LocationBarCoordinator implements LocationBar {
public void removeUrlFocusChangeListener(UrlFocusChangeListener listener) { public void removeUrlFocusChangeListener(UrlFocusChangeListener listener) {
mLocationBarLayout.removeUrlFocusChangeListener(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 { ...@@ -141,11 +141,6 @@ class LocationBarTablet extends LocationBarLayout {
return selectedTarget.onTouchEvent(event); 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 @Override
public void handleUrlFocusAnimation(final boolean hasFocus) { public void handleUrlFocusAnimation(final boolean hasFocus) {
super.handleUrlFocusAnimation(hasFocus); super.handleUrlFocusAnimation(hasFocus);
...@@ -183,15 +178,6 @@ class LocationBarTablet extends LocationBarLayout { ...@@ -183,15 +178,6 @@ class LocationBarTablet extends LocationBarLayout {
mUrlFocusChangeAnimator.start(); 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. * Updates progress of current the URL focus change animation.
* *
...@@ -262,6 +248,15 @@ class LocationBarTablet extends LocationBarLayout { ...@@ -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. * @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 * @return An animator to run for the given view when showing buttons in the unfocused location
...@@ -403,6 +398,11 @@ class LocationBarTablet extends LocationBarLayout { ...@@ -403,6 +398,11 @@ class LocationBarTablet extends LocationBarLayout {
return animators; 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 * Resets the alpha and translation X for all views affected by the animations for showing or
* hiding buttons. * 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