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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwWebContentsObserver.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 org.chromium.android_webview.AwContents.VisualStateCallback; 7 import org.chromium.android_webview.AwContents.VisualStateCallback;
8 import org.chromium.base.ThreadUtils; 8 import org.chromium.base.ThreadUtils;
9 import org.chromium.content_public.browser.WebContents; 9 import org.chromium.content_public.browser.WebContents;
10 import org.chromium.content_public.browser.WebContentsObserver; 10 import org.chromium.content_public.browser.WebContentsObserver;
(...skipping 25 matching lines...) Expand all
36 if (client == null) return; 36 if (client == null) return;
37 String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUr l(); 37 String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUr l();
38 boolean isErrorUrl = 38 boolean isErrorUrl =
39 unreachableWebDataUrl != null && unreachableWebDataUrl.equals(va lidatedUrl); 39 unreachableWebDataUrl != null && unreachableWebDataUrl.equals(va lidatedUrl);
40 if (isMainFrame && !isErrorUrl) { 40 if (isMainFrame && !isErrorUrl) {
41 client.onPageFinished(validatedUrl); 41 client.onPageFinished(validatedUrl);
42 } 42 }
43 } 43 }
44 44
45 @Override 45 @Override
46 public void didFailLoad(boolean isProvisionalLoad, 46 public void didFailLoad(boolean isProvisionalLoad, boolean isMainFrame, int errorCode,
47 boolean isMainFrame, int errorCode, String description, String faili ngUrl) { 47 String description, String failingUrl, boolean wasIgnoredByHandler) {
48 AwContentsClient client = mAwContentsClient.get(); 48 AwContentsClient client = mAwContentsClient.get();
49 if (client == null) return; 49 if (client == null) return;
50 String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUr l(); 50 String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUr l();
51 boolean isErrorUrl = 51 boolean isErrorUrl =
52 unreachableWebDataUrl != null && unreachableWebDataUrl.equals(fa ilingUrl); 52 unreachableWebDataUrl != null && unreachableWebDataUrl.equals(fa ilingUrl);
53 if (isMainFrame && !isErrorUrl && errorCode == NetError.ERR_ABORTED) { 53 if (isMainFrame && !isErrorUrl && errorCode == NetError.ERR_ABORTED) {
54 // Need to call onPageFinished for backwards compatibility with the classic webview. 54 // Need to call onPageFinished for backwards compatibility with the classic webview.
55 // See also AwContents.IoThreadClientImpl.onReceivedError. 55 // See also AwContents.IoThreadClientImpl.onReceivedError.
56 client.onPageFinished(failingUrl); 56 // If the navigation was ignored because of shouldOverrideUrlLoading we have already
57 // called onPageFinished in
58 // AwContents.InterceptNavigationDelegateImpl.shouldIgnoreNavigation instead.
59 if (!wasIgnoredByHandler) {
mnaganov (inactive) 2015/06/04 19:09:27 nit: Why not to put this condition check into the
gsennton 2015/06/08 14:07:23 Done.
60 client.onPageFinished(failingUrl);
61 }
57 } 62 }
58 } 63 }
59 64
60 @Override 65 @Override
61 public void didNavigateMainFrame(final String url, String baseUrl, 66 public void didNavigateMainFrame(final String url, String baseUrl,
62 boolean isNavigationToDifferentPage, boolean isFragmentNavigation, i nt statusCode) { 67 boolean isNavigationToDifferentPage, boolean isFragmentNavigation, i nt statusCode) {
63 // Only invoke the onPageCommitVisible callback when navigating to a dif ferent page, 68 // Only invoke the onPageCommitVisible callback when navigating to a dif ferent page,
64 // but not when navigating to a different fragment within the same page. 69 // but not when navigating to a different fragment within the same page.
65 if (isNavigationToDifferentPage) { 70 if (isNavigationToDifferentPage) {
66 ThreadUtils.postOnUiThread(new Runnable() { 71 ThreadUtils.postOnUiThread(new Runnable() {
(...skipping 24 matching lines...) Expand all
91 } 96 }
92 } 97 }
93 98
94 @Override 99 @Override
95 public void didNavigateAnyFrame(String url, String baseUrl, boolean isReload ) { 100 public void didNavigateAnyFrame(String url, String baseUrl, boolean isReload ) {
96 final AwContentsClient client = mAwContentsClient.get(); 101 final AwContentsClient client = mAwContentsClient.get();
97 if (client == null) return; 102 if (client == null) return;
98 client.doUpdateVisitedHistory(url, isReload); 103 client.doUpdateVisitedHistory(url, isReload);
99 } 104 }
100 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698