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

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

Issue 445403002: [android_webview] Factor AwWebContentsObserver out of AwContentsClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 package org.chromium.android_webview;
6
7 import org.chromium.content.browser.WebContentsObserverAndroid;
8 import org.chromium.content_public.browser.WebContents;
9 import org.chromium.net.NetError;
10
11 /**
12 * Routes notifications from WebContents to AwContentsClient and other listeners .
13 */
14 public class AwWebContentsObserver extends WebContentsObserverAndroid {
15 private final AwContentsClient mAwContentsClient;
16
17 public AwWebContentsObserver(WebContents webContents, AwContentsClient awCon tentsClient) {
18 super(webContents);
19 mAwContentsClient = awContentsClient;
20 }
21
22 @Override
23 public void didFinishLoad(long frameId, String validatedUrl, boolean isMainF rame) {
24 String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUr l();
25 boolean isErrorUrl =
26 unreachableWebDataUrl != null && unreachableWebDataUrl.equals(va lidatedUrl);
27 if (isMainFrame && !isErrorUrl) {
28 mAwContentsClient.onPageFinished(validatedUrl);
29 }
30 }
31
32 @Override
33 public void didFailLoad(boolean isProvisionalLoad,
34 boolean isMainFrame, int errorCode, String description, String faili ngUrl) {
35 String unreachableWebDataUrl = AwContentsStatics.getUnreachableWebDataUr l();
36 boolean isErrorUrl =
37 unreachableWebDataUrl != null && unreachableWebDataUrl.equals(fa ilingUrl);
38 if (isMainFrame && !isErrorUrl) {
39 if (errorCode != NetError.ERR_ABORTED) {
40 // This error code is generated for the following reasons:
41 // - WebView.stopLoading is called,
42 // - the navigation is intercepted by the embedder via shouldOve rrideNavigation.
43 //
44 // The Android WebView does not notify the embedder of these sit uations using
45 // this error code with the WebViewClient.onReceivedError callba ck.
46 mAwContentsClient.onReceivedError(
47 ErrorCodeConversionHelper.convertErrorCode(errorCode), d escription,
48 failingUrl);
49 }
50 // Need to call onPageFinished after onReceivedError (if there is an error) for
51 // backwards compatibility with the classic webview.
52 mAwContentsClient.onPageFinished(failingUrl);
53 }
54 }
55
56 @Override
57 public void didNavigateMainFrame(String url, String baseUrl,
58 boolean isNavigationToDifferentPage, boolean isFragmentNavigation) {
59 // This is here to emulate the Classic WebView firing onPageFinished for main frame
60 // navigations where only the hash fragment changes.
61 if (isFragmentNavigation) {
62 mAwContentsClient.onPageFinished(url);
63 }
64 }
65
66 @Override
67 public void didNavigateAnyFrame(String url, String baseUrl, boolean isReload ) {
68 mAwContentsClient.doUpdateVisitedHistory(url, isReload);
69 }
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698