This source file includes following definitions.
- didFinishLoad
- didFailLoad
- didNavigateMainFrame
- didNavigateAnyFrame
- installWebContentsObserver
- getCallbackHelper
- getCachedRendererBackgroundColor
- isCachedRendererBackgroundColorValid
- onBackgroundColorChanged
- getVisitedHistory
- doUpdateVisitedHistory
- onProgressChanged
- shouldInterceptRequest
- shouldOverrideKeyEvent
- shouldOverrideUrlLoading
- onLoadResource
- onUnhandledKeyEvent
- onConsoleMessage
- onReceivedHttpAuthRequest
- onReceivedSslError
- onReceivedLoginRequest
- onFormResubmission
- onDownloadStart
- showFileChooser
- onGeolocationPermissionsShowPrompt
- onGeolocationPermissionsHidePrompt
- onScaleChangedScaled
- handleJsAlert
- handleJsBeforeUnload
- handleJsConfirm
- handleJsPrompt
- onCreateWindow
- onCloseWindow
- onReceivedTouchIconUrl
- onReceivedIcon
- onReceivedTitle
- onRequestFocus
- getVideoLoadingProgressView
- onPageStarted
- onPageFinished
- onReceivedError
- onShowCustomView
- onShowCustomView
- onHideCustomView
- getDefaultVideoPoster
- onFindResultReceived
- onNewPicture
package org.chromium.android_webview;
import android.content.pm.ActivityInfo;
import android.graphics.Bitmap;
import android.graphics.Picture;
import android.net.http.SslError;
import android.os.Looper;
import android.os.Message;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.GeolocationPermissions;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.WebContentsObserverAndroid;
import org.chromium.net.NetError;
public abstract class AwContentsClient {
private final AwContentsClientCallbackHelper mCallbackHelper;
private AwWebContentsObserver mWebContentsObserver;
private int mCachedRendererBackgroundColor = INVALID_COLOR;
private static final int INVALID_COLOR = 0;
public AwContentsClient() {
this(Looper.myLooper());
}
public AwContentsClient(Looper looper) {
mCallbackHelper = new AwContentsClientCallbackHelper(looper, this);
}
class AwWebContentsObserver extends WebContentsObserverAndroid {
public AwWebContentsObserver(ContentViewCore contentViewCore) {
super(contentViewCore);
}
@Override
public void didFinishLoad(long frameId, String validatedUrl, boolean isMainFrame) {
if (isMainFrame) {
AwContentsClient.this.onPageFinished(validatedUrl);
}
}
@Override
public void didFailLoad(boolean isProvisionalLoad,
boolean isMainFrame, int errorCode, String description, String failingUrl) {
if (isMainFrame) {
if (errorCode != NetError.ERR_ABORTED) {
AwContentsClient.this.onReceivedError(
ErrorCodeConversionHelper.convertErrorCode(errorCode), description,
failingUrl);
}
AwContentsClient.this.onPageFinished(failingUrl);
}
}
@Override
public void didNavigateMainFrame(String url, String baseUrl,
boolean isNavigationToDifferentPage, boolean isNavigationInPage) {
if (isNavigationInPage) {
AwContentsClient.this.onPageFinished(url);
}
}
@Override
public void didNavigateAnyFrame(String url, String baseUrl, boolean isReload) {
AwContentsClient.this.doUpdateVisitedHistory(url, isReload);
}
}
final void installWebContentsObserver(ContentViewCore contentViewCore) {
if (mWebContentsObserver != null) {
mWebContentsObserver.detachFromWebContents();
}
mWebContentsObserver = new AwWebContentsObserver(contentViewCore);
}
final AwContentsClientCallbackHelper getCallbackHelper() {
return mCallbackHelper;
}
final int getCachedRendererBackgroundColor() {
assert isCachedRendererBackgroundColorValid();
return mCachedRendererBackgroundColor;
}
final boolean isCachedRendererBackgroundColorValid() {
return mCachedRendererBackgroundColor != INVALID_COLOR;
}
final void onBackgroundColorChanged(int color) {
mCachedRendererBackgroundColor = color == INVALID_COLOR ? 1 : color;
}
public static class FileChooserParams {
public int mode;
public String acceptTypes;
public String title;
public String defaultFilename;
public boolean capture;
}
public abstract void getVisitedHistory(ValueCallback<String[]> callback);
public abstract void doUpdateVisitedHistory(String url, boolean isReload);
public abstract void onProgressChanged(int progress);
public abstract InterceptedRequestData shouldInterceptRequest(String url);
public abstract boolean shouldOverrideKeyEvent(KeyEvent event);
public abstract boolean shouldOverrideUrlLoading(String url);
public abstract void onLoadResource(String url);
public abstract void onUnhandledKeyEvent(KeyEvent event);
public abstract boolean onConsoleMessage(ConsoleMessage consoleMessage);
public abstract void onReceivedHttpAuthRequest(AwHttpAuthHandler handler,
String host, String realm);
public abstract void onReceivedSslError(ValueCallback<Boolean> callback, SslError error);
public abstract void onReceivedLoginRequest(String realm, String account, String args);
public abstract void onFormResubmission(Message dontResend, Message resend);
public abstract void onDownloadStart(String url, String userAgent, String contentDisposition,
String mimeType, long contentLength);
public void showFileChooser(ValueCallback<String[]> uploadFilePathsCallback,
FileChooserParams fileChooserParams) { }
public abstract void onGeolocationPermissionsShowPrompt(String origin,
GeolocationPermissions.Callback callback);
public abstract void onGeolocationPermissionsHidePrompt();
public abstract void onScaleChangedScaled(float oldScale, float newScale);
protected abstract void handleJsAlert(String url, String message, JsResultReceiver receiver);
protected abstract void handleJsBeforeUnload(String url, String message,
JsResultReceiver receiver);
protected abstract void handleJsConfirm(String url, String message, JsResultReceiver receiver);
protected abstract void handleJsPrompt(String url, String message, String defaultValue,
JsPromptResultReceiver receiver);
protected abstract boolean onCreateWindow(boolean isDialog, boolean isUserGesture);
protected abstract void onCloseWindow();
public abstract void onReceivedTouchIconUrl(String url, boolean precomposed);
public abstract void onReceivedIcon(Bitmap bitmap);
public abstract void onReceivedTitle(String title);
protected abstract void onRequestFocus();
protected abstract View getVideoLoadingProgressView();
public abstract void onPageStarted(String url);
public abstract void onPageFinished(String url);
public abstract void onReceivedError(int errorCode, String description, String failingUrl);
public void onShowCustomView(View view,
int requestedOrientation, WebChromeClient.CustomViewCallback callback) {
}
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
onShowCustomView(view, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, callback);
}
public abstract void onHideCustomView();
public abstract Bitmap getDefaultVideoPoster();
public abstract void onFindResultReceived(int activeMatchOrdinal, int numberOfMatches,
boolean isDoneCounting);
public abstract void onNewPicture(Picture picture);
}