Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / infobar / InfoBarContainer.java
index eea69de..2b3c5be 100644 (file)
@@ -16,9 +16,8 @@ import android.widget.LinearLayout;
 
 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;
@@ -37,6 +36,9 @@ public class InfoBarContainer extends LinearLayout {
     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.
@@ -73,9 +75,6 @@ public class InfoBarContainer extends LinearLayout {
 
     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>();
 
@@ -89,14 +88,14 @@ public class InfoBarContainer extends LinearLayout {
     // 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;
@@ -110,13 +109,11 @@ public class InfoBarContainer extends LinearLayout {
         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) {
@@ -128,9 +125,8 @@ public class InfoBarContainer extends LinearLayout {
         return mAnimationListener;
     }
 
-
     public boolean areInfoBarsOnTop() {
-        return mInfoBarsOnTop;
+        return false;
     }
 
     @Override
@@ -151,13 +147,9 @@ public class InfoBarContainer extends LinearLayout {
         }
     }
 
-    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() {
@@ -209,15 +201,6 @@ public class InfoBarContainer extends LinearLayout {
         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.
@@ -362,7 +345,7 @@ public class InfoBarContainer extends LinearLayout {
             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);
@@ -374,11 +357,11 @@ public class InfoBarContainer extends LinearLayout {
     }
 
     // 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);
             }
         }
@@ -450,14 +433,6 @@ public class InfoBarContainer extends LinearLayout {
         }
     }
 
-    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.
      */
@@ -514,7 +489,7 @@ public class InfoBarContainer extends LinearLayout {
         return mNativeInfoBarContainer;
     }
 
-    private native long nativeInit(long webContentsPtr, AutoLoginDelegate autoLoginDelegate);
+    private native long nativeInit(WebContents webContents, AutoLoginDelegate autoLoginDelegate);
 
     private native void nativeDestroy(long nativeInfoBarContainerAndroid);
 }