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

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: Rebase and fix qinmin nit Created 5 years, 5 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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 // callback to the correct WebViewClient that is associated with the WebView . 470 // callback to the correct WebViewClient that is associated with the WebView .
471 // Otherwise, use this delegate only to post onPageStarted messages. 471 // Otherwise, use this delegate only to post onPageStarted messages.
472 // 472 //
473 // We are not using WebContentsObserver.didStartLoading because of stale URL s, out of order 473 // We are not using WebContentsObserver.didStartLoading because of stale URL s, out of order
474 // onPageStarted's and double onPageStarted's. 474 // onPageStarted's and double onPageStarted's.
475 // 475 //
476 private class InterceptNavigationDelegateImpl implements InterceptNavigation Delegate { 476 private class InterceptNavigationDelegateImpl implements InterceptNavigation Delegate {
477 @Override 477 @Override
478 public boolean shouldIgnoreNavigation(NavigationParams navigationParams) { 478 public boolean shouldIgnoreNavigation(NavigationParams navigationParams) {
479 final String url = navigationParams.url; 479 final String url = navigationParams.url;
480
481 final int transitionType = navigationParams.pageTransitionType;
482 final boolean isLoadUrl = (transitionType & PageTransition.FROM_API) != 0;
483 final boolean isBackForward = (transitionType & PageTransition.FORWA RD_BACK) != 0;
484 final boolean isReload =
485 (transitionType & PageTransition.CORE_MASK) == PageTransitio n.RELOAD;
486 final boolean isRedirect = navigationParams.isRedirect;
487
480 boolean ignoreNavigation = false; 488 boolean ignoreNavigation = false;
481 if (mDeferredShouldOverrideUrlLoadingIsPendingForPopup) { 489 // Any navigation from loadUrl, goBack/Forward, or reload, are consi dered application
482 mDeferredShouldOverrideUrlLoadingIsPendingForPopup = false; 490 // initiated and hence will not yield a shouldOverrideUrlLoading() c allback.
483 // If this is used for all navigations in future, cases for appl ication initiated 491 if ((!isLoadUrl || isRedirect) && !isBackForward && !navigationParam s.isPost) {
484 // load, redirect and backforward should also be filtered out. 492 if (!mContentsClient.hasWebViewClient()) {
485 if (!navigationParams.isPost) { 493 ignoreNavigation = AwContentsClient.sendBrowsingIntent(mCont ext, url,
486 if (!mContentsClient.hasWebViewClient()) { 494 navigationParams.hasUserGesture
487 ignoreNavigation = AwContentsClient.sendBrowsingIntent(m Context, url, 495 || navigationParams.hasUserGestureCarryover,
488 navigationParams.hasUserGesture 496 navigationParams.isRedirect);
489 || navigationParams.hasUserGestureCarryover, 497 } else {
490 navigationParams.isRedirect); 498 ignoreNavigation = mContentsClient.shouldOverrideUrlLoading( url);
491 } else {
492 ignoreNavigation = mContentsClient.shouldOverrideUrlLoad ing(url);
493 }
494 } 499 }
495 } 500 }
501
496 // The shouldOverrideUrlLoading call might have resulted in posting messages to the 502 // The shouldOverrideUrlLoading call might have resulted in posting messages to the
497 // UI thread. Using sendMessage here (instead of calling onPageStart ed directly) 503 // UI thread. Using sendMessage here (instead of calling onPageStart ed directly)
498 // will allow those to run in order. 504 // will allow those to run in order.
499 if (!ignoreNavigation) { 505 if (isRedirect) {
506 mContentsClient.getCallbackHelper().postOnPageStarted(url);
507 // We can post onPageFinished here since we know that the naviga tion will fail.
508 // Also AwWebContentsObserver.didFail does not call OnPageFinish ed when the
509 // navigation is overridden because we don't want an onPageFinis hed for such a
510 // navigation unless it is a redirect.
511 if (ignoreNavigation) {
512 mContentsClient.getCallbackHelper().postOnPageFinished(url);
513 }
514 } else if (!ignoreNavigation) {
500 mContentsClient.getCallbackHelper().postOnPageStarted(url); 515 mContentsClient.getCallbackHelper().postOnPageStarted(url);
501 } 516 }
502 return ignoreNavigation; 517 return ignoreNavigation;
503 } 518 }
504 } 519 }
505 520
506 //-------------------------------------------------------------------------- ------------------ 521 //-------------------------------------------------------------------------- ------------------
507 private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate { 522 private class AwLayoutSizerDelegate implements AwLayoutSizer.Delegate {
508 @Override 523 @Override
509 public void requestLayout() { 524 public void requestLayout() {
(...skipping 2594 matching lines...) Expand 10 before | Expand all | Expand 10 after
3104 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); 3119 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter);
3105 3120
3106 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, 3121 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin,
3107 long resources); 3122 long resources);
3108 3123
3109 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, 3124 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId,
3110 String message, String targetOrigin, int[] msgPorts); 3125 String message, String targetOrigin, int[] msgPorts);
3111 3126
3112 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess agePort[] ports); 3127 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess agePort[] ports);
3113 } 3128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698