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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 970883002: [Android WebView] Synthesize a fake page loading event on page source modification (Re-land) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed findbugs warning Created 5 years, 10 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 | android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegate.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index c95137c7ec63a5d061f50cf0c56f4f90399adf86..6e5e528cf7be29c6f4b762dcbb528920e11c04f7 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -49,7 +49,6 @@ import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewStatics;
import org.chromium.content.browser.SmartClipProvider;
-import org.chromium.content.browser.WebContentsObserver;
import org.chromium.content.common.CleanupReference;
import org.chromium.content_public.browser.GestureStateListener;
import org.chromium.content_public.browser.JavaScriptCallback;
@@ -204,7 +203,7 @@ public class AwContents implements SmartClipProvider,
private NavigationController mNavigationController;
private final AwContentsClient mContentsClient;
private final AwContentViewClient mContentViewClient;
- private WebContentsObserver mWebContentsObserver;
+ private AwWebContentsObserver mWebContentsObserver;
private final AwContentsClientBridge mContentsClientBridge;
private final AwWebContentsDelegateAdapter mWebContentsDelegate;
private final AwContentsIoThreadClient mIoThreadClient;
@@ -227,6 +226,8 @@ public class AwContents implements SmartClipProvider,
private boolean mHasRequestedVisitedHistoryFromClient;
// TODO(boliu): This should be in a global context, not per webview.
private final double mDIPScale;
+ // Whether the WebView has attempted to do any load (including uncommitted loads).
+ private boolean mDidAttemptLoad = false;
// The base background color, i.e. not accounting for any CSS body from the current page.
private int mBaseBackgroundColor = Color.WHITE;
@@ -908,6 +909,9 @@ public class AwContents implements SmartClipProvider,
if (wasWindowFocused) onWindowFocusChanged(wasWindowFocused);
if (wasFocused) onFocusChanged(true, 0, null);
+ // Popups are always assumed as having made a load attempt.
+ mDidAttemptLoad = true;
+
// Restore injected JavaScript interfaces.
for (Map.Entry<String, Pair<Object, Class>> entry : javascriptInterfaces.entrySet()) {
@SuppressWarnings("unchecked")
@@ -1239,6 +1243,19 @@ public class AwContents implements SmartClipProvider,
return url;
}
+ /**
+ * Gets the last committed URL. It represents the current page that is
+ * displayed in WebContents. It represents the current security context.
+ *
+ * @return The URL of the current page or null if it's empty.
+ */
+ public String getLastCommittedUrl() {
+ if (isDestroyed()) return null;
+ String url = mWebContents.getLastCommittedUrl();
+ if (url == null || url.trim().isEmpty()) return null;
+ return url;
+ }
+
public void requestFocus() {
mAwViewMethods.requestFocus();
}
@@ -1838,6 +1855,11 @@ public class AwContents implements SmartClipProvider,
return ports;
}
+ public boolean hasAccessedInitialDocument() {
+ if (isDestroyed()) return false;
+ return mWebContents.hasAccessedInitialDocument();
+ }
+
//--------------------------------------------------------------------------------------------
// View and ViewGroup method implementations
//--------------------------------------------------------------------------------------------
@@ -2072,6 +2094,12 @@ public class AwContents implements SmartClipProvider,
nativeInsertVisualStateCallback(mNativeAwContents, requestId, callback);
}
+ public boolean getDidAttemptLoad() {
+ if (mDidAttemptLoad) return mDidAttemptLoad;
+ mDidAttemptLoad = mWebContentsObserver.hasStartedAnyProvisionalLoad();
+ return mDidAttemptLoad;
+ }
+
//--------------------------------------------------------------------------------------------
// Methods called from native via JNI
//--------------------------------------------------------------------------------------------
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegate.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698