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.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 Loading... | |
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 AwContentsClient.this.onPageFinished(failingUrl); |
boliu
2014/02/11 23:40:03
Check what the ordering of onPageFinished vs onRec
| |
70 // - WebView.stopLoading is called, | 71 if (errorCode == NetError.ERR_ABORTED) { |
71 // - the navigation is intercepted by the embedder via shouldOve rrideNavigation. | 72 // This error code is generated for the following reasons: |
72 // | 73 // - WebView.stopLoading is called, |
73 // The Android WebView does not notify the embedder of these sit uations using this | 74 // - the navigation is intercepted by the embedder via shoul dOverrideNavigation. |
74 // error code with the WebViewClient.onReceivedError callback. | 75 // |
75 return; | 76 // The Android WebView does not notify the embedder of these situations using |
77 // this error code with the WebViewClient.onReceivedError ca llback. | |
78 return; | |
79 } | |
80 AwContentsClient.this.onReceivedError( | |
81 ErrorCodeConversionHelper.convertErrorCode(errorCode), d escription, | |
82 failingUrl); | |
76 } | 83 } |
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 } | 84 } |
84 | 85 |
85 @Override | 86 @Override |
86 public void didNavigateMainFrame(String url, String baseUrl, | 87 public void didNavigateMainFrame(String url, String baseUrl, |
87 boolean isNavigationToDifferentPage, boolean isNavigationInPage) { | 88 boolean isNavigationToDifferentPage, boolean isNavigationInPage) { |
88 // This is here to emulate the Classic WebView firing onPageFinished for main frame | 89 // This is here to emulate the Classic WebView firing onPageFinished for main frame |
89 // navigations where only the hash fragment changes. | 90 // navigations where only the hash fragment changes. |
90 if (isNavigationInPage) { | 91 if (isNavigationInPage) { |
91 AwContentsClient.this.onPageFinished(url); | 92 AwContentsClient.this.onPageFinished(url); |
92 } | 93 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, | 235 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, |
235 boolean isDoneCounting); | 236 boolean isDoneCounting); |
236 | 237 |
237 /** | 238 /** |
238 * Called whenever there is a new content picture available. | 239 * Called whenever there is a new content picture available. |
239 * @param picture New picture. | 240 * @param picture New picture. |
240 */ | 241 */ |
241 public abstract void onNewPicture(Picture picture); | 242 public abstract void onNewPicture(Picture picture); |
242 | 243 |
243 } | 244 } |
OLD | NEW |