| 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 330cd07ca86e4916a91eac67ebd9241ca3701c2a..40f0dbe23b454583f30dd65b01a0f629bfa52314 100644
|
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
|
| @@ -55,8 +55,10 @@ import org.chromium.content_public.Referrer;
|
| import org.chromium.content_public.browser.GestureStateListener;
|
| import org.chromium.content_public.browser.JavaScriptCallback;
|
| import org.chromium.content_public.browser.LoadUrlParams;
|
| +import org.chromium.content_public.browser.NavigationController;
|
| import org.chromium.content_public.browser.NavigationHistory;
|
| import org.chromium.content_public.browser.PageTransitionTypes;
|
| +import org.chromium.content_public.browser.WebContents;
|
| import org.chromium.ui.base.ActivityWindowAndroid;
|
| import org.chromium.ui.base.WindowAndroid;
|
| import org.chromium.ui.gfx.DeviceDisplayInfo;
|
| @@ -183,6 +185,8 @@ public class AwContents {
|
| private final Context mContext;
|
| private ContentViewCore mContentViewCore;
|
| private WindowAndroid mWindowAndroid;
|
| + private WebContents mWebContents;
|
| + private NavigationController mNavigationController;
|
| private final AwContentsClient mContentsClient;
|
| private final AwContentViewClient mContentViewClient;
|
| private WebContentsObserverAndroid mWebContentsObserver;
|
| @@ -746,6 +750,8 @@ public class AwContents {
|
| if (mNativeAwContents != 0) {
|
| destroy();
|
| mContentViewCore = null;
|
| + mWebContents = null;
|
| + mNavigationController = null;
|
| }
|
|
|
| assert mNativeAwContents == 0 && mCleanupReference == null && mContentViewCore == null;
|
| @@ -769,6 +775,8 @@ public class AwContents {
|
| new AwGestureStateListener(), mContentViewClient, mZoomControls, mWindowAndroid);
|
| nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mContentsClientBridge,
|
| mIoThreadClient, mInterceptNavigationDelegate);
|
| + mWebContents = mContentViewCore.getWebContents();
|
| + mNavigationController = mWebContents.getNavigationController();
|
| installWebContentsObserver();
|
| mSettings.setWebContents(nativeWebContents);
|
| nativeSetDipScale(mNativeAwContents, (float) mDIPScale);
|
| @@ -781,8 +789,7 @@ public class AwContents {
|
| if (mWebContentsObserver != null) {
|
| mWebContentsObserver.detachFromWebContents();
|
| }
|
| - mWebContentsObserver = new AwWebContentsObserver(mContentViewCore.getWebContents(),
|
| - mContentsClient);
|
| + mWebContentsObserver = new AwWebContentsObserver(mWebContents, mContentsClient);
|
| }
|
|
|
| /**
|
| @@ -889,6 +896,16 @@ public class AwContents {
|
| return mContentViewCore;
|
| }
|
|
|
| + @VisibleForTesting
|
| + public WebContents getWebContents() {
|
| + return mWebContents;
|
| + }
|
| +
|
| + @VisibleForTesting
|
| + public NavigationController getNavigationController() {
|
| + return mNavigationController;
|
| + }
|
| +
|
| // Can be called from any thread.
|
| public AwSettings getSettings() {
|
| return mSettings;
|
| @@ -1075,7 +1092,7 @@ public class AwContents {
|
|
|
| // If we are reloading the same url, then set transition type as reload.
|
| if (params.getUrl() != null &&
|
| - params.getUrl().equals(mContentViewCore.getUrl()) &&
|
| + params.getUrl().equals(mWebContents.getUrl()) &&
|
| params.getTransitionType() == PageTransitionTypes.PAGE_TRANSITION_LINK) {
|
| params.setTransitionType(PageTransitionTypes.PAGE_TRANSITION_RELOAD);
|
| }
|
| @@ -1109,7 +1126,7 @@ public class AwContents {
|
| }
|
| params.setExtraHeaders(new HashMap<String, String>());
|
|
|
| - mContentViewCore.loadUrl(params);
|
| + mNavigationController.loadUrl(params);
|
|
|
| // The behavior of WebViewClassic uses the populateVisitedLinks callback in WebKit.
|
| // Chromium does not use this use code path and the best emulation of this behavior to call
|
| @@ -1133,7 +1150,7 @@ public class AwContents {
|
| * @return The URL of the current page or null if it's empty.
|
| */
|
| public String getUrl() {
|
| - String url = mContentViewCore.getUrl();
|
| + String url = mWebContents.getUrl();
|
| if (url == null || url.trim().isEmpty()) return null;
|
| return url;
|
| }
|
| @@ -1324,56 +1341,56 @@ public class AwContents {
|
| * @see android.webkit.WebView#stopLoading()
|
| */
|
| public void stopLoading() {
|
| - mContentViewCore.stopLoading();
|
| + mWebContents.stop();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#reload()
|
| */
|
| public void reload() {
|
| - mContentViewCore.reload(true);
|
| + mNavigationController.reload(true);
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#canGoBack()
|
| */
|
| public boolean canGoBack() {
|
| - return mContentViewCore.canGoBack();
|
| + return mNavigationController.canGoBack();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#goBack()
|
| */
|
| public void goBack() {
|
| - mContentViewCore.goBack();
|
| + mNavigationController.goBack();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#canGoForward()
|
| */
|
| public boolean canGoForward() {
|
| - return mContentViewCore.canGoForward();
|
| + return mNavigationController.canGoForward();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#goForward()
|
| */
|
| public void goForward() {
|
| - mContentViewCore.goForward();
|
| + mNavigationController.goForward();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#canGoBackOrForward(int)
|
| */
|
| public boolean canGoBackOrForward(int steps) {
|
| - return mContentViewCore.canGoToOffset(steps);
|
| + return mNavigationController.canGoToOffset(steps);
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#goBackOrForward(int)
|
| */
|
| public void goBackOrForward(int steps) {
|
| - mContentViewCore.goToOffset(steps);
|
| + mNavigationController.goToOffset(steps);
|
| }
|
|
|
| /**
|
| @@ -1474,7 +1491,7 @@ public class AwContents {
|
| }
|
|
|
| public String getOriginalUrl() {
|
| - NavigationHistory history = mContentViewCore.getNavigationHistory();
|
| + NavigationHistory history = mNavigationController.getNavigationHistory();
|
| int currentIndex = history.getCurrentEntryIndex();
|
| if (currentIndex >= 0 && currentIndex < history.getEntryCount()) {
|
| return history.getEntryAtIndex(currentIndex).getOriginalUrl();
|
| @@ -1486,21 +1503,21 @@ public class AwContents {
|
| * @see ContentViewCore#getNavigationHistory()
|
| */
|
| public NavigationHistory getNavigationHistory() {
|
| - return mContentViewCore.getNavigationHistory();
|
| + return mNavigationController.getNavigationHistory();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#getTitle()
|
| */
|
| public String getTitle() {
|
| - return mContentViewCore.getTitle();
|
| + return mWebContents.getTitle();
|
| }
|
|
|
| /**
|
| * @see android.webkit.WebView#clearHistory()
|
| */
|
| public void clearHistory() {
|
| - mContentViewCore.clearHistory();
|
| + mNavigationController.clearHistory();
|
| }
|
|
|
| public String[] getHttpAuthUsernamePassword(String host, String realm) {
|
| @@ -1526,7 +1543,7 @@ public class AwContents {
|
| * @see android.webkit.WebView#clearSslPreferences()
|
| */
|
| public void clearSslPreferences() {
|
| - mContentViewCore.clearSslPreferences();
|
| + mNavigationController.clearSslPreferences();
|
| }
|
|
|
| // TODO(sgurun) remove after this rolls in. To keep internal tree happy.
|
| @@ -1697,14 +1714,14 @@ public class AwContents {
|
| };
|
| }
|
|
|
| - mContentViewCore.evaluateJavaScript(script, jsCallback);
|
| + mWebContents.evaluateJavaScript(script, jsCallback, false);
|
| }
|
|
|
| /**
|
| * @see ContentViewCore.evaluateJavaScriptEvenIfNotYetNavigated(String)
|
| */
|
| public void evaluateJavaScriptEvenIfNotYetNavigated(String script) {
|
| - mContentViewCore.evaluateJavaScriptEvenIfNotYetNavigated(script);
|
| + mWebContents.evaluateJavaScript(script, null, true);
|
| }
|
|
|
| //--------------------------------------------------------------------------------------------
|
| @@ -1854,7 +1871,7 @@ public class AwContents {
|
| // but is optimized out in the restoreState case because the title is
|
| // already restored. See WebContentsImpl::UpdateTitleForEntry. So we
|
| // call the callback explicitly here.
|
| - if (result) mContentsClient.onReceivedTitle(mContentViewCore.getTitle());
|
| + if (result) mContentsClient.onReceivedTitle(mWebContents.getTitle());
|
|
|
| return result;
|
| }
|
|
|