summaryrefslogtreecommitdiffstats
path: root/chrome/android
diff options
context:
space:
mode:
authorksimbili@google.com <ksimbili@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 04:49:05 +0000
committerksimbili@google.com <ksimbili@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-12 04:49:05 +0000
commit8f0b48ec9f59fe25adb2a1fb3da45df2131d039f (patch)
treedcfa0287c9aeff7ebf4bf9e92668e4b74bcc7a47 /chrome/android
parentcc668c3228173addddc5ea4272adb189f59f0b74 (diff)
downloadchromium_src-8f0b48ec9f59fe25adb2a1fb3da45df2131d039f.zip
chromium_src-8f0b48ec9f59fe25adb2a1fb3da45df2131d039f.tar.gz
chromium_src-8f0b48ec9f59fe25adb2a1fb3da45df2131d039f.tar.bz2
Changes needed to support background content view at java layer.
Changes to propogate first non-empty paint to the java layer. Review URL: https://codereview.chromium.org/183513010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256427 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/android')
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/Tab.java38
-rw-r--r--chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java7
2 files changed, 33 insertions, 12 deletions
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
index c205b29..59a9d35 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
@@ -702,6 +702,15 @@ public class Tab implements NavigationClient {
}
/**
+ * Creates and initializes the {@link ContentView}.
+ *
+ * @param nativeWebContents The native web contents pointer.
+ */
+ protected void initContentView(long nativeWebContents) {
+ setContentView(ContentView.newInstance(mContext, nativeWebContents, getWindowAndroid()));
+ }
+
+ /**
* Completes the {@link ContentView} specific initialization around a native WebContents
* pointer. {@link #getPageInfo()} will still return the {@link NativePage} if there is one.
* All initialization that needs to reoccur after a web contents swap should be added here.
@@ -709,14 +718,14 @@ public class Tab implements NavigationClient {
* NOTE: If you attempt to pass a native WebContents that does not have the same incognito
* state as this tab this call will fail.
*
- * @param nativeWebContents The native web contents pointer.
+ * @param view The content view that needs to be set as active view for the tab.
*/
- protected void initContentView(long nativeWebContents) {
+ protected void setContentView(ContentView view) {
NativePage previousNativePage = mNativePage;
mNativePage = null;
destroyNativePageInternal(previousNativePage);
- mContentView = ContentView.newInstance(mContext, nativeWebContents, getWindowAndroid());
+ mContentView = view;
mContentViewCore = mContentView.getContentViewCore();
mWebContentsDelegate = createWebContentsDelegate();
@@ -735,9 +744,10 @@ public class Tab implements NavigationClient {
if (mInfoBarContainer == null) {
// The InfoBarContainer needs to be created after the ContentView has been natively
// initialized.
+ WebContents webContents = view.getContentViewCore().getWebContents();
mInfoBarContainer = new InfoBarContainer(
(Activity) mContext, createAutoLoginProcessor(), getId(), getContentView(),
- nativeWebContents);
+ webContents);
} else {
mInfoBarContainer.onParentViewChanged(getId(), getContentView());
}
@@ -917,6 +927,19 @@ public class Tab implements NavigationClient {
@CalledByNative
private void swapWebContents(
final long newWebContents, boolean didStartLoad, boolean didFinishLoad) {
+ swapContentView(ContentView.newInstance(mContext, newWebContents, getWindowAndroid()),
+ false);
+ for (TabObserver observer : mObservers) {
+ observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
+ }
+ }
+
+ /**
+ * Called to swap out the current view with the one passed in.
+ * @param view The content view that should be swapped into the tab.
+ * @param deleteOldNativeWebContents Whether to delete the native web contents of old view.
+ */
+ protected void swapContentView(ContentView view, boolean deleteOldNativeWebContents) {
int originalWidth = 0;
int originalHeight = 0;
if (mContentViewCore != null) {
@@ -924,10 +947,10 @@ public class Tab implements NavigationClient {
originalHeight = mContentViewCore.getViewportHeightPix();
mContentViewCore.onHide();
}
- destroyContentView(false);
+ destroyContentView(deleteOldNativeWebContents);
NativePage previousNativePage = mNativePage;
mNativePage = null;
- initContentView(newWebContents);
+ setContentView(view);
// 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.
@@ -938,9 +961,6 @@ public class Tab implements NavigationClient {
mContentViewCore.attachImeAdapter();
for (TabObserver observer : mObservers) observer.onContentChanged(this);
destroyNativePageInternal(previousNativePage);
- for (TabObserver observer : mObservers) {
- observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
- }
}
@CalledByNative
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
index 55d8f8f..6247888 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java
@@ -19,6 +19,7 @@ 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;
@@ -96,7 +97,7 @@ public class InfoBarContainer extends LinearLayout {
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;
@@ -116,7 +117,7 @@ public class InfoBarContainer extends LinearLayout {
// 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) {
@@ -514,7 +515,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);
}