diff options
| -rw-r--r-- | core/java/android/webkit/CallbackProxy.java | 43 | ||||
| -rw-r--r-- | core/java/android/webkit/WebChromeClient.java | 9 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 10 |
3 files changed, 62 insertions, 0 deletions
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java index 96bf46ec9a29..e77d29b9ffb2 100644 --- a/core/java/android/webkit/CallbackProxy.java +++ b/core/java/android/webkit/CallbackProxy.java @@ -70,6 +70,9 @@ class CallbackProxy extends Handler { private final WebBackForwardList mBackForwardList; // Used to call startActivity during url override. private final Context mContext; + // Stores the URL being loaded and the viewing mode to switch into when + // the URL finishes loading. + private ChangeViewModeOnFinishedLoad mChange; // Message Ids private static final int PAGE_STARTED = 100; @@ -177,6 +180,37 @@ class CallbackProxy extends Handler { } /** + * Tell the host application that the WebView has changed viewing modes. + * @param toZoomedOut If true, the WebView has zoomed out so that the page + * fits the screen. If false, it is zoomed to the setting + * specified by the user. + */ + /* package */ void uiOnChangeViewingMode(boolean toZoomOverview) { + if (mWebChromeClient != null) { + mWebChromeClient.onChangeViewingMode(toZoomOverview); + } + } + + private static class ChangeViewModeOnFinishedLoad { + boolean mToZoomOverView; + String mOriginalUrl; + ChangeViewModeOnFinishedLoad(boolean toZoomOverview, + String originalUrl) { + mToZoomOverView = toZoomOverview; + mOriginalUrl = originalUrl; + } + } + + /** + * Keep track of the url and the viewing mode to change into. If/when that + * url finishes loading, this will change the viewing mode. + */ + /* package */ void uiChangeViewingModeOnFinishedLoad( + boolean toZoomOverview, String originalUrl) { + if (mWebChromeClient == null) return; + mChange = new ChangeViewModeOnFinishedLoad(toZoomOverview, originalUrl); + } + /** * Called by the UI side. Calling overrideUrlLoading from the WebCore * side will post a message to call this method. */ @@ -237,6 +271,15 @@ class CallbackProxy extends Handler { if (mWebViewClient != null) { mWebViewClient.onPageFinished(mWebView, (String) msg.obj); } + if (mChange != null) { + if (mWebView.getOriginalUrl().equals(mChange.mOriginalUrl)) { + uiOnChangeViewingMode(mChange.mToZoomOverView); + } else { + // The user has gone to a different page, so there is + // no need to hang on to the old object. + mChange = null; + } + } break; case RECEIVED_ICON: diff --git a/core/java/android/webkit/WebChromeClient.java b/core/java/android/webkit/WebChromeClient.java index c10bc97de103..e1c8d4da409a 100644 --- a/core/java/android/webkit/WebChromeClient.java +++ b/core/java/android/webkit/WebChromeClient.java @@ -23,6 +23,15 @@ import android.view.View; public class WebChromeClient { /** + * Tell the host application that the WebView has changed viewing modes. + * @param toZoomedOut If true, the WebView has zoomed out so that the page + * fits the screen. If false, it is zoomed to the setting + * specified by the user. + * @hide + */ + public void onChangeViewingMode(boolean toZoomedOut) {} + + /** * Tell the host application the current progress of loading a page. * @param view The WebView that initiated the callback. * @param newProgress Current page loading progress, represented by diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index be9daa531ebe..7468aef5df75 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -521,6 +521,7 @@ public class WebView extends AbsoluteLayout // follow the links. Double tap will toggle between zoom overview mode and // the last zoom scale. boolean mInZoomOverview = false; + // ideally mZoomOverviewWidth should be mContentWidth. But sites like espn, // engadget always have wider mContentWidth no matter what viewport size is. int mZoomOverviewWidth = WebViewCore.DEFAULT_VIEWPORT_WIDTH; @@ -4687,6 +4688,7 @@ public class WebView extends AbsoluteLayout mZoomCenterX = mLastTouchX; mZoomCenterY = mLastTouchY; mInZoomOverview = !mInZoomOverview; + mCallbackProxy.uiOnChangeViewingMode(mInZoomOverview); if (mInZoomOverview) { if (getSettings().getBuiltInZoomControls()) { if (mZoomButtonsController.isVisible()) { @@ -5034,6 +5036,14 @@ public class WebView extends AbsoluteLayout mInZoomOverview = ENABLE_DOUBLETAP_ZOOM && settings.getLoadWithOverviewMode(); } + mCallbackProxy.uiOnChangeViewingMode(true); + if (!mInZoomOverview) { + // We are going to start zoomed in. However, we + // truly want to show the title bar, and then hide + // it once the page has loaded + mCallbackProxy.uiChangeViewingModeOnFinishedLoad( + false, getOriginalUrl()); + } setNewZoomScale(mLastScale, false); setContentScrollTo(restoreState.mScrollX, restoreState.mScrollY); |