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

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

Issue 144283007: Call WebViewClient#onPageFinished when a main frame fails to load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test onReceivedError is called before onPageFinished Created 6 years, 10 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.content.pm.ActivityInfo; 7 import android.content.pm.ActivityInfo;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Picture; 9 import android.graphics.Picture;
10 import android.net.http.SslError; 10 import android.net.http.SslError;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 mCallbackHelper = new AwContentsClientCallbackHelper(looper, this); 51 mCallbackHelper = new AwContentsClientCallbackHelper(looper, this);
52 } 52 }
53 53
54 class AwWebContentsObserver extends WebContentsObserverAndroid { 54 class AwWebContentsObserver extends WebContentsObserverAndroid {
55 public AwWebContentsObserver(ContentViewCore contentViewCore) { 55 public AwWebContentsObserver(ContentViewCore contentViewCore) {
56 super(contentViewCore); 56 super(contentViewCore);
57 } 57 }
58 58
59 @Override 59 @Override
60 public void didFinishLoad(long frameId, String validatedUrl, boolean isM ainFrame) { 60 public void didFinishLoad(long frameId, String validatedUrl, boolean isM ainFrame) {
61 if (isMainFrame) 61 if (isMainFrame) {
62 AwContentsClient.this.onPageFinished(validatedUrl); 62 AwContentsClient.this.onPageFinished(validatedUrl);
63 }
63 } 64 }
64 65
65 @Override 66 @Override
66 public void didFailLoad(boolean isProvisionalLoad, 67 public void didFailLoad(boolean isProvisionalLoad,
67 boolean isMainFrame, int errorCode, String description, String f ailingUrl) { 68 boolean isMainFrame, int errorCode, String description, String f ailingUrl) {
68 if (errorCode == NetError.ERR_ABORTED) { 69 if (isMainFrame) {
69 // This error code is generated for the following reasons: 70 if (errorCode != NetError.ERR_ABORTED) {
70 // - WebView.stopLoading is called, 71 // This error code is generated for the following reasons:
71 // - the navigation is intercepted by the embedder via shouldOve rrideNavigation. 72 // - WebView.stopLoading is called,
72 // 73 // - the navigation is intercepted by the embedder via shoul dOverrideNavigation.
73 // The Android WebView does not notify the embedder of these sit uations using this 74 //
74 // error code with the WebViewClient.onReceivedError callback. 75 // The Android WebView does not notify the embedder of these situations using
75 return; 76 // this error code with the WebViewClient.onReceivedError ca llback.
77 AwContentsClient.this.onReceivedError(
78 ErrorCodeConversionHelper.convertErrorCode(errorCode ), description,
79 failingUrl);
80 }
81 // Need to call onPageFinished after onReceivedError (if there i s an error) for
82 // backwards compatibility with the classic webview.
83 AwContentsClient.this.onPageFinished(failingUrl);
mkosiba (inactive) 2014/02/12 16:03:38 The reason we have the errorCode check in the firs
76 } 84 }
77 if (!isMainFrame) {
78 // The Android WebView does not notify the embedder of sub-frame failures.
79 return;
80 }
81 AwContentsClient.this.onReceivedError(
82 ErrorCodeConversionHelper.convertErrorCode(errorCode), descr iption, failingUrl);
83 } 85 }
84 86
85 @Override 87 @Override
86 public void didNavigateMainFrame(String url, String baseUrl, 88 public void didNavigateMainFrame(String url, String baseUrl,
87 boolean isNavigationToDifferentPage, boolean isNavigationInPage) { 89 boolean isNavigationToDifferentPage, boolean isNavigationInPage) {
88 // This is here to emulate the Classic WebView firing onPageFinished for main frame 90 // This is here to emulate the Classic WebView firing onPageFinished for main frame
89 // navigations where only the hash fragment changes. 91 // navigations where only the hash fragment changes.
90 if (isNavigationInPage) { 92 if (isNavigationInPage) {
91 AwContentsClient.this.onPageFinished(url); 93 AwContentsClient.this.onPageFinished(url);
92 } 94 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, 236 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches,
235 boolean isDoneCounting); 237 boolean isDoneCounting);
236 238
237 /** 239 /**
238 * Called whenever there is a new content picture available. 240 * Called whenever there is a new content picture available.
239 * @param picture New picture. 241 * @param picture New picture.
240 */ 242 */
241 public abstract void onNewPicture(Picture picture); 243 public abstract void onNewPicture(Picture picture);
242 244
243 } 245 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698