| 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 7e1fb81fbad42dfd5228e96286282990de47ab9a..bdd081eee71d9f477e96a4800862d32a9ad29d8c 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/TabBase.java
|
| @@ -15,6 +15,10 @@ import org.chromium.content.browser.LoadUrlParams;
|
| import org.chromium.content.common.CleanupReference;
|
| import org.chromium.ui.gfx.NativeWindow;
|
|
|
| +import java.util.ArrayList;
|
| +import java.util.List;
|
| +
|
| +
|
| /**
|
| * The basic Java representation of a tab. Contains and manages a {@link ContentView}.
|
| */
|
| @@ -23,19 +27,20 @@ public class TabBase {
|
| private ContentView mContentView;
|
| private ChromeWebContentsDelegateAndroid mWebContentsDelegate;
|
| private int mNativeTabBaseAndroidImpl;
|
| + private List<TabObserver> mObservers = new ArrayList<TabObserver>();
|
|
|
| private CleanupReference mCleanupReference;
|
|
|
| + // Tab state
|
| + private boolean mIsLoading = false;
|
| +
|
| /**
|
| * @param context The Context the view is running in.
|
| * @param url The URL to start this tab with.
|
| * @param window The NativeWindow should represent this tab.
|
| - * @param delegate The {@link ChromeWebContentsDelegateAndroid} that should be notified of any
|
| - * WebContents changes.
|
| */
|
| - public TabBase(Context context, String url, NativeWindow window,
|
| - ChromeWebContentsDelegateAndroid delegate) {
|
| - this(context, 0, window, delegate);
|
| + public TabBase(Context context, String url, NativeWindow window) {
|
| + this(context, 0, window);
|
| loadUrlWithSanitization(url);
|
| }
|
|
|
| @@ -43,11 +48,8 @@ public class TabBase {
|
| * @param context The Context the view is running in.
|
| * @param nativeWebContents A native pointer to the WebContents this tab represents.
|
| * @param window The NativeWindow should represent this tab.
|
| - * @param delegate The {@link ChromeWebContentsDelegateAndroid} that should be notified
|
| - * of any WebContents changes.
|
| */
|
| - public TabBase(Context context, int nativeWebContentsPtr,
|
| - NativeWindow window, ChromeWebContentsDelegateAndroid delegate) {
|
| + public TabBase(Context context, int nativeWebContentsPtr, NativeWindow window) {
|
| mWindow = window;
|
|
|
| // Build the WebContents and the ContentView/ContentViewCore
|
| @@ -59,7 +61,7 @@ public class TabBase {
|
| mNativeTabBaseAndroidImpl = nativeInit(nativeWebContentsPtr, window.getNativePointer());
|
|
|
| // Build the WebContentsDelegate
|
| - mWebContentsDelegate = delegate == null ? new ChromeWebContentsDelegateAndroid() : delegate;
|
| + mWebContentsDelegate = new TabBaseChromeWebContentsDelegateAndroid();
|
| nativeInitWebContentsDelegate(mNativeTabBaseAndroidImpl, mWebContentsDelegate);
|
|
|
| // To be called after everything is initialized.
|
| @@ -80,6 +82,27 @@ public class TabBase {
|
| }
|
|
|
| /**
|
| + * @param observer The {@link TabObserver} that should be notified of changes.
|
| + */
|
| + public void addObserver(TabObserver observer) {
|
| + mObservers.add(observer);
|
| + }
|
| +
|
| + /**
|
| + * @param observer The {@link TabObserver} that should no longer be notified of changes.
|
| + */
|
| + public void removeObserver(TabObserver observer) {
|
| + mObservers.remove(observer);
|
| + }
|
| +
|
| + /**
|
| + * @return Whether or not the tab is currently loading.
|
| + */
|
| + public boolean isLoading() {
|
| + return mIsLoading;
|
| + }
|
| +
|
| + /**
|
| * @return The {@link ContentView} represented by this tab.
|
| */
|
| public ContentView getContentView() {
|
| @@ -131,6 +154,32 @@ public class TabBase {
|
| }
|
| }
|
|
|
| + private class TabBaseChromeWebContentsDelegateAndroid extends ChromeWebContentsDelegateAndroid {
|
| + @Override
|
| + public void onLoadProgressChanged(int progress) {
|
| + for (int i = 0; i < mObservers.size(); ++i) {
|
| + mObservers.get(i).onLoadProgressChanged(TabBase.this, progress);
|
| + }
|
| + }
|
| +
|
| + @Override
|
| + public void onUpdateUrl(String url) {
|
| + for (int i = 0; i < mObservers.size(); ++i) {
|
| + mObservers.get(i).onUpdateUrl(TabBase.this, url);
|
| + }
|
| + }
|
| +
|
| + @Override
|
| + public void onLoadStarted() {
|
| + mIsLoading = true;
|
| + }
|
| +
|
| + @Override
|
| + public void onLoadStopped() {
|
| + mIsLoading = false;
|
| + }
|
| + }
|
| +
|
| private native int nativeInit(int webContentsPtr, int windowAndroidPtr);
|
| private static native void nativeDestroy(int nativeTabBaseAndroidImpl);
|
| private native void nativeInitWebContentsDelegate(int nativeTabBaseAndroidImpl,
|
|
|