OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 private AwAutofillClient mAwAutofillClient; | 283 private AwAutofillClient mAwAutofillClient; |
284 | 284 |
285 private AwPdfExporter mAwPdfExporter; | 285 private AwPdfExporter mAwPdfExporter; |
286 | 286 |
287 private AwViewMethods mAwViewMethods; | 287 private AwViewMethods mAwViewMethods; |
288 private final FullScreenTransitionsState mFullScreenTransitionsState; | 288 private final FullScreenTransitionsState mFullScreenTransitionsState; |
289 | 289 |
290 private PostMessageSender mPostMessageSender; | 290 private PostMessageSender mPostMessageSender; |
291 | 291 |
292 // This flag indicates that ShouldOverrideUrlNavigation should be posted | |
293 // through the resourcethrottle. This is only used for popup windows. | |
294 private boolean mDeferredShouldOverrideUrlLoadingIsPendingForPopup; | |
295 | |
296 // This is a workaround for some qualcomm devices discarding buffer on | 292 // This is a workaround for some qualcomm devices discarding buffer on |
297 // Activity restore. | 293 // Activity restore. |
298 private boolean mInvalidateRootViewOnNextDraw; | 294 private boolean mInvalidateRootViewOnNextDraw; |
299 | 295 |
300 // The framework may temporarily detach our container view, for example duri
ng layout if | 296 // The framework may temporarily detach our container view, for example duri
ng layout if |
301 // we are a child of a ListView. This may cause many toggles of View focus,
which we suppress | 297 // we are a child of a ListView. This may cause many toggles of View focus,
which we suppress |
302 // when in this state. | 298 // when in this state. |
303 private boolean mTemporarilyDetached; | 299 private boolean mTemporarilyDetached; |
304 | 300 |
305 private Handler mHandler; | 301 private Handler mHandler; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 // callback to the correct WebViewClient that is associated with the WebView
. | 491 // callback to the correct WebViewClient that is associated with the WebView
. |
496 // Otherwise, use this delegate only to post onPageStarted messages. | 492 // Otherwise, use this delegate only to post onPageStarted messages. |
497 // | 493 // |
498 // We are not using WebContentsObserver.didStartLoading because of stale URL
s, out of order | 494 // We are not using WebContentsObserver.didStartLoading because of stale URL
s, out of order |
499 // onPageStarted's and double onPageStarted's. | 495 // onPageStarted's and double onPageStarted's. |
500 // | 496 // |
501 private class InterceptNavigationDelegateImpl implements InterceptNavigation
Delegate { | 497 private class InterceptNavigationDelegateImpl implements InterceptNavigation
Delegate { |
502 @Override | 498 @Override |
503 public boolean shouldIgnoreNavigation(NavigationParams navigationParams)
{ | 499 public boolean shouldIgnoreNavigation(NavigationParams navigationParams)
{ |
504 final String url = navigationParams.url; | 500 final String url = navigationParams.url; |
| 501 |
| 502 final int transitionType = navigationParams.pageTransitionType; |
| 503 final boolean isLoadUrl = (transitionType & PageTransition.FROM_API)
!= 0; |
| 504 final boolean isBackForward = (transitionType & PageTransition.FORWA
RD_BACK) != 0; |
| 505 final boolean isReload = |
| 506 (transitionType & PageTransition.CORE_MASK) == PageTransitio
n.RELOAD; |
| 507 final boolean isRedirect = navigationParams.isRedirect; |
| 508 |
505 boolean ignoreNavigation = false; | 509 boolean ignoreNavigation = false; |
506 if (mDeferredShouldOverrideUrlLoadingIsPendingForPopup) { | 510 // Any navigation from loadUrl, goBack/Forward, or reload, are consi
dered application |
507 mDeferredShouldOverrideUrlLoadingIsPendingForPopup = false; | 511 // initiated and hence will not yield a shouldOverrideUrlLoading() c
allback. |
508 // If this is used for all navigations in future, cases for appl
ication initiated | 512 if ((!isLoadUrl || isRedirect) && !isBackForward && !isReload |
509 // load, redirect and backforward should also be filtered out. | 513 && !navigationParams.isPost) { |
510 if (!navigationParams.isPost) { | 514 ignoreNavigation = mContentsClient.shouldIgnoreNavigation(mConte
xt, url, |
511 ignoreNavigation = mContentsClient.shouldIgnoreNavigation( | 515 navigationParams.isMainFrame, |
512 mContext, url, navigationParams.isMainFrame, | 516 navigationParams.hasUserGesture || navigationParams.hasU
serGestureCarryover, |
513 navigationParams.hasUserGesture | 517 navigationParams.isRedirect); |
514 || navigationParams.hasUserGestureCarryover, | |
515 navigationParams.isRedirect); | |
516 } | |
517 } | 518 } |
| 519 |
518 // The shouldOverrideUrlLoading call might have resulted in posting
messages to the | 520 // The shouldOverrideUrlLoading call might have resulted in posting
messages to the |
519 // UI thread. Using sendMessage here (instead of calling onPageStart
ed directly) | 521 // UI thread. Using sendMessage here (instead of calling onPageStart
ed directly) |
520 // will allow those to run in order. | 522 // will allow those to run in order. |
521 if (!ignoreNavigation) { | 523 if (isRedirect) { |
| 524 mContentsClient.getCallbackHelper().postOnPageStarted(url); |
| 525 // We can post onPageFinished here since we know that the naviga
tion will fail. |
| 526 // Also AwWebContentsObserver.didFail does not call OnPageFinish
ed when the |
| 527 // navigation is overridden because we don't want an onPageFinis
hed for such a |
| 528 // navigation unless it is a redirect. |
| 529 if (ignoreNavigation) { |
| 530 mContentsClient.getCallbackHelper().postOnPageFinished(url); |
| 531 } |
| 532 } else if (!ignoreNavigation) { |
522 mContentsClient.getCallbackHelper().postOnPageStarted(url); | 533 mContentsClient.getCallbackHelper().postOnPageStarted(url); |
523 } | 534 } |
524 return ignoreNavigation; | 535 return ignoreNavigation; |
525 } | 536 } |
526 } | 537 } |
527 | 538 |
528 //--------------------------------------------------------------------------
------------------ | 539 //--------------------------------------------------------------------------
------------------ |
529 private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate { | 540 private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate { |
530 @Override | 541 @Override |
531 public void requestLayout() { | 542 public void requestLayout() { |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 nativeDestroy(popupNativeAwContents); | 1011 nativeDestroy(popupNativeAwContents); |
1001 return; | 1012 return; |
1002 } | 1013 } |
1003 | 1014 |
1004 newContents.receivePopupContents(popupNativeAwContents); | 1015 newContents.receivePopupContents(popupNativeAwContents); |
1005 } | 1016 } |
1006 | 1017 |
1007 // Recap: supplyContentsForPopup() is called on the parent window's content,
this method is | 1018 // Recap: supplyContentsForPopup() is called on the parent window's content,
this method is |
1008 // called on the popup window's content. | 1019 // called on the popup window's content. |
1009 private void receivePopupContents(long popupNativeAwContents) { | 1020 private void receivePopupContents(long popupNativeAwContents) { |
1010 mDeferredShouldOverrideUrlLoadingIsPendingForPopup = true; | |
1011 // Save existing view state. | 1021 // Save existing view state. |
1012 final boolean wasAttached = mIsAttachedToWindow; | 1022 final boolean wasAttached = mIsAttachedToWindow; |
1013 final boolean wasViewVisible = mIsViewVisible; | 1023 final boolean wasViewVisible = mIsViewVisible; |
1014 final boolean wasWindowVisible = mIsWindowVisible; | 1024 final boolean wasWindowVisible = mIsWindowVisible; |
1015 final boolean wasPaused = mIsPaused; | 1025 final boolean wasPaused = mIsPaused; |
1016 final boolean wasFocused = mContainerViewFocused; | 1026 final boolean wasFocused = mContainerViewFocused; |
1017 final boolean wasWindowFocused = mWindowFocused; | 1027 final boolean wasWindowFocused = mWindowFocused; |
1018 | 1028 |
1019 // Properly clean up existing mContentViewCore and mNativeAwContents. | 1029 // Properly clean up existing mContentViewCore and mNativeAwContents. |
1020 if (wasFocused) onFocusChanged(false, 0, null); | 1030 if (wasFocused) onFocusChanged(false, 0, null); |
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3230 long resources); | 3240 long resources); |
3231 | 3241 |
3232 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, | 3242 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, |
3233 String message, String targetOrigin, int[] msgPorts); | 3243 String message, String targetOrigin, int[] msgPorts); |
3234 | 3244 |
3235 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); | 3245 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); |
3236 | 3246 |
3237 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); | 3247 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); |
3238 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); | 3248 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); |
3239 } | 3249 } |
OLD | NEW |