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

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

Issue 108803002: Make TabBase non abstract (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
Index: chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
index a53c2393d2c0c4c4bebf7684ddca39d559f1d74e..6db6b651cf193639ff58addc42af5bec45257ab3 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
@@ -584,7 +584,18 @@ public abstract class TabBase implements NavigationClient {
/**
* Initializes this {@link TabBase}.
*/
- public void initialize() { }
+ public void initialize() {
+ initializeNative();
+ }
+
+ /**
+ * Builds the native counterpart to this class. Meant to be overridden by subclasses to build
Yaron 2013/12/06 21:25:52 Update the class-level comment to comment on this.
David Trainor- moved to gerrit 2013/12/17 19:53:07 Done.
+ * subclass native counterparts instead.
+ */
+ protected void initializeNative() {
+ if (mNativeTabAndroid == 0) nativeInit();
+ assert mNativeTabAndroid != 0;
+ }
/**
* A helper method to initialize a {@link ContentView} without any native WebContents pointer.
@@ -636,8 +647,9 @@ public abstract class TabBase implements NavigationClient {
/**
* Cleans up all internal state, destroying any {@link NativePage} or {@link ContentView}
- * currently associated with this {@link TabBase}. Typically, pnce this call is made this
- * {@link TabBase} should no longer be used as subclasses usually destroy the native component.
+ * currently associated with this {@link TabBase}. This also destroys the native counterpart
+ * to this class, which means that all subclasses should erase their native pointers after
+ * this method is called. Once this call is made this {@link TabBase} should no longer be used.
*/
public void destroy() {
for (TabObserver observer : mObservers) observer.onDestroyed(this);
@@ -646,6 +658,15 @@ public abstract class TabBase implements NavigationClient {
mNativePage = null;
destroyNativePageInternal(currentNativePage);
destroyContentView(true);
+
+ // Destroys the native tab after destroying the ContentView but before destroying the
+ // InfoBarContainer. The native tab should be destroyed before the infobar container as
+ // destroying the native tab cleanups up any remaining infobars. The infobar container
+ // expects all infobars to be cleaned up before its own destruction.
+ assert mNativeTabAndroid != 0;
+ nativeDestroy(mNativeTabAndroid);
+ assert mNativeTabAndroid == 0;
+
if (mInfoBarContainer != null) {
mInfoBarContainer.destroy();
mInfoBarContainer = null;
@@ -845,6 +866,8 @@ public abstract class TabBase implements NavigationClient {
sIdCounter.addAndGet(diff);
}
+ private native void nativeInit();
+ private native void nativeDestroy(long nativeTabAndroid);
private native void nativeInitWebContents(long nativeTabAndroid, boolean incognito,
ContentViewCore contentViewCore, ChromeWebContentsDelegateAndroid delegate,
ContextMenuPopulator contextMenuPopulator);

Powered by Google App Engine
This is Rietveld 408576698