Chromium Code Reviews| 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 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 AwContentsClient.this.onPageFinished(failingUrl); | |
|
boliu
2014/02/12 01:07:07
Definitely add a comment about the ordering. Even
| |
| 76 } | 82 } |
| 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 } | 83 } |
| 84 | 84 |
| 85 @Override | 85 @Override |
| 86 public void didNavigateMainFrame(String url, String baseUrl, | 86 public void didNavigateMainFrame(String url, String baseUrl, |
| 87 boolean isNavigationToDifferentPage, boolean isNavigationInPage) { | 87 boolean isNavigationToDifferentPage, boolean isNavigationInPage) { |
| 88 // This is here to emulate the Classic WebView firing onPageFinished for main frame | 88 // This is here to emulate the Classic WebView firing onPageFinished for main frame |
| 89 // navigations where only the hash fragment changes. | 89 // navigations where only the hash fragment changes. |
| 90 if (isNavigationInPage) { | 90 if (isNavigationInPage) { |
| 91 AwContentsClient.this.onPageFinished(url); | 91 AwContentsClient.this.onPageFinished(url); |
| 92 } | 92 } |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, | 234 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, |
| 235 boolean isDoneCounting); | 235 boolean isDoneCounting); |
| 236 | 236 |
| 237 /** | 237 /** |
| 238 * Called whenever there is a new content picture available. | 238 * Called whenever there is a new content picture available. |
| 239 * @param picture New picture. | 239 * @param picture New picture. |
| 240 */ | 240 */ |
| 241 public abstract void onNewPicture(Picture picture); | 241 public abstract void onNewPicture(Picture picture); |
| 242 | 242 |
| 243 } | 243 } |
| OLD | NEW |