Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / TabBase.java
index ef424bf..44b820b 100644 (file)
@@ -13,6 +13,7 @@ import android.view.View;
 
 import org.chromium.base.CalledByNative;
 import org.chromium.base.ObserverList;
+import org.chromium.chrome.browser.banners.AppBannerManager;
 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuItemDelegate;
 import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator;
 import org.chromium.chrome.browser.contextmenu.ContextMenuParams;
@@ -87,6 +88,9 @@ public abstract class TabBase implements NavigationClient {
     /** InfoBar container to show InfoBars for this tab. */
     private InfoBarContainer mInfoBarContainer;
 
+    /** Manages app banners shown for this tab. */
+    private AppBannerManager mAppBannerManager;
+
     /** The sync id of the TabBase if session sync is enabled. */
     private int mSyncId;
 
@@ -671,6 +675,12 @@ public abstract class TabBase implements NavigationClient {
         } else {
             mInfoBarContainer.onParentViewChanged(getId(), getContentView());
         }
+
+        if (AppBannerManager.isEnabled() && mAppBannerManager == null) {
+            mAppBannerManager = new AppBannerManager(this);
+        }
+
+        for (TabObserver observer : mObservers) observer.onContentChanged(this);
     }
 
     /**
@@ -801,7 +811,7 @@ public abstract class TabBase implements NavigationClient {
     /**
      * @return The {@link WindowAndroid} associated with this {@link TabBase}.
      */
-    protected WindowAndroid getWindowAndroid() {
+    public WindowAndroid getWindowAndroid() {
         return mWindowAndroid;
     }
 
@@ -821,6 +831,14 @@ public abstract class TabBase implements NavigationClient {
     }
 
     /**
+     * Called when the navigation entry containing the historyitem changed,
+     * for example because of a scroll offset or form field change.
+     */
+    @CalledByNative
+    protected void onNavEntryChanged() {
+    }
+
+    /**
      * @return The native pointer representing the native side of this {@link TabBase} object.
      */
     @CalledByNative
@@ -830,17 +848,32 @@ public abstract class TabBase implements NavigationClient {
 
     /** This is currently called when committing a pre-rendered page. */
     @CalledByNative
-    private void swapWebContents(final long newWebContents) {
-        if (mContentViewCore != null) mContentViewCore.onHide();
+    private void swapWebContents(
+            final long newWebContents, boolean didStartLoad, boolean didFinishLoad) {
+        int originalWidth = 0;
+        int originalHeight = 0;
+        if (mContentViewCore != null) {
+            originalWidth = mContentViewCore.getViewportWidthPix();
+            originalHeight = mContentViewCore.getViewportHeightPix();
+            mContentViewCore.onHide();
+        }
         destroyContentView(false);
         NativePage previousNativePage = mNativePage;
         mNativePage = null;
         initContentView(newWebContents);
+        // Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(),
+        // next onShow() call would send a resize message with the current ContentViewCore size
+        // (zero) to the renderer process, although the new size will be set soon.
+        // However, this size fluttering may confuse Blink and rendered result can be broken
+        // (see http://crbug.com/340987).
+        mContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
         mContentViewCore.onShow();
         mContentViewCore.attachImeAdapter();
         for (TabObserver observer : mObservers) observer.onContentChanged(this);
         destroyNativePageInternal(previousNativePage);
-        for (TabObserver observer : mObservers) observer.onWebContentsSwapped(this);
+        for (TabObserver observer : mObservers) {
+            observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
+        }
     }
 
     @CalledByNative