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

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

Issue 981243006: Upstream an initial implementation of Tab.getProgress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | no next file » | 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/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
index aa978b9dcd4dcf1efa3f261ddfc78d1180693a6a..72e93ea4c7666289fd388dfa6ca6a9943578ca46 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/Tab.java
@@ -109,6 +109,12 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
public static final int INVALID_TAB_ID = -1;
private static final long INVALID_TIMESTAMP = -1;
+ /**
+ * The required page load percentage for the page to be considered ready assuming the
+ * TextureView is also ready.
+ */
+ private static final int CONSIDERED_READY_LOAD_PERCENTAGE = 100;
+
/** Used for logging. */
private static final String TAG = "Tab";
@@ -986,12 +992,33 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
}
}
+ /**
+ * @return Whether or not the loading and rendering of the page is done.
+ */
+ @VisibleForTesting
+ public boolean isLoadingAndRenderingDone() {
+ return isReady() && getProgress() >= CONSIDERED_READY_LOAD_PERCENTAGE;
+ }
+
/** Stop the current navigation. */
public void stopLoading() {
+ if (isLoading()) {
+ RewindableIterator<TabObserver> observers = getTabObservers();
+ while (observers.hasNext()) observers.next().onPageLoadFinished(this);
+ }
if (getWebContents() != null) getWebContents().stop();
}
/**
+ * @return a value between 0 and 100 reflecting what percentage of the page load is complete.
+ */
+ public int getProgress() {
+ ChromeWebContentsDelegateAndroid delegate = getChromeWebContentsDelegateAndroid();
+ if (delegate == null) return 0;
+ return isLoading() ? delegate.getMostRecentProgress() : 100;
+ }
+
+ /**
* @return The background color of the tab.
*/
public int getBackgroundColor() {
@@ -1174,6 +1201,12 @@ public class Tab implements ViewGroup.OnHierarchyChangeListener,
showInternal(type);
+ // If the page is still loading, update the progress bar (otherwise it would not show
+ // until the renderer notifies of new progress being made).
+ if (getProgress() < 100 && !isShowingInterstitialPage()) {
+ notifyLoadProgress(getProgress());
+ }
+
// Updating the timestamp has to happen after the showInternal() call since subclasses
// may use it for logging.
mTimestampMillis = System.currentTimeMillis();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698