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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 1155713005: Use a resource throttle to implement shouldOverrideUrlLoading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add flag showing that shouldOverrideUrl cancelled the navigation Created 5 years, 6 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 unified diff | Download patch
OLDNEW
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // callback to the correct WebViewClient that is associated with the WebView . 465 // callback to the correct WebViewClient that is associated with the WebView .
466 // Otherwise, use this delegate only to post onPageStarted messages. 466 // Otherwise, use this delegate only to post onPageStarted messages.
467 // 467 //
468 // We are not using WebContentsObserver.didStartLoading because of stale URL s, out of order 468 // We are not using WebContentsObserver.didStartLoading because of stale URL s, out of order
469 // onPageStarted's and double onPageStarted's. 469 // onPageStarted's and double onPageStarted's.
470 // 470 //
471 private class InterceptNavigationDelegateImpl implements InterceptNavigation Delegate { 471 private class InterceptNavigationDelegateImpl implements InterceptNavigation Delegate {
472 @Override 472 @Override
473 public boolean shouldIgnoreNavigation(NavigationParams navigationParams) { 473 public boolean shouldIgnoreNavigation(NavigationParams navigationParams) {
474 final String url = navigationParams.url; 474 final String url = navigationParams.url;
475
476 final int transitionType = navigationParams.pageTransitionType;
477 final boolean isLoadUrl =
478 (transitionType & PageTransition.FROM_API) != 0;
479 final boolean isBackForward =
480 (transitionType & PageTransition.FORWARD_BACK) != 0;
481 final boolean isReload =
482 (transitionType & PageTransition.CORE_MASK) == PageTransitio n.RELOAD;
483 final boolean isRedirect = navigationParams.isRedirect;
484
475 boolean ignoreNavigation = false; 485 boolean ignoreNavigation = false;
476 if (mDeferredShouldOverrideUrlLoadingIsPendingForPopup) { 486 // Any navigation from loadUrl, goBack/Forward, or reload, are consi dered application
477 mDeferredShouldOverrideUrlLoadingIsPendingForPopup = false; 487 // initiated and hence will not yield a shouldOverrideUrlLoading() c allback.
488 if ((isLoadUrl && !isRedirect) || isBackForward) {
478 // If this is used for all navigations in future, cases for appl ication initiated 489 // If this is used for all navigations in future, cases for appl ication initiated
479 // load, redirect and backforward should also be filtered out. 490 // load, redirect and backforward should also be filtered out.
sgurun-gerrit only 2015/06/05 07:52:49 no-op if expression is true? you should be able to
gsennton 2015/06/08 14:07:23 Done.
480 if (!navigationParams.isPost) { 491 } else if (!navigationParams.isPost) {
481 ignoreNavigation = mContentsClient.shouldOverrideUrlLoading( url); 492 ignoreNavigation = mContentsClient.shouldOverrideUrlLoading(url) ;
482 }
483 } 493 }
494
484 // The shouldOverrideUrlLoading call might have resulted in posting messages to the 495 // The shouldOverrideUrlLoading call might have resulted in posting messages to the
485 // UI thread. Using sendMessage here (instead of calling onPageStart ed directly) 496 // UI thread. Using sendMessage here (instead of calling onPageStart ed directly)
486 // will allow those to run in order. 497 // will allow those to run in order.
487 if (!ignoreNavigation) { 498 if (isRedirect) {
499 mContentsClient.getCallbackHelper().postOnPageStarted(url);
500 // We can post onPageFinished here since we know that the naviga tion will fail.
501 // Also AwWebContentsObserver.didFail does not call OnPageFinish ed when the
502 // navigation is overridden because we don't want an onPageFinis hed for such a
503 // navigation unless it is a redirect.
504 if (ignoreNavigation) {
505 mContentsClient.getCallbackHelper().postOnPageFinished(url);
506 }
507 } else if (!ignoreNavigation) {
488 mContentsClient.getCallbackHelper().postOnPageStarted(url); 508 mContentsClient.getCallbackHelper().postOnPageStarted(url);
489 } 509 }
490 return ignoreNavigation; 510 return ignoreNavigation;
491 } 511 }
492 } 512 }
493 513
494 //-------------------------------------------------------------------------- ------------------ 514 //-------------------------------------------------------------------------- ------------------
495 private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate { 515 private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate {
496 @Override 516 @Override
497 public void requestLayout() { 517 public void requestLayout() {
(...skipping 2569 matching lines...) Expand 10 before | Expand all | Expand 10 after
3067 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); 3087 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter);
3068 3088
3069 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, 3089 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin,
3070 long resources); 3090 long resources);
3071 3091
3072 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, 3092 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId,
3073 String message, String targetOrigin, int[] msgPorts); 3093 String message, String targetOrigin, int[] msgPorts);
3074 3094
3075 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess agePort[] ports); 3095 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess agePort[] ports);
3076 } 3096 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698