Chromium Code Reviews| 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); |