Chromium Code Reviews| 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..023646374fc47f50450fdf3fca8bc2ee5d3bd6a6 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; |
|
Charlie Reis
2015/03/03 22:21:00
What about window.open() (with no arguments)? Tha
mnaganov (inactive)
2015/03/04 10:30:29
I specifically checked this case, and for WebView
|
| + |
| // 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.getDidStartProvisionalLoadForFrameFired(); |
| + return mDidAttemptLoad; |
| + } |
| + |
| //-------------------------------------------------------------------------------------------- |
| // Methods called from native via JNI |
| //-------------------------------------------------------------------------------------------- |