Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java |
| index 9a144443c3aeefc1974a1fef69d5bb4acb3d5972..5709268edd44fe26e77ab7bf6d37ae0f3d268075 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java |
| @@ -8,7 +8,6 @@ import org.chromium.base.CalledByNative; |
| import org.chromium.base.ObserverList; |
| import org.chromium.base.TraceEvent; |
| import org.chromium.chrome.browser.Tab; |
| -import org.chromium.chrome.browser.profiles.Profile; |
| import org.chromium.chrome.browser.util.MathUtils; |
| import org.chromium.content_public.browser.WebContents; |
| @@ -18,7 +17,7 @@ import java.util.List; |
| /** |
| * This is the default implementation of the {@link TabModel} interface. |
| */ |
| -public abstract class TabModelBase implements TabModel { |
| +public abstract class TabModelBase extends TabModelJniBridge { |
| private static final String TAG = "TabModelBase"; |
| /** |
| @@ -29,8 +28,6 @@ public abstract class TabModelBase implements TabModel { |
| */ |
| private final List<Tab> mTabs = new ArrayList<Tab>(); |
| - private final boolean mIsIncognito; |
| - |
| private final TabModelOrderController mOrderController; |
| protected final TabModelDelegate mModelDelegate; |
| @@ -52,12 +49,12 @@ public abstract class TabModelBase implements TabModel { |
| */ |
| private int mIndex = INVALID_TAB_INDEX; |
| - /** Native Tab pointer which will be set by nativeInit(). */ |
| + /** Native TabModelBase pointer which will be set by nativeInit(). */ |
| private long mNativeTabModelImpl = 0; |
| public TabModelBase(boolean incognito, TabModelOrderController orderController, |
| TabModelDelegate modelDelegate) { |
| - mIsIncognito = incognito; |
| + super(incognito); |
| mNativeTabModelImpl = nativeInit(incognito); |
|
David Trainor- moved to gerrit
2014/10/09 20:43:42
Want to drive this from the base class? Like a in
|
| mOrderController = orderController; |
| mModelDelegate = modelDelegate; |
| @@ -65,30 +62,17 @@ public abstract class TabModelBase implements TabModel { |
| } |
| @Override |
| - public Profile getProfile() { |
| - return nativeGetProfileAndroid(mNativeTabModelImpl); |
| - } |
| - |
| - @Override |
| - public boolean isIncognito() { |
| - return mIsIncognito; |
| - } |
| - |
| - @Override |
| public void destroy() { |
| for (Tab tab : mTabs) { |
| if (tab.isInitialized()) tab.destroy(); |
| } |
| mRewoundList.destroy(); |
| - |
| - if (mNativeTabModelImpl != 0) { |
| - nativeDestroy(mNativeTabModelImpl); |
| - mNativeTabModelImpl = 0; |
| - } |
| - |
| mTabs.clear(); |
| mObservers.clear(); |
| + |
| + super.destroy(); |
| + mNativeTabModelImpl = 0; |
| } |
| @Override |
| @@ -111,12 +95,12 @@ public abstract class TabModelBase implements TabModel { |
| for (TabModelObserver obs : mObservers) obs.willAddTab(tab, type); |
| - boolean selectTab = mOrderController.willOpenInForeground(type, mIsIncognito); |
| + boolean selectTab = mOrderController.willOpenInForeground(type, isIncognito()); |
| index = mOrderController.determineInsertionIndex(type, index, tab); |
| assert index <= mTabs.size(); |
| - assert tab.isIncognito() == mIsIncognito; |
| + assert tab.isIncognito() == isIncognito(); |
| // TODO(dtrainor): Update the list of undoable tabs instead of committing it. |
| commitAllTabClosures(); |
| @@ -143,12 +127,12 @@ public abstract class TabModelBase implements TabModel { |
| mModelDelegate.didChange(); |
| mModelDelegate.didCreateNewTab(tab); |
| - if (mNativeTabModelImpl != 0) nativeTabAddedToModel(mNativeTabModelImpl, tab); |
| + tabAddedToModel(tab); |
| for (TabModelObserver obs : mObservers) obs.didAddTab(tab, type); |
| if (selectTab) { |
| - mModelDelegate.selectModel(mIsIncognito); |
| + mModelDelegate.selectModel(isIncognito()); |
| setIndex(newIndex, TabModel.TabSelectionType.FROM_NEW); |
| } |
| @@ -194,9 +178,9 @@ public abstract class TabModelBase implements TabModel { |
| } |
| private Tab findTabInAllTabModels(int tabId) { |
| - Tab tab = TabModelUtils.getTabById(mModelDelegate.getModel(mIsIncognito), tabId); |
| + Tab tab = TabModelUtils.getTabById(mModelDelegate.getModel(isIncognito()), tabId); |
| if (tab != null) return tab; |
| - return TabModelUtils.getTabById(mModelDelegate.getModel(!mIsIncognito), tabId); |
| + return TabModelUtils.getTabById(mModelDelegate.getModel(!isIncognito()), tabId); |
| } |
| @Override |
| @@ -222,7 +206,7 @@ public abstract class TabModelBase implements TabModel { |
| nextTab = parentTab; |
| } else if (adjacentTab != null) { |
| nextTab = adjacentTab; |
| - } else if (mIsIncognito) { |
| + } else if (isIncognito()) { |
| nextTab = TabModelUtils.getCurrentTab(mModelDelegate.getModel(false)); |
| } |
| @@ -236,7 +220,7 @@ public abstract class TabModelBase implements TabModel { |
| @Override |
| public boolean supportsPendingClosures() { |
| - return !mIsIncognito; |
| + return !isIncognito(); |
| } |
| @Override |
| @@ -401,16 +385,6 @@ public abstract class TabModelBase implements TabModel { |
| } |
| /** |
| - * @param incognito |
| - * @param nativeWebContents |
| - * @param parentId |
| - * @return |
| - */ |
| - @CalledByNative |
| - protected abstract Tab createTabWithNativeContents(boolean incognito, long nativeWebContents, |
| - int parentId); |
| - |
| - /** |
| * Performs the necessary actions to remove this {@link Tab} from this {@link TabModel}. |
| * This does not actually destroy the {@link Tab} (see |
| * {@link #finalizeTabClosure(Tab)}. |
| @@ -479,7 +453,7 @@ public abstract class TabModelBase implements TabModel { |
| * rewindable closes were undone). If there are no possible rewindable closes this list |
| * should match {@link #mTabs}. |
| */ |
| - private List<Tab> mRewoundTabs = new ArrayList<Tab>(); |
| + private final List<Tab> mRewoundTabs = new ArrayList<Tab>(); |
| @Override |
| public boolean isIncognito() { |
| @@ -594,33 +568,16 @@ public abstract class TabModelBase implements TabModel { |
| } |
| } |
| - /** |
| - * Broadcast a notification (in native code) that all tabs are now loaded from storage. |
| - */ |
| - public void broadcastSessionRestoreComplete() { |
| - nativeBroadcastSessionRestoreComplete(mNativeTabModelImpl); |
| - } |
| - |
| - // JNI related methods ------------------------------------------------------------------------- |
| - |
| @Override |
| - @CalledByNative |
| public int getCount() { |
| return mTabs.size(); |
| } |
| @Override |
| - @CalledByNative |
| public int index() { |
| return mIndex; |
| } |
| - @SuppressWarnings("unused") |
| - @CalledByNative |
| - private void setIndex(int index) { |
| - TabModelUtils.setIndex(this, index); |
| - } |
| - |
| /** |
| * Used by Developer Tools to create a new tab with a given URL. |
| * |
| @@ -630,14 +587,10 @@ public abstract class TabModelBase implements TabModel { |
| @CalledByNative |
| protected abstract Tab createNewTabForDevTools(String url); |
| - @CalledByNative |
| - private boolean isSessionRestoreInProgress() { |
| + @Override |
| + protected boolean isSessionRestoreInProgress() { |
| return mModelDelegate.isSessionRestoreInProgress(); |
| } |
| private native long nativeInit(boolean isIncognito); |
| - private native void nativeDestroy(long nativeTabModelBase); |
| - private native void nativeBroadcastSessionRestoreComplete(long nativeTabModelBase); |
| - private native Profile nativeGetProfileAndroid(long nativeTabModelBase); |
| - private native void nativeTabAddedToModel(long nativeTabModelBase, Tab tab); |
| } |