Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3575)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 1502153002: Revert of [Android] Support infobars on native page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index 8066da2c07fac086c255d3084dd2e76a86dafaec..10097b49d5821b637c743ef0392ccfd368b8fab3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -182,8 +182,8 @@
/** Listens to gesture events fired by the ContentViewCore. */
private GestureStateListener mGestureStateListener;
- /** The parent view of the ContentView, NativePage's view and the InfoBarContainer. */
- private FrameLayout mTabView;
+ /** The parent view of the ContentView and the InfoBarContainer. */
+ private FrameLayout mContentViewParent;
/** A list of Tab observers. These are used to broadcast Tab events to listeners. */
private final ObserverList<TabObserver> mObservers = new ObserverList<TabObserver>();
@@ -780,7 +780,7 @@
* This can be {@code null}, if the tab is frozen or being initialized or destroyed.
*/
public View getView() {
- return mTabView;
+ return mNativePage != null ? mNativePage.getView() : mContentViewParent;
}
/**
@@ -1200,13 +1200,8 @@
*/
private void showNativePage(NativePage nativePage) {
if (mNativePage == nativePage) return;
- destroyNativePage();
+ NativePage previousNativePage = mNativePage;
mNativePage = nativePage;
-
- mTabView.addView(nativePage.getView(),
- mTabView.indexOfChild(mContentViewCore.getContainerView()) + 1,
- new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
-
pushNativePageStateToNavigationEntry();
// Notifying of theme color change before content change because some of
// the observers depend on the theme information being correct in
@@ -1217,6 +1212,7 @@
for (TabObserver observer : mObservers) {
observer.onContentChanged(this);
}
+ destroyNativePageInternal(previousNativePage);
}
/**
@@ -1225,8 +1221,7 @@
*/
public void freezeNativePage() {
if (mNativePage == null || mNativePage instanceof FrozenNativePage) return;
- assert mNativePage.getView().getWindowToken() == null : "Cannot freeze visible native page";
- mTabView.removeView(mNativePage.getView());
+ assert mNativePage.getView().getParent() == null : "Cannot freeze visible native page";
mNativePage = FrozenNativePage.freeze(mNativePage);
}
@@ -1237,9 +1232,10 @@
updateTitle();
if (mNativePage == null) return;
- destroyNativePage();
+ NativePage previousNativePage = mNativePage;
+ mNativePage = null;
for (TabObserver observer : mObservers) observer.onContentChanged(this);
-
+ destroyNativePageInternal(previousNativePage);
}
/**
@@ -1507,7 +1503,9 @@
private void setContentViewCore(ContentViewCore cvc) {
try {
TraceEvent.begin("ChromeTab.setContentViewCore");
- destroyNativePage();
+ NativePage previousNativePage = mNativePage;
+ mNativePage = null;
+ destroyNativePageInternal(previousNativePage);
mContentViewCore = cvc;
cvc.getContainerView().setOnHierarchyChangeListener(this);
@@ -1518,12 +1516,12 @@
// ContentView -- causes problems since then the ContentView would contain both real
// views (the infobars) and virtual views (the web page elements), which breaks Android
// accessibility. http://crbug.com/416663
- if (mTabView != null) {
+ if (mContentViewParent != null) {
assert false;
- mTabView.removeAllViews();
- }
- mTabView = new FrameLayout(mThemedApplicationContext);
- mTabView.addView(cvc.getContainerView(),
+ mContentViewParent.removeAllViews();
+ }
+ mContentViewParent = new FrameLayout(mThemedApplicationContext);
+ mContentViewParent.addView(cvc.getContainerView(),
new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
@@ -1547,9 +1545,9 @@
// The InfoBarContainer needs to be created after the ContentView has been natively
// initialized.
mInfoBarContainer = new InfoBarContainer(
- mThemedApplicationContext, getId(), mTabView, this);
+ mThemedApplicationContext, getId(), mContentViewParent, this);
} else {
- mInfoBarContainer.onParentViewChanged(getId(), mTabView);
+ mInfoBarContainer.onParentViewChanged(getId(), mContentViewParent);
}
mInfoBarContainer.setContentViewCore(mContentViewCore);
@@ -1694,7 +1692,9 @@
for (TabObserver observer : mObservers) observer.onDestroyed(this);
mObservers.clear();
- destroyNativePage();
+ NativePage currentNativePage = mNativePage;
+ mNativePage = null;
+ destroyNativePageInternal(currentNativePage);
destroyContentViewCore(true);
// Destroys the native tab after destroying the ContentView but before destroying the
@@ -2013,12 +2013,11 @@
mGroupedWithParent = groupedWithParent;
}
- private void destroyNativePage() {
- if (mNativePage == null) return;
-
- mTabView.removeView(mNativePage.getView());
- mNativePage.destroy();
- mNativePage = null;
+ private void destroyNativePageInternal(NativePage nativePage) {
+ if (nativePage == null) return;
+ assert nativePage != mNativePage : "Attempting to destroy active page.";
+
+ nativePage.destroy();
}
/**
@@ -2050,7 +2049,7 @@
mSwipeRefreshHandler.setContentViewCore(null);
mSwipeRefreshHandler = null;
}
- mTabView = null;
+ mContentViewParent = null;
mContentViewCore.destroy();
mContentViewCore = null;
@@ -2163,6 +2162,8 @@
mContentViewCore.onHide();
}
destroyContentViewCore(deleteOldNativeWebContents);
+ NativePage previousNativePage = mNativePage;
+ mNativePage = null;
setContentViewCore(newContentViewCore);
// 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
@@ -2172,6 +2173,7 @@
mContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
mContentViewCore.onShow();
mContentViewCore.attachImeAdapter();
+ destroyNativePageInternal(previousNativePage);
mWebContentsObserver.didChangeThemeColor(
getWebContents().getThemeColor(mDefaultThemeColor));
for (TabObserver observer : mObservers) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698