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

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

Issue 11351002: Fix ChromiumTestShellTestBase. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Nits Created 8 years, 2 months 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 | chrome/android/java/src/org/chromium/chrome/browser/TabObserver.java » ('j') | 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/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,
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/TabObserver.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698