import com.google.common.annotations.VisibleForTesting;
-import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.CalledByNative;
-import org.chromium.content.browser.DeviceUtils;
+import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.UiUtils;
import java.util.ArrayDeque;
private static final String TAG = "InfoBarContainer";
private static final long REATTACH_FADE_IN_MS = 250;
+ /**
+ * A listener for the InfoBar animation.
+ */
public interface InfoBarAnimationListener {
/**
* Notifies the subscriber when an animation is completed.
private final AutoLoginDelegate mAutoLoginDelegate;
- // Whether the infobar are shown on top (below the location bar) or at the bottom of the screen.
- private final boolean mInfoBarsOnTop;
-
// The list of all infobars in this container, regardless of whether they've been shown yet.
private final ArrayList<InfoBar> mInfoBars = new ArrayList<InfoBar>();
// True when this container has been emptied and its native counterpart has been destroyed.
private boolean mDestroyed = false;
- // The id of the tab associated with us. Set to TabBase.INVALID_TAB_ID if no tab is associated.
+ // The id of the tab associated with us. Set to Tab.INVALID_TAB_ID if no tab is associated.
private int mTabId;
// Parent view that contains us.
private ViewGroup mParentView;
public InfoBarContainer(Activity activity, AutoLoginProcessor autoLoginProcessor,
- int tabId, ViewGroup parentView, long nativeWebContents) {
+ int tabId, ViewGroup parentView, WebContents webContents) {
super(activity);
setOrientation(LinearLayout.VERTICAL);
mAnimationListener = null;
mAnimationSizer = new FrameLayout(activity);
mAnimationSizer.setVisibility(INVISIBLE);
- // The tablet has the infobars below the location bar. On the phone they are at the bottom.
- mInfoBarsOnTop = DeviceUtils.isTablet(activity);
- setGravity(determineGravity());
+ setGravity(Gravity.BOTTOM);
// Chromium's InfoBarContainer may add an InfoBar immediately during this initialization
// call, so make sure everything in the InfoBarContainer is completely ready beforehand.
- mNativeInfoBarContainer = nativeInit(nativeWebContents, mAutoLoginDelegate);
+ mNativeInfoBarContainer = nativeInit(webContents, mAutoLoginDelegate);
}
public void setAnimationListener(InfoBarAnimationListener listener) {
return mAnimationListener;
}
-
public boolean areInfoBarsOnTop() {
- return mInfoBarsOnTop;
+ return false;
}
@Override
}
}
- private int determineGravity() {
- return mInfoBarsOnTop ? Gravity.TOP : Gravity.BOTTOM;
- }
-
private FrameLayout.LayoutParams createLayoutParams() {
return new FrameLayout.LayoutParams(
- LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, determineGravity());
+ LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
}
public void removeFromParentView() {
setVisibility(INVISIBLE);
}
- public InfoBar findInfoBar(int nativeInfoBar) {
- for (InfoBar infoBar : mInfoBars) {
- if (infoBar.ownsNativeInfoBar(nativeInfoBar)) {
- return infoBar;
- }
- }
- return null;
- }
-
/**
* Adds an InfoBar to the view hierarchy.
* @param infoBar InfoBar to add to the View hierarchy.
targetView = info.target.getContentWrapper(true);
assert mInfoBars.contains(info.target);
toShow = targetView.detachCurrentView();
- addView(targetView, mInfoBarsOnTop ? getChildCount() : 0,
+ addView(targetView, 0,
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
} else {
targetView = info.target.getContentWrapper(false);
}
// Called by the tab when it has started loading a new page.
- public void onPageStarted(String url) {
+ public void onPageStarted() {
LinkedList<InfoBar> barsToRemove = new LinkedList<InfoBar>();
for (InfoBar infoBar : mInfoBars) {
- if (infoBar.shouldExpire(url)) {
+ if (infoBar.shouldExpire()) {
barsToRemove.add(infoBar);
}
}
}
}
- public void startTransition() {
- if (mInfoBarsOnTop) {
- // We need to clip this view to its bounds while it is animated because the layout's
- // z-ordering puts it on top of other infobars as it's being animated.
- ApiCompatibilityUtils.postInvalidateOnAnimation(this);
- }
- }
-
/**
* Finishes off whatever animation is running.
*/
return mNativeInfoBarContainer;
}
- private native long nativeInit(long webContentsPtr, AutoLoginDelegate autoLoginDelegate);
+ private native long nativeInit(WebContents webContents, AutoLoginDelegate autoLoginDelegate);
private native void nativeDestroy(long nativeInfoBarContainerAndroid);
}